Skip to main content

Simulation of Biological Systems

Project description

Package CodeStyle License PyVersion CI

SimBio

simbio is a Python-based package for simulation of Chemical Reaction Networks (CRNs). It extends poincare, a package for modelling dynamical systems, to add functionality for CRNs.

Usage

To create a system with two species $A$ and $B$ and a reaction converting $2A \rightarrow B$ with rate 1:

>>> from simbio import Compartment, Species, RateLaw, initial
>>> class Model(Compartment):
...    A: Species = initial(default=1)
...    B: Species = initial(default=0)
...    r = RateLaw(
...        reactants=[2 * A],
...        products=[B],
...        rate_law=1,
...    )

This corresponds to the following system of equations

$$ \begin{cases} \frac{dA}{dt} = -2 \ \frac{dB}{dt} = +1 \end{cases} $$

with initial conditions

$$ \begin{cases} A(0) = 1 \ B(0) = 0 \end{cases} $$

In CRNs, we usually deal with mass-action reactions. Using MassAction instead of Reaction automatically adds the reactants to the rate law:

>>> from simbio import MassAction
>>> class MassActionModel(Compartment):
...    A: Species = initial(default=1)
...    B: Species = initial(default=0)
...    r = MassAction(
...        reactants=[2 * A],
...        products=[B],
...        rate=1,
...    )

generating the following equations:

$$ \begin{cases} \frac{dA}{dt} = -2 A^2 \ \frac{dB}{dt} = +1 A^2 \end{cases} $$

To simulate the system, use the Simulator.solve which outputs a pandas.DataFrame:

>>> from simbio import Simulator
>>> Simulator(MassActionModel).solve(save_at=range(5))
             A         B
time
0     1.000000  0.000000
1     0.333266  0.333367
2     0.199937  0.400032
3     0.142798  0.428601
4     0.111061  0.444470

For more details into SimBio's capabilities, we recommend reading poincaré's README.

SBML

SimBio can import models from Systems Biology Markup Language (SBML) files:

>>> from simbio.io import sbml
>>> sbml.load("repressilator.sbml")
Elowitz2000 - Repressilator
-----------------------------------------------------------------------------------
type          total  names
----------  -------  --------------------------------------------------------------
variables         6  PX, PY, PZ, X, Y, Z
parameters       17  cell, beta, alpha0, alpha, eff, n, KM, tau_mRNA, tau_prot, ...
equations        12  Reaction1, Reaction2, Reaction3, Reaction4, Reaction5, ...

or download them from the BioModels repository:

>>> from simbio.io import biomodels
>>> biomodels.load_model("BIOMD12")
Elowitz2000 - Repressilator
-----------------------------------------------------------------------------------
type          total  names
----------  -------  --------------------------------------------------------------
variables         6  PX, PY, PZ, X, Y, Z
parameters       17  cell, beta, alpha0, alpha, eff, n, KM, tau_mRNA, tau_prot, ...
equations        12  Reaction1, Reaction2, Reaction3, Reaction4, Reaction5, ...

Installation

It can be installed from PyPI with pip:

pip install simbio

Or, to additionally install the SBML importer:

pip install simbio[io]

While poincaré is installed automatically as a dependency, if you are using conda/mamba, you might prefer to install it from conda-forge:

conda install --channel conda-forge poincare

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

SimBio-0.3.2.tar.gz (40.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

SimBio-0.3.2-py3-none-any.whl (29.1 kB view details)

Uploaded Python 3

File details

Details for the file SimBio-0.3.2.tar.gz.

File metadata

  • Download URL: SimBio-0.3.2.tar.gz
  • Upload date:
  • Size: 40.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for SimBio-0.3.2.tar.gz
Algorithm Hash digest
SHA256 e4c931510c95425d0b0696a37c0c105eb0a7b118a31340e7007db7a6ed6ca836
MD5 7f7a086171dcefb96554a661c36b4631
BLAKE2b-256 e2eb78af65f59760b1426659b16c0e843d96d2802946d459d4414fb5403e31e1

See more details on using hashes here.

File details

Details for the file SimBio-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: SimBio-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 29.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for SimBio-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e7aac5b20f79a8562a886193c972ce54ebeb00e7449fd10ebce77bb7d51a3c3f
MD5 aceb57b11f25c7e53b1c5c5498a38e06
BLAKE2b-256 13c1daeb539ee9410244143bf830d56e5dc2f79c48e39ee80400d015a2ed0bae

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page