SimBio 0.2.2__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {SimBio-0.2.2 → SimBio-0.3.0}/.gitignore +4 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/.pre-commit-config.yaml +10 -8
- SimBio-0.3.0/PKG-INFO +165 -0
- SimBio-0.3.0/README.md +134 -0
- SimBio-0.3.0/conftest.py +32 -0
- SimBio-0.3.0/src/SimBio.egg-info/PKG-INFO +165 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/src/SimBio.egg-info/SOURCES.txt +1 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/src/simbio/__init__.py +2 -2
- {SimBio-0.2.2 → SimBio-0.3.0}/src/simbio/core.py +59 -30
- {SimBio-0.2.2 → SimBio-0.3.0}/src/simbio/io/sbml/importer.py +6 -6
- {SimBio-0.2.2 → SimBio-0.3.0}/src/simbio/io/sbml/types.py +1 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/src/simbio/reactions/enzymatic.py +5 -5
- {SimBio-0.2.2 → SimBio-0.3.0}/src/simbio/reactions/test_reactions.py +3 -3
- {SimBio-0.2.2 → SimBio-0.3.0}/src/simbio/test_core.py +4 -4
- SimBio-0.2.2/PKG-INFO +0 -81
- SimBio-0.2.2/README.md +0 -50
- SimBio-0.2.2/src/SimBio.egg-info/PKG-INFO +0 -81
- {SimBio-0.2.2 → SimBio-0.3.0}/.gitattributes +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/.github/workflows/ci.yml +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/.readthedocs.yml +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/docs/_config.yml +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/docs/_toc.yml +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/docs/compilers/index.md +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/docs/design/design.md +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/docs/design/dsl.md +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/docs/design/features.md +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/docs/design/multilevel_dsl.md +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/docs/design/references.md +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/docs/examples/basic.md +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/docs/examples/chained-reactions.md +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/docs/examples/compartments.md +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/docs/examples/enzymatic.md +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/docs/index.md +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/docs/jupytext.toml +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/docs/model/dynamic.md +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/docs/model/index.md +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/docs/model/reactions.md +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/docs/model/static.md +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/docs/references.bib +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/environment-dev.yml +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/pyproject.toml +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/requirements.docs.txt +1 -1
- {SimBio-0.2.2 → SimBio-0.3.0}/requirements.io.txt +1 -1
- {SimBio-0.2.2 → SimBio-0.3.0}/requirements.test.txt +1 -1
- {SimBio-0.2.2 → SimBio-0.3.0}/requirements.txt +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/setup.cfg +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/src/SimBio.egg-info/dependency_links.txt +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/src/SimBio.egg-info/requires.txt +3 -3
- {SimBio-0.2.2 → SimBio-0.3.0}/src/SimBio.egg-info/top_level.txt +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/src/simbio/io/biomodels.py +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/src/simbio/io/mathML/__init__.py +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/src/simbio/io/mathML/exporter.py +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/src/simbio/io/mathML/importer.py +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/src/simbio/io/mathML/symbol.py +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/src/simbio/io/mathML/test_mathML.py +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/src/simbio/io/mathML/to_symbolite.py +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/src/simbio/io/sbml/__init__.py +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/src/simbio/io/sbml/from_libsbml.py +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/src/simbio/io/sbml/test_importer.py +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/src/simbio/reactions/__init__.py +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/src/simbio/reactions/compound.py +0 -0
- {SimBio-0.2.2 → SimBio-0.3.0}/src/simbio/reactions/single.py +0 -0
|
@@ -3,22 +3,24 @@ ci:
|
|
|
3
3
|
|
|
4
4
|
repos:
|
|
5
5
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
6
|
-
rev: v4.
|
|
6
|
+
rev: v4.5.0
|
|
7
7
|
hooks:
|
|
8
8
|
- id: check-yaml
|
|
9
|
+
- id: check-toml
|
|
10
|
+
- id: requirements-txt-fixer
|
|
11
|
+
- id: sort-simple-yaml
|
|
9
12
|
- id: end-of-file-fixer
|
|
10
13
|
- id: trailing-whitespace
|
|
11
|
-
- repo: https://github.com/
|
|
12
|
-
rev:
|
|
13
|
-
hooks:
|
|
14
|
-
- id: black
|
|
15
|
-
- repo: https://github.com/charliermarsh/ruff-pre-commit
|
|
16
|
-
rev: 'v0.0.278'
|
|
14
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
15
|
+
rev: v0.1.11
|
|
17
16
|
hooks:
|
|
18
17
|
- id: ruff
|
|
19
18
|
args: ["--fix"]
|
|
19
|
+
types_or: [python, pyi, jupyter]
|
|
20
|
+
- id: ruff-format
|
|
21
|
+
types_or: [python, pyi, jupyter]
|
|
20
22
|
- repo: https://github.com/executablebooks/mdformat
|
|
21
|
-
rev: 0.7.
|
|
23
|
+
rev: 0.7.17
|
|
22
24
|
hooks:
|
|
23
25
|
- id: mdformat
|
|
24
26
|
additional_dependencies:
|
SimBio-0.3.0/PKG-INFO
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: SimBio
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Simulation of Biological Systems
|
|
5
|
+
Author-email: "Hernán E. Grecco" <hernan.grecco@gmail.com>, Mauro Silberberg <maurosilber@gmail.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/hgrecco/simbio
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/hgrecco/simbio/issues
|
|
8
|
+
Keywords: mass action,michaelis menten,ode,compartment,reaction,SBML,poincare
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering
|
|
12
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
Requires-Dist: poincare>=0.3.1
|
|
19
|
+
Provides-Extra: io
|
|
20
|
+
Requires-Dist: biomodels; extra == "io"
|
|
21
|
+
Requires-Dist: python-libsbml; extra == "io"
|
|
22
|
+
Provides-Extra: test
|
|
23
|
+
Requires-Dist: pytest; extra == "test"
|
|
24
|
+
Requires-Dist: simbio[io]; extra == "test"
|
|
25
|
+
Provides-Extra: docs
|
|
26
|
+
Requires-Dist: jupyter-book; extra == "docs"
|
|
27
|
+
Requires-Dist: jupytext; extra == "docs"
|
|
28
|
+
Requires-Dist: numba; extra == "docs"
|
|
29
|
+
Requires-Dist: simbio-corbat2018; extra == "docs"
|
|
30
|
+
Requires-Dist: simbio[test]; extra == "docs"
|
|
31
|
+
|
|
32
|
+

|
|
33
|
+

|
|
34
|
+

|
|
35
|
+

