kda


Namekda JSON
Version 0.3.0 PyPI version JSON
download
home_pagehttps://github.com/Becksteinlab/kda/
SummaryKinetic Diagram Analysis tools
upload_time2024-03-19 02:29:07
maintainer
docs_urlNone
authorNikolaus Awtrey
requires_python
licenseLGPLv3
keywords science kinetics chemistry physics
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Kinetic Diagram Analysis
==============================
[//]: # (Badges)
[![CI](https://github.com/Becksteinlab/kda/actions/workflows/test.yml/badge.svg)](https://github.com/Becksteinlab/kda/actions/workflows/test.yml)
[![codecov](https://codecov.io/gh/Becksteinlab/kda/branch/master/graph/badge.svg)](https://codecov.io/gh/Becksteinlab/kda/branch/master)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.5826394.svg)](https://doi.org/10.5281/zenodo.5826394)

Python package used for the analysis of biochemical kinetic diagrams using the diagrammatic approach developed by [T.L. Hill](https://link.springer.com/book/10.1007/978-1-4612-3558-3).

**WARNING:** this software is in flux and is not API stable.

## Examples

KDA has a host of capabilities, all beginning with defining the connections and reaction rates (if desired) for your system. This is done by constructing an `NxN`array with diagonal values set to zero, and off-diagonal values `(i, j)` representing connections (and reaction rates) between states `i` and `j`. If desired, these can be the edge weights (denoted `kij`), but they can be specified later.

The following is an example for a simple 3-state model with all nodes connected:
```python
import numpy as np
import networkx as nx
from kda import graph_utils, calculations

# define matrix with reaction rates set to 1
K = np.array(
    [
        [0, 1, 1],
        [1, 0, 1],
        [1, 1, 0],
    ]
)
# initialize an empty graph object
G = nx.MultiDiGraph()
# populate the edge data
graph_utils.generate_edges(G, K, val_key="val", name_key="name")
# calculate the state probabilities
state_probabilities = calculations.calc_state_probs(G, key="val")
# get the state probabilities in expression form
state_probability_str = calculations.calc_state_probs(G, key="name", output_strings=True)
# print results
print("State probabilities: \n", state_probabilities)
print("State 1 probability expression: \n", state_probability_str[0])
```

The output from the above example:
```bash
$ python example_script.py
State probabilities:
 [0.33333333 0.33333333 0.33333333]
State 1 probability expression:
 (k21*k31 + k21*k32 + k23*k31)/(k12*k23 + k12*k31 + k12*k32 + k13*k21 + k13*k23 + k13*k32 + k21*k31 + k21*k32 + k23*k31)
```
As expected, the state probabilities are equal because all edge weights are set to a value of 1.

Continuing with the previous example, the KDA `diagrams` and `plotting` modules can be leveraged to display the diagrams that lead to the above probability expression:
```python
import os
from kda import diagrams, plotting

# generate the set of directional diagrams for G
directional_diagrams = diagrams.generate_directional_diagrams(G)
# get the current working directory
cwd = os.getcwd()
# specify the positions of all nodes in NetworkX fashion
node_positions = {0: [0, 1], 1: [-0.5, 0], 2: [0.5, 0]}
# plot and save the input diagram
plotting.draw_diagrams(G, pos=node_positions, path=cwd, label="input")
# plot and save the directional diagrams as a panel
plotting.draw_diagrams(
    directional_diagrams,
    pos=node_positions,
    path=cwd,
    cbt=True,
    label="directional_panel",
)
```

This will generate two files, `input.png` and `directional_panel.png`, in your current working directory:

#### `input.png`
<img src="https://github.com/Becksteinlab/kda-examples/blob/master/kda_examples/test_model_3_state/diagrams/input.png" width=300, alt="3-state model input diagram">

#### `directional.png`
<img src="https://github.com/Becksteinlab/kda-examples/blob/master/kda_examples/test_model_3_state/diagrams/directional.png" width=300, alt="3-state model directional diagrams">

**NOTE:** For more examples (like the following) visit the [KDA examples](https://github.com/Becksteinlab/kda-examples) repository:

<img src="https://github.com/Becksteinlab/kda-examples/blob/master/kda_examples/test_model_4_state_leakage/diagrams/input.png" width=250, alt="4-state model with leakage input diagram"> <img src="https://github.com/Becksteinlab/kda-examples/blob/master/kda_examples/test_model_5_state_leakage/diagrams/input.png" width=250, alt="5-state model with leakage input diagram"> <img src="https://github.com/Becksteinlab/kda-examples/blob/master/kda_examples/test_model_6_state_leakage/diagrams/input.png" width=250, alt="6-state model with leakage input diagram">

## Installation
### Development version from source

To install the latest development version from source, run
```bash
git clone git@github.com:Becksteinlab/kda.git
cd kda
python setup.py install
```

## Copyright

Copyright (c) 2020, Nikolaus Awtrey

## Acknowledgements

Project based on the
[Computational Molecular Science Python Cookiecutter](https://github.com/molssi/cookiecutter-cms) version 1.2.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Becksteinlab/kda/",
    "name": "kda",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "science kinetics chemistry physics",
    "author": "Nikolaus Awtrey",
    "author_email": "nawtrey@asu.edu",
    "download_url": "https://files.pythonhosted.org/packages/f3/e5/1fb1952561f1bec1208eaa0c4f91ebbcde3fe3a37823d20e3ec3c5b0fc88/kda-0.3.0.tar.gz",
    "platform": null,
    "description": "Kinetic Diagram Analysis\r\n==============================\r\n[//]: # (Badges)\r\n[![CI](https://github.com/Becksteinlab/kda/actions/workflows/test.yml/badge.svg)](https://github.com/Becksteinlab/kda/actions/workflows/test.yml)\r\n[![codecov](https://codecov.io/gh/Becksteinlab/kda/branch/master/graph/badge.svg)](https://codecov.io/gh/Becksteinlab/kda/branch/master)\r\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.5826394.svg)](https://doi.org/10.5281/zenodo.5826394)\r\n\r\nPython package used for the analysis of biochemical kinetic diagrams using the diagrammatic approach developed by [T.L. Hill](https://link.springer.com/book/10.1007/978-1-4612-3558-3).\r\n\r\n**WARNING:** this software is in flux and is not API stable.\r\n\r\n## Examples\r\n\r\nKDA has a host of capabilities, all beginning with defining the connections and reaction rates (if desired) for your system. This is done by constructing an `NxN`array with diagonal values set to zero, and off-diagonal values `(i, j)` representing connections (and reaction rates) between states `i` and `j`. If desired, these can be the edge weights (denoted `kij`), but they can be specified later.\r\n\r\nThe following is an example for a simple 3-state model with all nodes connected:\r\n```python\r\nimport numpy as np\r\nimport networkx as nx\r\nfrom kda import graph_utils, calculations\r\n\r\n# define matrix with reaction rates set to 1\r\nK = np.array(\r\n    [\r\n        [0, 1, 1],\r\n        [1, 0, 1],\r\n        [1, 1, 0],\r\n    ]\r\n)\r\n# initialize an empty graph object\r\nG = nx.MultiDiGraph()\r\n# populate the edge data\r\ngraph_utils.generate_edges(G, K, val_key=\"val\", name_key=\"name\")\r\n# calculate the state probabilities\r\nstate_probabilities = calculations.calc_state_probs(G, key=\"val\")\r\n# get the state probabilities in expression form\r\nstate_probability_str = calculations.calc_state_probs(G, key=\"name\", output_strings=True)\r\n# print results\r\nprint(\"State probabilities: \\n\", state_probabilities)\r\nprint(\"State 1 probability expression: \\n\", state_probability_str[0])\r\n```\r\n\r\nThe output from the above example:\r\n```bash\r\n$ python example_script.py\r\nState probabilities:\r\n [0.33333333 0.33333333 0.33333333]\r\nState 1 probability expression:\r\n (k21*k31 + k21*k32 + k23*k31)/(k12*k23 + k12*k31 + k12*k32 + k13*k21 + k13*k23 + k13*k32 + k21*k31 + k21*k32 + k23*k31)\r\n```\r\nAs expected, the state probabilities are equal because all edge weights are set to a value of 1.\r\n\r\nContinuing with the previous example, the KDA `diagrams` and `plotting` modules can be leveraged to display the diagrams that lead to the above probability expression:\r\n```python\r\nimport os\r\nfrom kda import diagrams, plotting\r\n\r\n# generate the set of directional diagrams for G\r\ndirectional_diagrams = diagrams.generate_directional_diagrams(G)\r\n# get the current working directory\r\ncwd = os.getcwd()\r\n# specify the positions of all nodes in NetworkX fashion\r\nnode_positions = {0: [0, 1], 1: [-0.5, 0], 2: [0.5, 0]}\r\n# plot and save the input diagram\r\nplotting.draw_diagrams(G, pos=node_positions, path=cwd, label=\"input\")\r\n# plot and save the directional diagrams as a panel\r\nplotting.draw_diagrams(\r\n    directional_diagrams,\r\n    pos=node_positions,\r\n    path=cwd,\r\n    cbt=True,\r\n    label=\"directional_panel\",\r\n)\r\n```\r\n\r\nThis will generate two files, `input.png` and `directional_panel.png`, in your current working directory:\r\n\r\n#### `input.png`\r\n<img src=\"https://github.com/Becksteinlab/kda-examples/blob/master/kda_examples/test_model_3_state/diagrams/input.png\" width=300, alt=\"3-state model input diagram\">\r\n\r\n#### `directional.png`\r\n<img src=\"https://github.com/Becksteinlab/kda-examples/blob/master/kda_examples/test_model_3_state/diagrams/directional.png\" width=300, alt=\"3-state model directional diagrams\">\r\n\r\n**NOTE:** For more examples (like the following) visit the [KDA examples](https://github.com/Becksteinlab/kda-examples) repository:\r\n\r\n<img src=\"https://github.com/Becksteinlab/kda-examples/blob/master/kda_examples/test_model_4_state_leakage/diagrams/input.png\" width=250, alt=\"4-state model with leakage input diagram\"> <img src=\"https://github.com/Becksteinlab/kda-examples/blob/master/kda_examples/test_model_5_state_leakage/diagrams/input.png\" width=250, alt=\"5-state model with leakage input diagram\"> <img src=\"https://github.com/Becksteinlab/kda-examples/blob/master/kda_examples/test_model_6_state_leakage/diagrams/input.png\" width=250, alt=\"6-state model with leakage input diagram\">\r\n\r\n## Installation\r\n### Development version from source\r\n\r\nTo install the latest development version from source, run\r\n```bash\r\ngit clone git@github.com:Becksteinlab/kda.git\r\ncd kda\r\npython setup.py install\r\n```\r\n\r\n## Copyright\r\n\r\nCopyright (c) 2020, Nikolaus Awtrey\r\n\r\n## Acknowledgements\r\n\r\nProject based on the\r\n[Computational Molecular Science Python Cookiecutter](https://github.com/molssi/cookiecutter-cms) version 1.2.\r\n",
    "bugtrack_url": null,
    "license": "LGPLv3",
    "summary": "Kinetic Diagram Analysis tools",
    "version": "0.3.0",
    "project_urls": {
        "Homepage": "https://github.com/Becksteinlab/kda/",
        "Issue Tracker": "https://github.com/Becksteinlab/kda/issues",
        "Source": "https://github.com/Becksteinlab/kda/"
    },
    "split_keywords": [
        "science",
        "kinetics",
        "chemistry",
        "physics"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "90d8436e0e94eced0248718e4a79b96fd52f9a2dff7ea006d9aae820c5d84279",
                "md5": "071a296198d6cdd7796d9180c697e4e2",
                "sha256": "14e144928e82379fb401e47a4d2a6a8aaf996d69f1eab7ecde92cd772e0142a6"
            },
            "downloads": -1,
            "filename": "kda-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "071a296198d6cdd7796d9180c697e4e2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 64939,
            "upload_time": "2024-03-19T02:29:05",
            "upload_time_iso_8601": "2024-03-19T02:29:05.485015Z",
            "url": "https://files.pythonhosted.org/packages/90/d8/436e0e94eced0248718e4a79b96fd52f9a2dff7ea006d9aae820c5d84279/kda-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f3e51fb1952561f1bec1208eaa0c4f91ebbcde3fe3a37823d20e3ec3c5b0fc88",
                "md5": "61364b1f6bfe2df21bc4f5efe66fd36a",
                "sha256": "f11e69f175f4548f3e1e987bb943546a7785cc30cbc44d5c0461837b56c6efa5"
            },
            "downloads": -1,
            "filename": "kda-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "61364b1f6bfe2df21bc4f5efe66fd36a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 74555,
            "upload_time": "2024-03-19T02:29:07",
            "upload_time_iso_8601": "2024-03-19T02:29:07.970926Z",
            "url": "https://files.pythonhosted.org/packages/f3/e5/1fb1952561f1bec1208eaa0c4f91ebbcde3fe3a37823d20e3ec3c5b0fc88/kda-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-19 02:29:07",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Becksteinlab",
    "github_project": "kda",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "kda"
}
        
Elapsed time: 3.19390s