SimBio 1.0.0b3__tar.gz → 1.1.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-1.0.0b3 → simbio-1.1.0}/PKG-INFO +3 -107
- simbio-1.1.0/README.md +100 -0
- {simbio-1.0.0b3 → simbio-1.1.0}/pyproject.toml +4 -3
- {simbio-1.0.0b3 → simbio-1.1.0}/src/simbio/__init__.py +7 -1
- simbio-1.1.0/src/simbio/reactions/test_reactions.py +46 -0
- simbio-1.1.0/src/simbio/rebop/__init__.py +3 -0
- simbio-1.0.0b3/README.md +0 -204
- simbio-1.0.0b3/src/simbio/reactions/test_reactions.py +0 -22
- {simbio-1.0.0b3 → simbio-1.1.0}/src/simbio/core.py +0 -0
- {simbio-1.0.0b3 → simbio-1.1.0}/src/simbio/io/__init__.py +0 -0
- {simbio-1.0.0b3 → simbio-1.1.0}/src/simbio/io/biomodels.py +0 -0
- {simbio-1.0.0b3 → simbio-1.1.0}/src/simbio/io/graph/networkx.py +0 -0
- {simbio-1.0.0b3 → simbio-1.1.0}/src/simbio/io/mathML/__init__.py +0 -0
- {simbio-1.0.0b3 → simbio-1.1.0}/src/simbio/io/mathML/exporter.py +0 -0
- {simbio-1.0.0b3 → simbio-1.1.0}/src/simbio/io/mathML/importer.py +0 -0
- {simbio-1.0.0b3 → simbio-1.1.0}/src/simbio/io/mathML/symbol.py +0 -0
- {simbio-1.0.0b3 → simbio-1.1.0}/src/simbio/io/mathML/test_mathML.py +0 -0
- {simbio-1.0.0b3 → simbio-1.1.0}/src/simbio/io/mathML/to_symbolite.py +0 -0
- {simbio-1.0.0b3 → simbio-1.1.0}/src/simbio/io/sbml/__init__.py +0 -0
- {simbio-1.0.0b3 → simbio-1.1.0}/src/simbio/io/sbml/from_libsbml.py +0 -0
- {simbio-1.0.0b3 → simbio-1.1.0}/src/simbio/io/sbml/importer.py +0 -0
- {simbio-1.0.0b3 → simbio-1.1.0}/src/simbio/io/sbml/test_importer.py +0 -0
- {simbio-1.0.0b3 → simbio-1.1.0}/src/simbio/io/sbml/tests/atol_factor.csv +0 -0
- {simbio-1.0.0b3 → simbio-1.1.0}/src/simbio/io/sbml/tests/test_sbml_test_suite.py +0 -0
- {simbio-1.0.0b3 → simbio-1.1.0}/src/simbio/io/sbml/types.py +0 -0
- {simbio-1.0.0b3 → simbio-1.1.0}/src/simbio/reactions/__init__.py +0 -0
- {simbio-1.0.0b3 → simbio-1.1.0}/src/simbio/reactions/compound.py +0 -0
- {simbio-1.0.0b3 → simbio-1.1.0}/src/simbio/reactions/enzymatic.py +0 -0
- {simbio-1.0.0b3 → simbio-1.1.0}/src/simbio/reactions/single.py +0 -0
- {simbio-1.0.0b3 → simbio-1.1.0}/src/simbio/test_core.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: simbio
|
|
3
|
-
Version: 1.0
|
|
3
|
+
Version: 1.1.0
|
|
4
4
|
Summary: A Python-based package for simulation of Chemical Reaction Networks (CRNs).
|
|
5
5
|
Keywords: mass action,michaelis menten,ode,compartment,reaction,SBML,poincare
|
|
6
6
|
Author: Hernán E. Grecco, Mauro Silberberg
|
|
@@ -12,7 +12,7 @@ Classifier: Topic :: Scientific/Engineering
|
|
|
12
12
|
Classifier: Topic :: Software Development :: Libraries
|
|
13
13
|
Classifier: Programming Language :: Python :: 3
|
|
14
14
|
Classifier: Operating System :: OS Independent
|
|
15
|
-
Requires-Dist: poincare>=1.0
|
|
15
|
+
Requires-Dist: poincare>=1.1.0
|
|
16
16
|
Requires-Dist: biomodels ; extra == 'io'
|
|
17
17
|
Requires-Dist: python-libsbml ; extra == 'io'
|
|
18
18
|
Requires-Python: >=3.12
|
|
@@ -40,111 +40,7 @@ to add functionality for CRNs.
|
|
|
40
40
|
|
|
41
41
|
## Usage
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
and a reaction converting $2A \\rightarrow B$ with rate 1:
|
|
45
|
-
|
|
46
|
-
```python
|
|
47
|
-
>>> from simbio import Compartment, Species, RateLaw, initial
|
|
48
|
-
>>> class Model(Compartment):
|
|
49
|
-
... A: Species = initial(default=1)
|
|
50
|
-
... B: Species = initial(default=0)
|
|
51
|
-
... r = RateLaw(
|
|
52
|
-
... reactants=[2 * A],
|
|
53
|
-
... products=[B],
|
|
54
|
-
... rate_law=1,
|
|
55
|
-
... )
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
This corresponds to the following system of equations
|
|
59
|
-
|
|
60
|
-
$$
|
|
61
|
-
\\begin{cases}
|
|
62
|
-
\\frac{dA}{dt} = -2 \\
|
|
63
|
-
\\frac{dB}{dt} = +1
|
|
64
|
-
\\end{cases}
|
|
65
|
-
$$
|
|
66
|
-
|
|
67
|
-
with initial conditions
|
|
68
|
-
|
|
69
|
-
$$
|
|
70
|
-
\\begin{cases}
|
|
71
|
-
A(0) = 1 \\
|
|
72
|
-
B(0) = 0
|
|
73
|
-
\\end{cases}
|
|
74
|
-
$$
|
|
75
|
-
|
|
76
|
-
In CRNs,
|
|
77
|
-
we usually deal with [mass-action](https://en.wikipedia.org/wiki/Law_of_mass_action) reactions.
|
|
78
|
-
Using `MassAction` instead of `Reaction` automatically adds the reactants to the rate law:
|
|
79
|
-
|
|
80
|
-
```python
|
|
81
|
-
>>> from simbio import MassAction
|
|
82
|
-
>>> class MassActionModel(Compartment):
|
|
83
|
-
... A: Species = initial(default=1)
|
|
84
|
-
... B: Species = initial(default=0)
|
|
85
|
-
... r = MassAction(
|
|
86
|
-
... reactants=[2 * A],
|
|
87
|
-
... products=[B],
|
|
88
|
-
... rate=1,
|
|
89
|
-
... )
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
generating the following equations:
|
|
93
|
-
|
|
94
|
-
$$
|
|
95
|
-
\\begin{cases}
|
|
96
|
-
\\frac{dA}{dt} = -2 A^2 \\
|
|
97
|
-
\\frac{dB}{dt} = +1 A^2
|
|
98
|
-
\\end{cases}
|
|
99
|
-
$$
|
|
100
|
-
|
|
101
|
-
To simulate the system,
|
|
102
|
-
use the `Simulator.solve` which outputs a `pandas.DataFrame`:
|
|
103
|
-
|
|
104
|
-
```python
|
|
105
|
-
>>> from simbio import Simulator
|
|
106
|
-
>>> Simulator(MassActionModel).solve(save_at=range(5))
|
|
107
|
-
A B
|
|
108
|
-
time
|
|
109
|
-
0 1.000000 0.000000
|
|
110
|
-
1 0.333266 0.333367
|
|
111
|
-
2 0.199937 0.400032
|
|
112
|
-
3 0.142798 0.428601
|
|
113
|
-
4 0.111061 0.444470
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
For more details into SimBio's capabilities,
|
|
117
|
-
we recommend reading [poincaré's README](https://github.com/dyscolab/poincare).
|
|
118
|
-
|
|
119
|
-
## SBML
|
|
120
|
-
|
|
121
|
-
SimBio can import models from Systems Biology Markup Language (SBML) files:
|
|
122
|
-
|
|
123
|
-
```python
|
|
124
|
-
>>> from simbio.io import sbml
|
|
125
|
-
>>> sbml.load("repressilator.sbml")
|
|
126
|
-
Elowitz2000 - Repressilator
|
|
127
|
-
-----------------------------------------------------------------------------------
|
|
128
|
-
type total names
|
|
129
|
-
---------- ------- --------------------------------------------------------------
|
|
130
|
-
variables 6 PX, PY, PZ, X, Y, Z
|
|
131
|
-
parameters 17 cell, beta, alpha0, alpha, eff, n, KM, tau_mRNA, tau_prot, ...
|
|
132
|
-
equations 12 Reaction1, Reaction2, Reaction3, Reaction4, Reaction5, ...
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
or download them from the [BioModels](https://www.ebi.ac.uk/biomodels/) repository:
|
|
136
|
-
|
|
137
|
-
```python
|
|
138
|
-
>>> from simbio.io import biomodels
|
|
139
|
-
>>> biomodels.load("BIOMD12")
|
|
140
|
-
Elowitz2000 - Repressilator
|
|
141
|
-
-----------------------------------------------------------------------------------
|
|
142
|
-
type total names
|
|
143
|
-
---------- ------- --------------------------------------------------------------
|
|
144
|
-
variables 6 PX, PY, PZ, X, Y, Z
|
|
145
|
-
parameters 17 cell, beta, alpha0, alpha, eff, n, KM, tau_mRNA, tau_prot, ...
|
|
146
|
-
equations 12 Reaction1, Reaction2, Reaction3, Reaction4, Reaction5, ...
|
|
147
|
-
```
|
|
43
|
+
See [simbio's documentation](https://dyscolab.github.io/simbio/) on the dyscolab page, or go directly to the [intro tutorial](https://marimo.app/github.com/dyscolab/dyscolab-tutorials/blob/main/simbio/getting_started_with_simbio.py).
|
|
148
44
|
|
|
149
45
|
## Install
|
|
150
46
|
|
simbio-1.1.0/README.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# simbio
|
|
2
|
+
|
|
3
|
+
[![Copier Badge][copier-badge]][copier-url]
|
|
4
|
+
[![Pixi Badge][pixi-badge]][pixi-url]
|
|
5
|
+
![License][license-badge]
|
|
6
|
+
[![CI Badge][ci-badge]][ci-url]
|
|
7
|
+
[![conda-forge Badge][conda-forge-badge]][conda-forge-url]
|
|
8
|
+
[![PyPI Badge][pypi-badge]][pypi-url]
|
|
9
|
+
[![Python version Badge][pypi-version-badge]][pypi-version-url]
|
|
10
|
+
|
|
11
|
+
A Python-based package for simulation of Chemical Reaction Networks (CRNs).
|
|
12
|
+
It extends [`poincare`](https://github.com/dyscolab/poincare),
|
|
13
|
+
a package for modelling dynamical systems,
|
|
14
|
+
to add functionality for CRNs.
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
See [simbio's documentation](https://dyscolab.github.io/simbio/) on the dyscolab page, or go directly to the [intro tutorial](https://marimo.app/github.com/dyscolab/dyscolab-tutorials/blob/main/simbio/getting_started_with_simbio.py).
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
Using [pixi][pixi-url],
|
|
23
|
+
install from PyPI with:
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
pixi add --pypi simbio
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
or install the latest development version from GitHub with:
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
pixi add --pypi simbio@https://github.com/dyscolab/simbio.git
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Otherwise,
|
|
36
|
+
use `pip` or your `pip`-compatible package manager:
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
pip install simbio # from PyPI
|
|
40
|
+
pip install git+https://github.com/dyscolab/simbio.git # from GitHub
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Development
|
|
44
|
+
|
|
45
|
+
This project is managed by [pixi][pixi-url].
|
|
46
|
+
You can install it for development using:
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
git clone https://github.com/dyscolab/simbio
|
|
50
|
+
cd simbio
|
|
51
|
+
pixi run pre-commit-install
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Pre-commit hooks are used to lint and format the project.
|
|
55
|
+
|
|
56
|
+
### Testing
|
|
57
|
+
|
|
58
|
+
Run tests using:
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
pixi run test
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Publishing to PyPI
|
|
65
|
+
|
|
66
|
+
When a tagged commit is pushed to GitHub,
|
|
67
|
+
the GitHub Action defined in `.github/workflows/ci.yml`
|
|
68
|
+
builds and publishes the package to PyPI.
|
|
69
|
+
|
|
70
|
+
Tag a commit and push the tags with:
|
|
71
|
+
|
|
72
|
+
```sh
|
|
73
|
+
git tag <my-tag>
|
|
74
|
+
git push --tags
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Trusted publishing must be enabled once in [PyPI Publishing](https://pypi.org/manage/account/publishing/).
|
|
78
|
+
Fill the following values in the form:
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
PyPI Project Name: simbio
|
|
82
|
+
Owner: maurosilber
|
|
83
|
+
Repository name: simbio
|
|
84
|
+
Workflow name: ci.yml
|
|
85
|
+
Environment name: pypi
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
[ci-badge]: https://img.shields.io/github/actions/workflow/status/dyscolab/simbio/ci.yml
|
|
89
|
+
[ci-url]: https://github.com/dyscolab/simbio/actions/workflows/ci.yml
|
|
90
|
+
[conda-forge-badge]: https://img.shields.io/conda/vn/conda-forge/simbio?logoColor=white&logo=conda-forge
|
|
91
|
+
[conda-forge-url]: https://prefix.dev/channels/conda-forge/packages/simbio
|
|
92
|
+
[copier-badge]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-black.json
|
|
93
|
+
[copier-url]: https://github.com/copier-org/copier
|
|
94
|
+
[license-badge]: https://img.shields.io/badge/license-MIT-blue
|
|
95
|
+
[pixi-badge]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/prefix-dev/pixi/main/assets/badge/v0.json
|
|
96
|
+
[pixi-url]: https://pixi.sh
|
|
97
|
+
[pypi-badge]: https://img.shields.io/pypi/v/simbio.svg?logo=pypi&logoColor=white
|
|
98
|
+
[pypi-url]: https://pypi.org/project/simbio
|
|
99
|
+
[pypi-version-badge]: https://img.shields.io/pypi/pyversions/simbio?logoColor=white&logo=python
|
|
100
|
+
[pypi-version-url]: https://pypi.org/project/simbio
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "simbio"
|
|
3
3
|
description = "A Python-based package for simulation of Chemical Reaction Networks (CRNs)."
|
|
4
|
-
version = "1.0
|
|
4
|
+
version = "1.1.0"
|
|
5
5
|
authors = [
|
|
6
6
|
{ name = "Hernán E. Grecco", email = "hernan.grecco@gmail.com" },
|
|
7
7
|
{ name = "Mauro Silberberg", email = "maurosilber@gmail.com" },
|
|
@@ -26,7 +26,7 @@ keywords = [
|
|
|
26
26
|
"poincare",
|
|
27
27
|
]
|
|
28
28
|
requires-python = ">=3.12"
|
|
29
|
-
dependencies = ["poincare >= 1.0
|
|
29
|
+
dependencies = ["poincare >= 1.1.0"]
|
|
30
30
|
|
|
31
31
|
[project.urls]
|
|
32
32
|
homepage = "https://github.com/dyscolab/simbio"
|
|
@@ -69,12 +69,13 @@ preview = ["pixi-build"]
|
|
|
69
69
|
|
|
70
70
|
[tool.pixi.package.build]
|
|
71
71
|
backend = { name = "pixi-build-python", version = "0.4.*" }
|
|
72
|
+
# config = { ignore-pypi-mapping = false } # Enable automatic PyPI-to-conda mapping
|
|
72
73
|
|
|
73
74
|
[tool.pixi.package.host-dependencies]
|
|
74
75
|
uv-build = "*"
|
|
75
76
|
|
|
76
77
|
[tool.pixi.package.run-dependencies]
|
|
77
|
-
# poincare = ">=1.0.
|
|
78
|
+
# poincare = ">=1.0.0"
|
|
78
79
|
|
|
79
80
|
[tool.pixi.environments]
|
|
80
81
|
default = ["test", "py312"]
|
|
@@ -6,6 +6,7 @@ from poincare import (
|
|
|
6
6
|
Variable,
|
|
7
7
|
assign,
|
|
8
8
|
initial,
|
|
9
|
+
model_report,
|
|
9
10
|
)
|
|
10
11
|
from poincare.reactions import (
|
|
11
12
|
AbsoluteRateLaw,
|
|
@@ -19,10 +20,12 @@ from .core import (
|
|
|
19
20
|
Compartment,
|
|
20
21
|
Species,
|
|
21
22
|
System,
|
|
23
|
+
Volume,
|
|
22
24
|
amount,
|
|
23
25
|
concentration,
|
|
24
26
|
reaction_amount,
|
|
25
27
|
reaction_concentration,
|
|
28
|
+
volume,
|
|
26
29
|
)
|
|
27
30
|
|
|
28
31
|
__all__ = [
|
|
@@ -31,11 +34,13 @@ __all__ = [
|
|
|
31
34
|
"assign",
|
|
32
35
|
]
|
|
33
36
|
__all__ += [
|
|
37
|
+
"Simulator",
|
|
34
38
|
"Compartment",
|
|
35
39
|
"System",
|
|
36
40
|
"Variable",
|
|
37
41
|
"Reactant",
|
|
38
42
|
"Species",
|
|
43
|
+
"Volume",
|
|
39
44
|
"Parameter",
|
|
40
45
|
"MassAction",
|
|
41
46
|
"RateLaw",
|
|
@@ -46,5 +51,6 @@ __all__ += [
|
|
|
46
51
|
"reaction_initial",
|
|
47
52
|
"reaction_concentration",
|
|
48
53
|
"reaction_amount",
|
|
49
|
-
"
|
|
54
|
+
"volume",
|
|
55
|
+
"model_report",
|
|
50
56
|
]
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from pytest import mark
|
|
3
|
+
|
|
4
|
+
from .. import Simulator, System, Variable, initial, MassAction
|
|
5
|
+
from ..reactions import compound, enzymatic, single
|
|
6
|
+
from ..reactions.single import Synthesis
|
|
7
|
+
|
|
8
|
+
reactions = []
|
|
9
|
+
for mod in (single, compound, enzymatic):
|
|
10
|
+
for name in dir(mod):
|
|
11
|
+
value = getattr(mod, name)
|
|
12
|
+
if isinstance(value, type(System)) and value != System:
|
|
13
|
+
reactions.append(value)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@mark.parametrize("reaction", reactions)
|
|
17
|
+
def test_reactions(reaction):
|
|
18
|
+
model = reaction(**dict.fromkeys(reaction._required, 1))
|
|
19
|
+
sim = Simulator(model)
|
|
20
|
+
sim.solve(save_at=np.linspace(0, 1, 10))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_external_stoichiometry_in_reaction():
|
|
24
|
+
class Model1(System):
|
|
25
|
+
A: Variable = initial(default=10)
|
|
26
|
+
B: Variable = initial(default=5)
|
|
27
|
+
AB: Variable = initial(default=5)
|
|
28
|
+
|
|
29
|
+
r = Synthesis(A=10 * A, B=B, AB=AB, rate=2)
|
|
30
|
+
|
|
31
|
+
class Model2(System):
|
|
32
|
+
A: Variable = initial(default=10)
|
|
33
|
+
B: Variable = initial(default=5)
|
|
34
|
+
AB: Variable = initial(default=5)
|
|
35
|
+
|
|
36
|
+
r = MassAction(reactants=[10 * A, B], products=[AB], rate=2)
|
|
37
|
+
|
|
38
|
+
assert Model1.r.reaction.reactants[0].stoichiometry == 10
|
|
39
|
+
|
|
40
|
+
sim1 = Simulator(Model1)
|
|
41
|
+
result1 = np.asarray(sim1.solve(save_at=np.linspace(0, 10, 10)).to_array())
|
|
42
|
+
|
|
43
|
+
sim2 = Simulator(Model2)
|
|
44
|
+
result2 = np.asarray(sim2.solve(save_at=np.linspace(0, 10, 10)).to_array())
|
|
45
|
+
|
|
46
|
+
assert np.all(result1 == result2)
|
simbio-1.0.0b3/README.md
DELETED
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
# simbio
|
|
2
|
-
|
|
3
|
-
[![Copier Badge][copier-badge]][copier-url]
|
|
4
|
-
[![Pixi Badge][pixi-badge]][pixi-url]
|
|
5
|
-
![License][license-badge]
|
|
6
|
-
[![CI Badge][ci-badge]][ci-url]
|
|
7
|
-
[![conda-forge Badge][conda-forge-badge]][conda-forge-url]
|
|
8
|
-
[![PyPI Badge][pypi-badge]][pypi-url]
|
|
9
|
-
[![Python version Badge][pypi-version-badge]][pypi-version-url]
|
|
10
|
-
|
|
11
|
-
A Python-based package for simulation of Chemical Reaction Networks (CRNs).
|
|
12
|
-
It extends [`poincare`](https://github.com/dyscolab/poincare),
|
|
13
|
-
a package for modelling dynamical systems,
|
|
14
|
-
to add functionality for CRNs.
|
|
15
|
-
|
|
16
|
-
## Usage
|
|
17
|
-
|
|
18
|
-
To create a system with two species $A$ and $B$
|
|
19
|
-
and a reaction converting $2A \\rightarrow B$ with rate 1:
|
|
20
|
-
|
|
21
|
-
```python
|
|
22
|
-
>>> from simbio import Compartment, Species, RateLaw, initial
|
|
23
|
-
>>> class Model(Compartment):
|
|
24
|
-
... A: Species = initial(default=1)
|
|
25
|
-
... B: Species = initial(default=0)
|
|
26
|
-
... r = RateLaw(
|
|
27
|
-
... reactants=[2 * A],
|
|
28
|
-
... products=[B],
|
|
29
|
-
... rate_law=1,
|
|
30
|
-
... )
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
This corresponds to the following system of equations
|
|
34
|
-
|
|
35
|
-
$$
|
|
36
|
-
\\begin{cases}
|
|
37
|
-
\\frac{dA}{dt} = -2 \\
|
|
38
|
-
\\frac{dB}{dt} = +1
|
|
39
|
-
\\end{cases}
|
|
40
|
-
$$
|
|
41
|
-
|
|
42
|
-
with initial conditions
|
|
43
|
-
|
|
44
|
-
$$
|
|
45
|
-
\\begin{cases}
|
|
46
|
-
A(0) = 1 \\
|
|
47
|
-
B(0) = 0
|
|
48
|
-
\\end{cases}
|
|
49
|
-
$$
|
|
50
|
-
|
|
51
|
-
In CRNs,
|
|
52
|
-
we usually deal with [mass-action](https://en.wikipedia.org/wiki/Law_of_mass_action) reactions.
|
|
53
|
-
Using `MassAction` instead of `Reaction` automatically adds the reactants to the rate law:
|
|
54
|
-
|
|
55
|
-
```python
|
|
56
|
-
>>> from simbio import MassAction
|
|
57
|
-
>>> class MassActionModel(Compartment):
|
|
58
|
-
... A: Species = initial(default=1)
|
|
59
|
-
... B: Species = initial(default=0)
|
|
60
|
-
... r = MassAction(
|
|
61
|
-
... reactants=[2 * A],
|
|
62
|
-
... products=[B],
|
|
63
|
-
... rate=1,
|
|
64
|
-
... )
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
generating the following equations:
|
|
68
|
-
|
|
69
|
-
$$
|
|
70
|
-
\\begin{cases}
|
|
71
|
-
\\frac{dA}{dt} = -2 A^2 \\
|
|
72
|
-
\\frac{dB}{dt} = +1 A^2
|
|
73
|
-
\\end{cases}
|
|
74
|
-
$$
|
|
75
|
-
|
|
76
|
-
To simulate the system,
|
|
77
|
-
use the `Simulator.solve` which outputs a `pandas.DataFrame`:
|
|
78
|
-
|
|
79
|
-
```python
|
|
80
|
-
>>> from simbio import Simulator
|
|
81
|
-
>>> Simulator(MassActionModel).solve(save_at=range(5))
|
|
82
|
-
A B
|
|
83
|
-
time
|
|
84
|
-
0 1.000000 0.000000
|
|
85
|
-
1 0.333266 0.333367
|
|
86
|
-
2 0.199937 0.400032
|
|
87
|
-
3 0.142798 0.428601
|
|
88
|
-
4 0.111061 0.444470
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
For more details into SimBio's capabilities,
|
|
92
|
-
we recommend reading [poincaré's README](https://github.com/dyscolab/poincare).
|
|
93
|
-
|
|
94
|
-
## SBML
|
|
95
|
-
|
|
96
|
-
SimBio can import models from Systems Biology Markup Language (SBML) files:
|
|
97
|
-
|
|
98
|
-
```python
|
|
99
|
-
>>> from simbio.io import sbml
|
|
100
|
-
>>> sbml.load("repressilator.sbml")
|
|
101
|
-
Elowitz2000 - Repressilator
|
|
102
|
-
-----------------------------------------------------------------------------------
|
|
103
|
-
type total names
|
|
104
|
-
---------- ------- --------------------------------------------------------------
|
|
105
|
-
variables 6 PX, PY, PZ, X, Y, Z
|
|
106
|
-
parameters 17 cell, beta, alpha0, alpha, eff, n, KM, tau_mRNA, tau_prot, ...
|
|
107
|
-
equations 12 Reaction1, Reaction2, Reaction3, Reaction4, Reaction5, ...
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
or download them from the [BioModels](https://www.ebi.ac.uk/biomodels/) repository:
|
|
111
|
-
|
|
112
|
-
```python
|
|
113
|
-
>>> from simbio.io import biomodels
|
|
114
|
-
>>> biomodels.load("BIOMD12")
|
|
115
|
-
Elowitz2000 - Repressilator
|
|
116
|
-
-----------------------------------------------------------------------------------
|
|
117
|
-
type total names
|
|
118
|
-
---------- ------- --------------------------------------------------------------
|
|
119
|
-
variables 6 PX, PY, PZ, X, Y, Z
|
|
120
|
-
parameters 17 cell, beta, alpha0, alpha, eff, n, KM, tau_mRNA, tau_prot, ...
|
|
121
|
-
equations 12 Reaction1, Reaction2, Reaction3, Reaction4, Reaction5, ...
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
## Install
|
|
125
|
-
|
|
126
|
-
Using [pixi][pixi-url],
|
|
127
|
-
install from PyPI with:
|
|
128
|
-
|
|
129
|
-
```sh
|
|
130
|
-
pixi add --pypi simbio
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
or install the latest development version from GitHub with:
|
|
134
|
-
|
|
135
|
-
```sh
|
|
136
|
-
pixi add --pypi simbio@https://github.com/dyscolab/simbio.git
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
Otherwise,
|
|
140
|
-
use `pip` or your `pip`-compatible package manager:
|
|
141
|
-
|
|
142
|
-
```sh
|
|
143
|
-
pip install simbio # from PyPI
|
|
144
|
-
pip install git+https://github.com/dyscolab/simbio.git # from GitHub
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
## Development
|
|
148
|
-
|
|
149
|
-
This project is managed by [pixi][pixi-url].
|
|
150
|
-
You can install it for development using:
|
|
151
|
-
|
|
152
|
-
```sh
|
|
153
|
-
git clone https://github.com/dyscolab/simbio
|
|
154
|
-
cd simbio
|
|
155
|
-
pixi run pre-commit-install
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
Pre-commit hooks are used to lint and format the project.
|
|
159
|
-
|
|
160
|
-
### Testing
|
|
161
|
-
|
|
162
|
-
Run tests using:
|
|
163
|
-
|
|
164
|
-
```sh
|
|
165
|
-
pixi run test
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
### Publishing to PyPI
|
|
169
|
-
|
|
170
|
-
When a tagged commit is pushed to GitHub,
|
|
171
|
-
the GitHub Action defined in `.github/workflows/ci.yml`
|
|
172
|
-
builds and publishes the package to PyPI.
|
|
173
|
-
|
|
174
|
-
Tag a commit and push the tags with:
|
|
175
|
-
|
|
176
|
-
```sh
|
|
177
|
-
git tag <my-tag>
|
|
178
|
-
git push --tags
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
Trusted publishing must be enabled once in [PyPI Publishing](https://pypi.org/manage/account/publishing/).
|
|
182
|
-
Fill the following values in the form:
|
|
183
|
-
|
|
184
|
-
```
|
|
185
|
-
PyPI Project Name: simbio
|
|
186
|
-
Owner: maurosilber
|
|
187
|
-
Repository name: simbio
|
|
188
|
-
Workflow name: ci.yml
|
|
189
|
-
Environment name: pypi
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
[ci-badge]: https://img.shields.io/github/actions/workflow/status/dyscolab/simbio/ci.yml
|
|
193
|
-
[ci-url]: https://github.com/dyscolab/simbio/actions/workflows/ci.yml
|
|
194
|
-
[conda-forge-badge]: https://img.shields.io/conda/vn/conda-forge/simbio?logoColor=white&logo=conda-forge
|
|
195
|
-
[conda-forge-url]: https://prefix.dev/channels/conda-forge/packages/simbio
|
|
196
|
-
[copier-badge]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-black.json
|
|
197
|
-
[copier-url]: https://github.com/copier-org/copier
|
|
198
|
-
[license-badge]: https://img.shields.io/badge/license-MIT-blue
|
|
199
|
-
[pixi-badge]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/prefix-dev/pixi/main/assets/badge/v0.json
|
|
200
|
-
[pixi-url]: https://pixi.sh
|
|
201
|
-
[pypi-badge]: https://img.shields.io/pypi/v/simbio.svg?logo=pypi&logoColor=white
|
|
202
|
-
[pypi-url]: https://pypi.org/project/simbio
|
|
203
|
-
[pypi-version-badge]: https://img.shields.io/pypi/pyversions/simbio?logoColor=white&logo=python
|
|
204
|
-
[pypi-version-url]: https://pypi.org/project/simbio
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import numpy as np
|
|
2
|
-
from pytest import mark
|
|
3
|
-
|
|
4
|
-
from .. import (
|
|
5
|
-
Simulator,
|
|
6
|
-
System,
|
|
7
|
-
)
|
|
8
|
-
from ..reactions import compound, enzymatic, single
|
|
9
|
-
|
|
10
|
-
reactions = []
|
|
11
|
-
for mod in (single, compound, enzymatic):
|
|
12
|
-
for name in dir(mod):
|
|
13
|
-
value = getattr(mod, name)
|
|
14
|
-
if isinstance(value, type(System)) and value != System:
|
|
15
|
-
reactions.append(value)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
@mark.parametrize("reaction", reactions)
|
|
19
|
-
def test_reactions(reaction):
|
|
20
|
-
model = reaction(**dict.fromkeys(reaction._required, 1))
|
|
21
|
-
sim = Simulator(model)
|
|
22
|
-
sim.solve(save_at=np.linspace(0, 1, 10))
|
|
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
|