|
|
36
|
+
[](https://github.com/hgrecco/simbio/actions/workflows/ci.yml)
|
|
37
|
+
|
|
38
|
+
# SimBio
|
|
39
|
+
|
|
40
|
+
`simbio` is a Python-based package for simulation of Chemical Reaction Networks (CRNs).
|
|
41
|
+
It extends [`poincare`](https://github.com/maurosilber/poincare),
|
|
42
|
+
a package for modelling dynamical systems,
|
|
43
|
+
to add functionality for CRNs.
|
|
44
|
+
|
|
45
|
+
## Usage
|
|
46
|
+
|
|
47
|
+
To create a system with two species $A$ and $B$
|
|
48
|
+
and a reaction converting $2A \\rightarrow B$ with rate 1:
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
>>> from simbio import Compartment, Species, RateLaw, initial
|
|
52
|
+
>>> class Model(Compartment):
|
|
53
|
+
... A: Species = initial(default=1)
|
|
54
|
+
... B: Species = initial(default=0)
|
|
55
|
+
... r = RateLaw(
|
|
56
|
+
... reactants=[2 * A],
|
|
57
|
+
... products=[B],
|
|
58
|
+
... rate_law=1,
|
|
59
|
+
... )
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
This corresponds to the following system of equations
|
|
63
|
+
|
|
64
|
+
$$
|
|
65
|
+
\\begin{cases}
|
|
66
|
+
\\frac{dA}{dt} = -2 \\
|
|
67
|
+
\\frac{dB}{dt} = +1
|
|
68
|
+
\\end{cases}
|
|
69
|
+
$$
|
|
70
|
+
|
|
71
|
+
with initial conditions
|
|
72
|
+
|
|
73
|
+
$$
|
|
74
|
+
\\begin{cases}
|
|
75
|
+
A(0) = 1 \\
|
|
76
|
+
B(0) = 0
|
|
77
|
+
\\end{cases}
|
|
78
|
+
$$
|
|
79
|
+
|
|
80
|
+
In CRNs,
|
|
81
|
+
we usually deal with [mass-action](https://en.wikipedia.org/wiki/Law_of_mass_action) reactions.
|
|
82
|
+
Using `MassAction` instead of `Reaction` automatically adds the reactants to the rate law:
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
>>> from simbio import MassAction
|
|
86
|
+
>>> class MassActionModel(Compartment):
|
|
87
|
+
... A: Species = initial(default=1)
|
|
88
|
+
... B: Species = initial(default=0)
|
|
89
|
+
... r = MassAction(
|
|
90
|
+
... reactants=[2 * A],
|
|
91
|
+
... products=[B],
|
|
92
|
+
... rate=1,
|
|
93
|
+
... )
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
generating the following equations:
|
|
97
|
+
|
|
98
|
+
$$
|
|
99
|
+
\\begin{cases}
|
|
100
|
+
\\frac{dA}{dt} = -2 A^2 \\
|
|
101
|
+
\\frac{dB}{dt} = +1 A^2
|
|
102
|
+
\\end{cases}
|
|
103
|
+
$$
|
|
104
|
+
|
|
105
|
+
To simulate the system,
|
|
106
|
+
use the `Simulator.solve` which outputs a `pandas.DataFrame`:
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
>>> from simbio import Simulator
|
|
110
|
+
>>> Simulator(MassActionModel).solve(save_at=range(5))
|
|
111
|
+
A B
|
|
112
|
+
time
|
|
113
|
+
0 1.000000 0.000000
|
|
114
|
+
1 0.333266 0.333367
|
|
115
|
+
2 0.199937 0.400032
|
|
116
|
+
3 0.142798 0.428601
|
|
117
|
+
4 0.111061 0.444470
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
For more details into SimBio's capabilities,
|
|
121
|
+
we recommend reading [poincaré's README](https://github.com/maurosilber/poincare).
|
|
122
|
+
|
|
123
|
+
## SBML
|
|
124
|
+
|
|
125
|
+
SimBio can import models from Systems Biology Markup Language (SBML) files:
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
>>> from simbio.io import sbml
|
|
129
|
+
>>> sbml.load("repressilator.sbml")
|
|
130
|
+
Elowitz2000 - Repressilator
|
|
131
|
+
-----------------------------------------------------------------------------------
|
|
132
|
+
type total names
|
|
133
|
+
---------- ------- --------------------------------------------------------------
|
|
134
|
+
variables 6 PX, PY, PZ, X, Y, Z
|
|
135
|
+
parameters 17 cell, beta, alpha0, alpha, eff, n, KM, tau_mRNA, tau_prot, ...
|
|
136
|
+
equations 12 Reaction1, Reaction2, Reaction3, Reaction4, Reaction5, ...
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
or download them from the [BioModels](https://www.ebi.ac.uk/biomodels/) repository:
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
>>> from simbio.io import biomodels
|
|
143
|
+
>>> biomodels.load_model("BIOMD12")
|
|
144
|
+
Elowitz2000 - Repressilator
|
|
145
|
+
-----------------------------------------------------------------------------------
|
|
146
|
+
type total names
|
|
147
|
+
---------- ------- --------------------------------------------------------------
|
|
148
|
+
variables 6 PX, PY, PZ, X, Y, Z
|
|
149
|
+
parameters 17 cell, beta, alpha0, alpha, eff, n, KM, tau_mRNA, tau_prot, ...
|
|
150
|
+
equations 12 Reaction1, Reaction2, Reaction3, Reaction4, Reaction5, ...
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Installation
|
|
154
|
+
|
|
155
|
+
It can be installed from [PyPI](https://pypi.org/p/simbio) with `pip`:
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
pip install simbio
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Or, to additionally install the SBML importer:
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
pip install simbio[io]
|
|
165
|
+
```
|
SimBio-0.3.0/README.md
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+

|
|
2
|
+

|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
[](https://github.com/hgrecco/simbio/actions/workflows/ci.yml)
|
|
6
|
+
|
|
7
|
+
# SimBio
|
|
8
|
+
|
|
9
|
+
`simbio` is a Python-based package for simulation of Chemical Reaction Networks (CRNs).
|
|
10
|
+
It extends [`poincare`](https://github.com/maurosilber/poincare),
|
|
11
|
+
a package for modelling dynamical systems,
|
|
12
|
+
to add functionality for CRNs.
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
To create a system with two species $A$ and $B$
|
|
17
|
+
and a reaction converting $2A \\rightarrow B$ with rate 1:
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
>>> from simbio import Compartment, Species, RateLaw, initial
|
|
21
|
+
>>> class Model(Compartment):
|
|
22
|
+
... A: Species = initial(default=1)
|
|
23
|
+
... B: Species = initial(default=0)
|
|
24
|
+
... r = RateLaw(
|
|
25
|
+
... reactants=[2 * A],
|
|
26
|
+
... products=[B],
|
|
27
|
+
... rate_law=1,
|
|
28
|
+
... )
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
This corresponds to the following system of equations
|
|
32
|
+
|
|
33
|
+
$$
|
|
34
|
+
\\begin{cases}
|
|
35
|
+
\\frac{dA}{dt} = -2 \\
|
|
36
|
+
\\frac{dB}{dt} = +1
|
|
37
|
+
\\end{cases}
|
|
38
|
+
$$
|
|
39
|
+
|
|
40
|
+
with initial conditions
|
|
41
|
+
|
|
42
|
+
$$
|
|
43
|
+
\\begin{cases}
|
|
44
|
+
A(0) = 1 \\
|
|
45
|
+
B(0) = 0
|
|
46
|
+
\\end{cases}
|
|
47
|
+
$$
|
|
48
|
+
|
|
49
|
+
In CRNs,
|
|
50
|
+
we usually deal with [mass-action](https://en.wikipedia.org/wiki/Law_of_mass_action) reactions.
|
|
51
|
+
Using `MassAction` instead of `Reaction` automatically adds the reactants to the rate law:
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
>>> from simbio import MassAction
|
|
55
|
+
>>> class MassActionModel(Compartment):
|
|
56
|
+
... A: Species = initial(default=1)
|
|
57
|
+
... B: Species = initial(default=0)
|
|
58
|
+
... r = MassAction(
|
|
59
|
+
... reactants=[2 * A],
|
|
60
|
+
... products=[B],
|
|
61
|
+
... rate=1,
|
|
62
|
+
... )
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
generating the following equations:
|
|
66
|
+
|
|
67
|
+
$$
|
|
68
|
+
\\begin{cases}
|
|
69
|
+
\\frac{dA}{dt} = -2 A^2 \\
|
|
70
|
+
\\frac{dB}{dt} = +1 A^2
|
|
71
|
+
\\end{cases}
|
|
72
|
+
$$
|
|
73
|
+
|
|
74
|
+
To simulate the system,
|
|
75
|
+
use the `Simulator.solve` which outputs a `pandas.DataFrame`:
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
>>> from simbio import Simulator
|
|
79
|
+
>>> Simulator(MassActionModel).solve(save_at=range(5))
|
|
80
|
+
A B
|
|
81
|
+
time
|
|
82
|
+
0 1.000000 0.000000
|
|
83
|
+
1 0.333266 0.333367
|
|
84
|
+
2 0.199937 0.400032
|
|
85
|
+
3 0.142798 0.428601
|
|
86
|
+
4 0.111061 0.444470
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
For more details into SimBio's capabilities,
|
|
90
|
+
we recommend reading [poincaré's README](https://github.com/maurosilber/poincare).
|
|
91
|
+
|
|
92
|
+
## SBML
|
|
93
|
+
|
|
94
|
+
SimBio can import models from Systems Biology Markup Language (SBML) files:
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
>>> from simbio.io import sbml
|
|
98
|
+
>>> sbml.load("repressilator.sbml")
|
|
99
|
+
Elowitz2000 - Repressilator
|
|
100
|
+
-----------------------------------------------------------------------------------
|
|
101
|
+
type total names
|
|
102
|
+
---------- ------- --------------------------------------------------------------
|
|
103
|
+
variables 6 PX, PY, PZ, X, Y, Z
|
|
104
|
+
parameters 17 cell, beta, alpha0, alpha, eff, n, KM, tau_mRNA, tau_prot, ...
|
|
105
|
+
equations 12 Reaction1, Reaction2, Reaction3, Reaction4, Reaction5, ...
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
or download them from the [BioModels](https://www.ebi.ac.uk/biomodels/) repository:
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
>>> from simbio.io import biomodels
|
|
112
|
+
>>> biomodels.load_model("BIOMD12")
|
|
113
|
+
Elowitz2000 - Repressilator
|
|
114
|
+
-----------------------------------------------------------------------------------
|
|
115
|
+
type total names
|
|
116
|
+
---------- ------- --------------------------------------------------------------
|
|
117
|
+
variables 6 PX, PY, PZ, X, Y, Z
|
|
118
|
+
parameters 17 cell, beta, alpha0, alpha, eff, n, KM, tau_mRNA, tau_prot, ...
|
|
119
|
+
equations 12 Reaction1, Reaction2, Reaction3, Reaction4, Reaction5, ...
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Installation
|
|
123
|
+
|
|
124
|
+
It can be installed from [PyPI](https://pypi.org/p/simbio) with `pip`:
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
pip install simbio
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Or, to additionally install the SBML importer:
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
pip install simbio[io]
|
|
134
|
+
```
|
SimBio-0.3.0/conftest.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
import biomodels
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def download_repressilator():
|
|
7
|
+
file = Path("repressilator.sbml")
|
|
8
|
+
if file.exists():
|
|
9
|
+
return
|
|
10
|
+
|
|
11
|
+
omex = biomodels.get_omex("BIOMD12")
|
|
12
|
+
file.write_bytes(omex.master.read_bytes())
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def setup_readme():
|
|
16
|
+
with open("README.md") as readme, open("test_readme.txt", "w") as out:
|
|
17
|
+
lines = iter(readme)
|
|
18
|
+
for line in lines:
|
|
19
|
+
if line.startswith("```python"):
|
|
20
|
+
while not (line := next(lines)).startswith("```"):
|
|
21
|
+
if line == "time\n":
|
|
22
|
+
# Hardcoding whitespace in DataFrame output
|
|
23
|
+
# which is removed from README.md by pre-commit hooks
|
|
24
|
+
line = next(lines)
|
|
25
|
+
out.write("time")
|
|
26
|
+
out.write(" " * (len(line) - 5))
|
|
27
|
+
out.write("\n")
|
|
28
|
+
out.write(line)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
download_repressilator()
|
|
32
|
+
setup_readme()
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: SimBio
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Simulation of Biological Systems
|
|
5
|
+
Author-email: "Hernán E. Grecco" <hernan.grecco@gmail.com>, Mauro Silberberg <maurosilber@gmail.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/hgrecco/simbio
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/hgrecco/simbio/issues
|
|
8
|
+
Keywords: mass action,michaelis menten,ode,compartment,reaction,SBML,poincare
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering
|
|
12
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
Requires-Dist: poincare>=0.3.1
|
|
19
|
+
Provides-Extra: io
|
|
20
|
+
Requires-Dist: biomodels; extra == "io"
|
|
21
|
+
Requires-Dist: python-libsbml; extra == "io"
|
|
22
|
+
Provides-Extra: test
|
|
23
|
+
Requires-Dist: pytest; extra == "test"
|
|
24
|
+
Requires-Dist: simbio[io]; extra == "test"
|
|
25
|
+
Provides-Extra: docs
|
|
26
|
+
Requires-Dist: jupyter-book; extra == "docs"
|
|
27
|
+
Requires-Dist: jupytext; extra == "docs"
|
|
28
|
+
Requires-Dist: numba; extra == "docs"
|
|
29
|
+
Requires-Dist: simbio-corbat2018; extra == "docs"
|
|
30
|
+
Requires-Dist: simbio[test]; extra == "docs"
|
|
31
|
+
|
|
32
|
+

|
|
33
|
+

|
|
34
|
+

|
|
35
|
+

|
|
36
|
+
[](https://github.com/hgrecco/simbio/actions/workflows/ci.yml)
|
|
37
|
+
|
|
38
|
+
# SimBio
|
|
39
|
+
|
|
40
|
+
`simbio` is a Python-based package for simulation of Chemical Reaction Networks (CRNs).
|
|
41
|
+
It extends [`poincare`](https://github.com/maurosilber/poincare),
|
|
42
|
+
a package for modelling dynamical systems,
|
|
43
|
+
to add functionality for CRNs.
|
|
44
|
+
|
|
45
|
+
## Usage
|
|
46
|
+
|
|
47
|
+
To create a system with two species $A$ and $B$
|
|
48
|
+
and a reaction converting $2A \\rightarrow B$ with rate 1:
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
>>> from simbio import Compartment, Species, RateLaw, initial
|
|
52
|
+
>>> class Model(Compartment):
|
|
53
|
+
... A: Species = initial(default=1)
|
|
54
|
+
... B: Species = initial(default=0)
|
|
55
|
+
... r = RateLaw(
|
|
56
|
+
... reactants=[2 * A],
|
|
57
|
+
... products=[B],
|
|
58
|
+
... rate_law=1,
|
|
59
|
+
... )
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
This corresponds to the following system of equations
|
|
63
|
+
|
|
64
|
+
$$
|
|
65
|
+
\\begin{cases}
|
|
66
|
+
\\frac{dA}{dt} = -2 \\
|
|
67
|
+
\\frac{dB}{dt} = +1
|
|
68
|
+
\\end{cases}
|
|
69
|
+
$$
|
|
70
|
+
|
|
71
|
+
with initial conditions
|
|
72
|
+
|
|
73
|
+
$$
|
|
74
|
+
\\begin{cases}
|
|
75
|
+
A(0) = 1 \\
|
|
76
|
+
B(0) = 0
|
|
77
|
+
\\end{cases}
|
|
78
|
+
$$
|
|
79
|
+
|
|
80
|
+
In CRNs,
|
|
81
|
+
we usually deal with [mass-action](https://en.wikipedia.org/wiki/Law_of_mass_action) reactions.
|
|
82
|
+
Using `MassAction` instead of `Reaction` automatically adds the reactants to the rate law:
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
>>> from simbio import MassAction
|
|
86
|
+
>>> class MassActionModel(Compartment):
|
|
87
|
+
... A: Species = initial(default=1)
|
|
88
|
+
... B: Species = initial(default=0)
|
|
89
|
+
... r = MassAction(
|
|
90
|
+
... reactants=[2 * A],
|
|
91
|
+
... products=[B],
|
|
92
|
+
... rate=1,
|
|
93
|
+
... )
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
generating the following equations:
|
|
97
|
+
|
|
98
|
+
$$
|
|
99
|
+
\\begin{cases}
|
|
100
|
+
\\frac{dA}{dt} = -2 A^2 \\
|
|
101
|
+
\\frac{dB}{dt} = +1 A^2
|
|
102
|
+
\\end{cases}
|
|
103
|
+
$$
|
|
104
|
+
|
|
105
|
+
To simulate the system,
|
|
106
|
+
use the `Simulator.solve` which outputs a `pandas.DataFrame`:
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
>>> from simbio import Simulator
|
|
110
|
+
>>> Simulator(MassActionModel).solve(save_at=range(5))
|
|
111
|
+
A B
|
|
112
|
+
time
|
|
113
|
+
0 1.000000 0.000000
|
|
114
|
+
1 0.333266 0.333367
|
|
115
|
+
2 0.199937 0.400032
|
|
116
|
+
3 0.142798 0.428601
|
|
117
|
+
4 0.111061 0.444470
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
For more details into SimBio's capabilities,
|
|
121
|
+
we recommend reading [poincaré's README](https://github.com/maurosilber/poincare).
|
|
122
|
+
|
|
123
|
+
## SBML
|
|
124
|
+
|
|
125
|
+
SimBio can import models from Systems Biology Markup Language (SBML) files:
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
>>> from simbio.io import sbml
|
|
129
|
+
>>> sbml.load("repressilator.sbml")
|
|
130
|
+
Elowitz2000 - Repressilator
|
|
131
|
+
-----------------------------------------------------------------------------------
|
|
132
|
+
type total names
|
|
133
|
+
---------- ------- --------------------------------------------------------------
|
|
134
|
+
variables 6 PX, PY, PZ, X, Y, Z
|
|
135
|
+
parameters 17 cell, beta, alpha0, alpha, eff, n, KM, tau_mRNA, tau_prot, ...
|
|
136
|
+
equations 12 Reaction1, Reaction2, Reaction3, Reaction4, Reaction5, ...
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
or download them from the [BioModels](https://www.ebi.ac.uk/biomodels/) repository:
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
>>> from simbio.io import biomodels
|
|
143
|
+
>>> biomodels.load_model("BIOMD12")
|
|
144
|
+
Elowitz2000 - Repressilator
|
|
145
|
+
-----------------------------------------------------------------------------------
|
|
146
|
+
type total names
|
|
147
|
+
---------- ------- --------------------------------------------------------------
|
|
148
|
+
variables 6 PX, PY, PZ, X, Y, Z
|
|
149
|
+
parameters 17 cell, beta, alpha0, alpha, eff, n, KM, tau_mRNA, tau_prot, ...
|
|
150
|
+
equations 12 Reaction1, Reaction2, Reaction3, Reaction4, Reaction5, ...
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Installation
|
|
154
|
+
|
|
155
|
+
It can be installed from [PyPI](https://pypi.org/p/simbio) with `pip`:
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
pip install simbio
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Or, to additionally install the SBML importer:
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
pip install simbio[io]
|
|
165
|
+
```
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from poincare import Constant, Independent, Parameter, assign
|
|
2
2
|
|
|
3
|
-
from .core import Compartment, MassAction,
|
|
3
|
+
from .core import Compartment, MassAction, RateLaw, Simulator, Species, initial
|
|
4
4
|
|
|
5
5
|
__all__ = [
|
|
6
6
|
"Constant",
|
|
@@ -11,7 +11,7 @@ __all__ = [
|
|
|
11
11
|
__all__ += [
|
|
12
12
|
"Compartment",
|
|
13
13
|
"MassAction",
|
|
14
|
-
"
|
|
14
|
+
"RateLaw",
|
|
15
15
|
"Species",
|
|
16
16
|
"initial",
|
|
17
17
|
"Simulator",
|
|
@@ -24,6 +24,7 @@ if TYPE_CHECKING:
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
def initial(*, default: Initial | None = None, init: bool = True) -> Species:
|
|
27
|
+
"""Creates an Species with a default initial condition."""
|
|
27
28
|
return Species(variable=default)
|
|
28
29
|
|
|
29
30
|
|
|
@@ -142,12 +143,14 @@ class Species(Node, Scalar):
|
|
|
142
143
|
expression=symbol.Expression(
|
|
143
144
|
func=symbol.mul,
|
|
144
145
|
args=(
|
|
145
|
-
int(st2)
|
|
146
|
+
int(st2)
|
|
147
|
+
| float(st2),
|
|
146
148
|
Species(variable=var, stoichiometry=st),
|
|
147
149
|
)
|
|
148
150
|
| (
|
|
149
151
|
Species(variable=var, stoichiometry=st),
|
|
150
|
-
int(st2)
|
|
152
|
+
int(st2)
|
|
153
|
+
| float(st2),
|
|
151
154
|
),
|
|
152
155
|
)
|
|
153
156
|
):
|
|
@@ -158,32 +161,43 @@ class Species(Node, Scalar):
|
|
|
158
161
|
|
|
159
162
|
|
|
160
163
|
@dataclass
|
|
161
|
-
class
|
|
164
|
+
class RateLaw(EquationGroup):
|
|
165
|
+
"""A RateLaw reaction contains a set of equations transforming
|
|
166
|
+
reactants into products with a given rate law.
|
|
167
|
+
|
|
168
|
+
Given:
|
|
169
|
+
- `x, y: Species`
|
|
170
|
+
- `k: float`
|
|
171
|
+
|
|
172
|
+
Then:
|
|
173
|
+
`Reaction(reactants=[2 * x], products=[y], rate_law=k)`
|
|
174
|
+
|
|
175
|
+
will contain two equations:
|
|
176
|
+
- `dx/dt = -2 * k`
|
|
177
|
+
- `dy/dt = +k`
|
|
178
|
+
"""
|
|
179
|
+
|
|
162
180
|
def __init__(
|
|
163
181
|
self,
|
|
164
182
|
*,
|
|
165
183
|
reactants: Sequence[Species],
|
|
166
184
|
products: Sequence[Species],
|
|
167
|
-
rate_law:
|
|
185
|
+
rate_law: float | Symbol,
|
|
168
186
|
):
|
|
169
187
|
self.reactants = tuple(map(Species.from_mul, reactants))
|
|
170
188
|
self.products = tuple(map(Species.from_mul, products))
|
|
171
|
-
self.rate_law = substitute(rate_law,
|
|
172
|
-
self.equations = tuple(self.
|
|
189
|
+
self.rate_law = substitute(rate_law, _SpeciesToVariable)
|
|
190
|
+
self.equations = tuple(self._yield_equations())
|
|
173
191
|
|
|
174
192
|
def _copy_from(self, parent: System):
|
|
175
193
|
mapper = NodeMapper(parent)
|
|
176
194
|
return self.__class__(
|
|
177
195
|
reactants=[substitute(v, mapper) for v in self.reactants],
|
|
178
196
|
products=[substitute(v, mapper) for v in self.products],
|
|
179
|
-
rate_law=substitute(substitute(self.rate_law, mapper),
|
|
197
|
+
rate_law=substitute(substitute(self.rate_law, mapper), _SpeciesToVariable),
|
|
180
198
|
)
|
|
181
199
|
|
|
182
|
-
def
|
|
183
|
-
if callable(self.rate_law):
|
|
184
|
-
rate = self.rate_law(*self.reactants)
|
|
185
|
-
else:
|
|
186
|
-
rate = self.rate_law
|
|
200
|
+
def _yield_equations(self) -> Iterator[Equation]:
|
|
187
201
|
species_stoich: dict[Variable, float] = defaultdict(float)
|
|
188
202
|
for r in self.reactants:
|
|
189
203
|
species_stoich[r.variable] -= r.stoichiometry
|
|
@@ -191,10 +205,27 @@ class Reaction(EquationGroup):
|
|
|
191
205
|
species_stoich[p.variable] += p.stoichiometry
|
|
192
206
|
|
|
193
207
|
for s, st in species_stoich.items():
|
|
194
|
-
yield s.derive() << st *
|
|
208
|
+
yield s.derive() << st * self.rate_law
|
|
209
|
+
|
|
195
210
|
|
|
211
|
+
class MassAction(RateLaw):
|
|
212
|
+
"""A MassAction reaction contains a set of equations transforming
|
|
213
|
+
reactants into products with a given rate.
|
|
214
|
+
The reaction's rate law is the product of the rate
|
|
215
|
+
and the reactants raised to their stoichiometric coefficient.
|
|
216
|
+
|
|
217
|
+
Given:
|
|
218
|
+
- `x, y: Species`
|
|
219
|
+
- `k: float`
|
|
220
|
+
|
|
221
|
+
Then:
|
|
222
|
+
`Reaction(reactants=[2 * x], products=[y], rate_law=k)`
|
|
223
|
+
|
|
224
|
+
will contain two equations:
|
|
225
|
+
- `dx/dt = -2 * k * x**2`
|
|
226
|
+
- `dy/dt = +k * x**2`
|
|
227
|
+
"""
|
|
196
228
|
|
|
197
|
-
class MassAction(Reaction):
|
|
198
229
|
def __init__(
|
|
199
230
|
self,
|
|
200
231
|
*,
|
|
@@ -204,12 +235,13 @@ class MassAction(Reaction):
|
|
|
204
235
|
):
|
|
205
236
|
self.reactants = tuple(map(Species.from_mul, reactants))
|
|
206
237
|
self.products = tuple(map(Species.from_mul, products))
|
|
207
|
-
self.rate = substitute(rate,
|
|
208
|
-
self.equations = tuple(self.
|
|
238
|
+
self.rate = substitute(rate, _SpeciesToVariable)
|
|
239
|
+
self.equations = tuple(self._yield_equations())
|
|
209
240
|
|
|
210
|
-
|
|
241
|
+
@property
|
|
242
|
+
def rate_law(self):
|
|
211
243
|
rate = self.rate
|
|
212
|
-
for r in reactants:
|
|
244
|
+
for r in self.reactants:
|
|
213
245
|
rate *= r.variable**r.stoichiometry
|
|
214
246
|
return rate
|
|
215
247
|
|
|
@@ -218,20 +250,20 @@ class MassAction(Reaction):
|
|
|
218
250
|
return self.__class__(
|
|
219
251
|
reactants=[substitute(v, mapper) for v in self.reactants],
|
|
220
252
|
products=[substitute(v, mapper) for v in self.products],
|
|
221
|
-
rate=substitute(substitute(self.rate, mapper),
|
|
253
|
+
rate=substitute(substitute(self.rate, mapper), _SpeciesToVariable),
|
|
222
254
|
)
|
|
223
255
|
|
|
224
256
|
|
|
225
|
-
def
|
|
257
|
+
def _species_to_variable(x):
|
|
226
258
|
if isinstance(x, Species):
|
|
227
259
|
return x.variable
|
|
228
260
|
else:
|
|
229
261
|
return x
|
|
230
262
|
|
|
231
263
|
|
|
232
|
-
class
|
|
264
|
+
class _SpeciesToVariable(dict):
|
|
233
265
|
def get(self, key, default=None):
|
|
234
|
-
return
|
|
266
|
+
return _species_to_variable(key)
|
|
235
267
|
|
|
236
268
|
|
|
237
269
|
class Simulator(_Simulator):
|
|
@@ -244,10 +276,10 @@ class Simulator(_Simulator):
|
|
|
244
276
|
transform: Sequence[Symbol] | Mapping[str, Symbol] | None = None,
|
|
245
277
|
):
|
|
246
278
|
if isinstance(transform, Sequence):
|
|
247
|
-
transform = [substitute(v,
|
|
279
|
+
transform = [substitute(v, _SpeciesToVariable()) for v in transform]
|
|
248
280
|
elif isinstance(transform, Mapping):
|
|
249
281
|
transform = {
|
|
250
|
-
k: substitute(v,
|
|
282
|
+
k: substitute(v, _SpeciesToVariable()) for k, v in transform.items()
|
|
251
283
|
}
|
|
252
284
|
super().__init__(system, backend=backend, transform=transform)
|
|
253
285
|
|
|
@@ -258,7 +290,7 @@ class Simulator(_Simulator):
|
|
|
258
290
|
t_span: tuple[float, float] = (0, np.inf),
|
|
259
291
|
):
|
|
260
292
|
return super().create_problem(
|
|
261
|
-
{
|
|
293
|
+
{_species_to_variable(k): v for k, v in values.items()},
|
|
262
294
|
t_span=t_span,
|
|
263
295
|
)
|
|
264
296
|
|
|
@@ -272,11 +304,8 @@ class Simulator(_Simulator):
|
|
|
272
304
|
func: Callable[[pd.DataFrame], Any] = lambda df: df.plot(),
|
|
273
305
|
):
|
|
274
306
|
if isinstance(values, Sequence):
|
|
275
|
-
values = [
|
|
307
|
+
values = [_species_to_variable(v) for v in values]
|
|
276
308
|
elif isinstance(values, Mapping):
|
|
277
|
-
values = {
|
|
278
|
-
k: v.variable if isinstance(v, Species) else v
|
|
279
|
-
for k, v in values.items()
|
|
280
|
-
}
|
|
309
|
+
values = {k: _species_to_variable(v) for k, v in values.items()}
|
|
281
310
|
|
|
282
311
|
return super().interact(values, t_span=t_span, save_at=save_at, func=func)
|
|
@@ -17,7 +17,7 @@ from ... import (
|
|
|
17
17
|
Constant,
|
|
18
18
|
Independent,
|
|
19
19
|
Parameter,
|
|
20
|
-
|
|
20
|
+
RateLaw,
|
|
21
21
|
Species,
|
|
22
22
|
initial,
|
|
23
23
|
)
|
|
@@ -282,7 +282,7 @@ class SBMLImporter:
|
|
|
282
282
|
if len(kinetic_law.parameters) > 0:
|
|
283
283
|
mapping = {}
|
|
284
284
|
for p in kinetic_law.parameters:
|
|
285
|
-
new_id = f"{r.id}
|
|
285
|
+
new_id = f"{r.id}__{p.id}"
|
|
286
286
|
self.add_parameter(replace(p, id=new_id))
|
|
287
287
|
mapping[p.id] = MathMLSymbol(new_id)
|
|
288
288
|
formula = substitute_by_name(formula, **mapping)
|
|
@@ -290,7 +290,7 @@ class SBMLImporter:
|
|
|
290
290
|
|
|
291
291
|
self.simbio.add(
|
|
292
292
|
r.id,
|
|
293
|
-
|
|
293
|
+
RateLaw(reactants=reactants, products=products, rate_law=formula),
|
|
294
294
|
)
|
|
295
295
|
return
|
|
296
296
|
|
|
@@ -298,7 +298,7 @@ class SBMLImporter:
|
|
|
298
298
|
if not r.reversible:
|
|
299
299
|
self.simbio.add(
|
|
300
300
|
r.id,
|
|
301
|
-
|
|
301
|
+
RateLaw(reactants=reactants, products=products, rate_law=formula),
|
|
302
302
|
)
|
|
303
303
|
return
|
|
304
304
|
|
|
@@ -334,7 +334,7 @@ class SBMLImporter:
|
|
|
334
334
|
# Cannot split formula into forward and reverse
|
|
335
335
|
self.simbio.add(
|
|
336
336
|
r.id,
|
|
337
|
-
|
|
337
|
+
RateLaw(reactants=reactants, products=products, rate_law=formula),
|
|
338
338
|
)
|
|
339
339
|
return
|
|
340
340
|
|
|
@@ -365,7 +365,7 @@ class SBMLImporter:
|
|
|
365
365
|
|
|
366
366
|
name = r.id
|
|
367
367
|
if name is None or name == r.variable:
|
|
368
|
-
name = f"{r.variable}
|
|
368
|
+
name = f"{r.variable}__rate_rule"
|
|
369
369
|
self.simbio.add(name, eq)
|
|
370
370
|
|
|
371
371
|
@add.register
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from ..core import Compartment,
|
|
1
|
+
from ..core import Compartment, Parameter, RateLaw, Species, assign, initial
|
|
2
2
|
from .compound import Dissociation, ReversibleSynthesis
|
|
3
3
|
|
|
4
4
|
|
|
@@ -55,10 +55,10 @@ class MichaelisMentenEqApprox(Compartment):
|
|
|
55
55
|
P: Species = initial()
|
|
56
56
|
maximum_velocity: Parameter = assign()
|
|
57
57
|
dissociation_constant: Parameter = assign()
|
|
58
|
-
reaction =
|
|
58
|
+
reaction = RateLaw(
|
|
59
59
|
reactants=[S],
|
|
60
60
|
products=[P],
|
|
61
|
-
|
|
61
|
+
rate_law=maximum_velocity * S / (dissociation_constant + S),
|
|
62
62
|
)
|
|
63
63
|
|
|
64
64
|
|
|
@@ -67,8 +67,8 @@ class MichaelisMentenQuasiSSAprox(Compartment):
|
|
|
67
67
|
P: Species = initial()
|
|
68
68
|
maximum_velocity: Parameter = assign()
|
|
69
69
|
michaelis_constant: Parameter = assign()
|
|
70
|
-
reaction =
|
|
70
|
+
reaction = RateLaw(
|
|
71
71
|
reactants=[S],
|
|
72
72
|
products=[P],
|
|
73
|
-
|
|
73
|
+
rate_law=maximum_velocity * S / (michaelis_constant + S),
|
|
74
74
|
)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import numpy as np
|
|
2
2
|
from pytest import mark
|
|
3
3
|
|
|
4
|
-
from ..core import Compartment, Parameter,
|
|
4
|
+
from ..core import Compartment, Parameter, RateLaw, Simulator, Species, assign, initial
|
|
5
5
|
from ..reactions import compound, enzymatic, single
|
|
6
6
|
|
|
7
7
|
reactions = []
|
|
@@ -23,7 +23,7 @@ def test_reaction_with_species():
|
|
|
23
23
|
class Model(Compartment):
|
|
24
24
|
s: Species = initial(default=0)
|
|
25
25
|
k: Parameter = assign(default=0)
|
|
26
|
-
r_with_species =
|
|
27
|
-
r_with_variable =
|
|
26
|
+
r_with_species = RateLaw(reactants=[s], products=[], rate_law=k * s)
|
|
27
|
+
r_with_variable = RateLaw(reactants=[s], products=[], rate_law=k * s.variable)
|
|
28
28
|
|
|
29
29
|
assert Model.r_with_species.rate_law == Model.r_with_variable.rate_law
|
|
@@ -8,7 +8,7 @@ from . import (
|
|
|
8
8
|
Constant,
|
|
9
9
|
MassAction,
|
|
10
10
|
Parameter,
|
|
11
|
-
|
|
11
|
+
RateLaw,
|
|
12
12
|
Simulator,
|
|
13
13
|
Species,
|
|
14
14
|
assign,
|
|
@@ -123,9 +123,9 @@ def test_reaction(f):
|
|
|
123
123
|
class Model(Compartment):
|
|
124
124
|
x: Species = initial(default=0)
|
|
125
125
|
c: Constant = assign(default=0, constant=True)
|
|
126
|
-
eq1 =
|
|
127
|
-
eq2 =
|
|
128
|
-
eq3 =
|
|
126
|
+
eq1 = RateLaw(reactants=[x], products=[], rate_law=c)
|
|
127
|
+
eq2 = RateLaw(reactants=[], products=[x], rate_law=c)
|
|
128
|
+
eq3 = RateLaw(reactants=[2 * x], products=[3 * x], rate_law=c)
|
|
129
129
|
|
|
130
130
|
model: Model = f(Model)
|
|
131
131
|
assert model.x.variable.equation_order == 1
|
SimBio-0.2.2/PKG-INFO
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: SimBio
|
|
3
|
-
Version: 0.2.2
|
|
4
|
-
Summary: Simulation of Biological Systems
|
|
5
|
-
Author-email: "Hernán E. Grecco" <hernan.grecco@gmail.com>, Mauro Silberberg <maurosilber@gmail.com>
|
|
6
|
-
Project-URL: Homepage, https://github.com/hgrecco/simbio
|
|
7
|
-
Project-URL: Bug Tracker, https://github.com/hgrecco/simbio/issues
|
|
8
|
-
Keywords: mass action,michaelis menten,ode,compartment,reaction,SBML,poincare
|
|
9
|
-
Classifier: Intended Audience :: Developers
|
|
10
|
-
Classifier: Intended Audience :: Science/Research
|
|
11
|
-
Classifier: Topic :: Scientific/Engineering
|
|
12
|
-
Classifier: Topic :: Software Development :: Libraries
|
|
13
|
-
Classifier: Programming Language :: Python :: 3
|
|
14
|
-
Classifier: License :: OSI Approved :: BSD License
|
|
15
|
-
Classifier: Operating System :: OS Independent
|
|
16
|
-
Requires-Python: >=3.10
|
|
17
|
-
Description-Content-Type: text/markdown
|
|
18
|
-
Requires-Dist: poincare>=0.3.1
|
|
19
|
-
Provides-Extra: io
|
|
20
|
-
Requires-Dist: python-libsbml; extra == "io"
|
|
21
|
-
Requires-Dist: biomodels; extra == "io"
|
|
22
|
-
Provides-Extra: test
|
|
23
|
-
Requires-Dist: simbio[io]; extra == "test"
|
|
24
|
-
Requires-Dist: pytest; extra == "test"
|
|
25
|
-
Provides-Extra: docs
|
|
26
|
-
Requires-Dist: simbio[test]; extra == "docs"
|
|
27
|
-
Requires-Dist: jupyter-book; extra == "docs"
|
|
28
|
-
Requires-Dist: jupytext; extra == "docs"
|
|
29
|
-
Requires-Dist: numba; extra == "docs"
|
|
30
|
-
Requires-Dist: simbio-corbat2018; extra == "docs"
|
|
31
|
-
|
|
32
|
-
# SimBio
|
|
33
|
-
|
|
34
|
-
`simbio` is a Python-based library of biological systems simulation.
|
|
35
|
-
As a comparison with other libraries we can enumerate:
|
|
36
|
-
|
|
37
|
-
- Models are composables,
|
|
38
|
-
so you can create bigger models using smaller ones
|
|
39
|
-
- Models are python classes,
|
|
40
|
-
so it is easier to understand the inners
|
|
41
|
-
and easy to compose into bigger models
|
|
42
|
-
- Posibility to do `numba` JIT compilation
|
|
43
|
-
- Small footprint library,
|
|
44
|
-
can be imported on a bigger application without fuzz
|
|
45
|
-
|
|
46
|
-
## Installation
|
|
47
|
-
|
|
48
|
-
If you are using pip,
|
|
49
|
-
it can be installed directly from PyPI:
|
|
50
|
-
|
|
51
|
-
```
|
|
52
|
-
pip install simbio
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
or the latest version from GitHub:
|
|
56
|
-
|
|
57
|
-
```
|
|
58
|
-
pip install git+https://github.com/hgrecco/simbio
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
## Examples
|
|
62
|
-
|
|
63
|
-
On the folder `src/simbio/tests/examples`,
|
|
64
|
-
we included some examples for the library usage.
|
|
65
|
-
|
|
66
|
-
## Development
|
|
67
|
-
|
|
68
|
-
We are using pytest for testing,
|
|
69
|
-
and pre-commit hooks to format and lint the codebase.
|
|
70
|
-
|
|
71
|
-
To easily set-up a development environment,
|
|
72
|
-
run the following commands:
|
|
73
|
-
|
|
74
|
-
```
|
|
75
|
-
git clone https://github.com/hgrecco/simbio
|
|
76
|
-
cd simbio
|
|
77
|
-
conda env create --file environment-dev.yml
|
|
78
|
-
pre-commit install
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
which assume you have git and conda preinstalled.
|
SimBio-0.2.2/README.md
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# SimBio
|
|
2
|
-
|
|
3
|
-
`simbio` is a Python-based library of biological systems simulation.
|
|
4
|
-
As a comparison with other libraries we can enumerate:
|
|
5
|
-
|
|
6
|
-
- Models are composables,
|
|
7
|
-
so you can create bigger models using smaller ones
|
|
8
|
-
- Models are python classes,
|
|
9
|
-
so it is easier to understand the inners
|
|
10
|
-
and easy to compose into bigger models
|
|
11
|
-
- Posibility to do `numba` JIT compilation
|
|
12
|
-
- Small footprint library,
|
|
13
|
-
can be imported on a bigger application without fuzz
|
|
14
|
-
|
|
15
|
-
## Installation
|
|
16
|
-
|
|
17
|
-
If you are using pip,
|
|
18
|
-
it can be installed directly from PyPI:
|
|
19
|
-
|
|
20
|
-
```
|
|
21
|
-
pip install simbio
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
or the latest version from GitHub:
|
|
25
|
-
|
|
26
|
-
```
|
|
27
|
-
pip install git+https://github.com/hgrecco/simbio
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## Examples
|
|
31
|
-
|
|
32
|
-
On the folder `src/simbio/tests/examples`,
|
|
33
|
-
we included some examples for the library usage.
|
|
34
|
-
|
|
35
|
-
## Development
|
|
36
|
-
|
|
37
|
-
We are using pytest for testing,
|
|
38
|
-
and pre-commit hooks to format and lint the codebase.
|
|
39
|
-
|
|
40
|
-
To easily set-up a development environment,
|
|
41
|
-
run the following commands:
|
|
42
|
-
|
|
43
|
-
```
|
|
44
|
-
git clone https://github.com/hgrecco/simbio
|
|
45
|
-
cd simbio
|
|
46
|
-
conda env create --file environment-dev.yml
|
|
47
|
-
pre-commit install
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
which assume you have git and conda preinstalled.
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: SimBio
|
|
3
|
-
Version: 0.2.2
|
|
4
|
-
Summary: Simulation of Biological Systems
|
|
5
|
-
Author-email: "Hernán E. Grecco" <hernan.grecco@gmail.com>, Mauro Silberberg <maurosilber@gmail.com>
|
|
6
|
-
Project-URL: Homepage, https://github.com/hgrecco/simbio
|
|
7
|
-
Project-URL: Bug Tracker, https://github.com/hgrecco/simbio/issues
|
|
8
|
-
Keywords: mass action,michaelis menten,ode,compartment,reaction,SBML,poincare
|
|
9
|
-
Classifier: Intended Audience :: Developers
|
|
10
|
-
Classifier: Intended Audience :: Science/Research
|
|
11
|
-
Classifier: Topic :: Scientific/Engineering
|
|
12
|
-
Classifier: Topic :: Software Development :: Libraries
|
|
13
|
-
Classifier: Programming Language :: Python :: 3
|
|
14
|
-
Classifier: License :: OSI Approved :: BSD License
|
|
15
|
-
Classifier: Operating System :: OS Independent
|
|
16
|
-
Requires-Python: >=3.10
|
|
17
|
-
Description-Content-Type: text/markdown
|
|
18
|
-
Requires-Dist: poincare>=0.3.1
|
|
19
|
-
Provides-Extra: io
|
|
20
|
-
Requires-Dist: python-libsbml; extra == "io"
|
|
21
|
-
Requires-Dist: biomodels; extra == "io"
|
|
22
|
-
Provides-Extra: test
|
|
23
|
-
Requires-Dist: simbio[io]; extra == "test"
|
|
24
|
-
Requires-Dist: pytest; extra == "test"
|
|
25
|
-
Provides-Extra: docs
|
|
26
|
-
Requires-Dist: simbio[test]; extra == "docs"
|
|
27
|
-
Requires-Dist: jupyter-book; extra == "docs"
|
|
28
|
-
Requires-Dist: jupytext; extra == "docs"
|
|
29
|
-
Requires-Dist: numba; extra == "docs"
|
|
30
|
-
Requires-Dist: simbio-corbat2018; extra == "docs"
|
|
31
|
-
|
|
32
|
-
# SimBio
|
|
33
|
-
|
|
34
|
-
`simbio` is a Python-based library of biological systems simulation.
|
|
35
|
-
As a comparison with other libraries we can enumerate:
|
|
36
|
-
|
|
37
|
-
- Models are composables,
|
|
38
|
-
so you can create bigger models using smaller ones
|
|
39
|
-
- Models are python classes,
|
|
40
|
-
so it is easier to understand the inners
|
|
41
|
-
and easy to compose into bigger models
|
|
42
|
-
- Posibility to do `numba` JIT compilation
|
|
43
|
-
- Small footprint library,
|
|
44
|
-
can be imported on a bigger application without fuzz
|
|
45
|
-
|
|
46
|
-
## Installation
|
|
47
|
-
|
|
48
|
-
If you are using pip,
|
|
49
|
-
it can be installed directly from PyPI:
|
|
50
|
-
|
|
51
|
-
```
|
|
52
|
-
pip install simbio
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
or the latest version from GitHub:
|
|
56
|
-
|
|
57
|
-
```
|
|
58
|
-
pip install git+https://github.com/hgrecco/simbio
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
## Examples
|
|
62
|
-
|
|
63
|
-
On the folder `src/simbio/tests/examples`,
|
|
64
|
-
we included some examples for the library usage.
|
|
65
|
-
|
|
66
|
-
## Development
|
|
67
|
-
|
|
68
|
-
We are using pytest for testing,
|
|
69
|
-
and pre-commit hooks to format and lint the codebase.
|
|
70
|
-
|
|
71
|
-
To easily set-up a development environment,
|
|
72
|
-
run the following commands:
|
|
73
|
-
|
|
74
|
-
```
|
|
75
|
-
git clone https://github.com/hgrecco/simbio
|
|
76
|
-
cd simbio
|
|
77
|
-
conda env create --file environment-dev.yml
|
|
78
|
-
pre-commit install
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
which assume you have git and conda preinstalled.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|