cayenne : Python package for stochastic simulations
Introduction
cayenne is a Python package for stochastic simulations. It offers a simple API to define models, perform stochastic simulations with them and visualize the results in a convenient manner.
Currently under active development in the develop branch.
Install
Install with pip:
$ pip install cayenne
Documentation
- General: https://cayenne.readthedocs.io.
- Benchmark repository, comparing
cayennewith other stochastic simulation packages: https://github.com/Heuro-labs/cayenne-benchmarks
Usage
A short summary follows, but a more detailed tutorial can be found here. You can define a model as a Python string (or a text file, see docs). The format of this string is loosely based on the excellent antimony library, which is used behind the scenes by cayenne.
from cayenne.simulation import Simulation
model_str = """
const compartment comp1;
comp1 = 1.0; # volume of compartment
r1: A => B; k1;
r2: B => C; k2;
k1 = 0.11;
k2 = 0.1;
chem_flag = false;
A = 100;
B = 0;
C = 0;
"""
sim = Simulation.load_model(model_str, "ModelString")
# Run the simulation
sim.simulate(max_t=40, max_iter=1000, n_rep=10)
sim.plot()
Change simulation algorithm
You can change the algorithm used to perform the simulation by changing the algorithm parameter (one of "direct", "tau_leaping" or "tau_adaptive")
sim.simulate(max_t=150, max_iter=1000, n_rep=10, algorithm="tau_leaping")
Our benchmarks are summarized below, and show direct to be a good starting point. tau_leaping offers greater speed but needs specification and tuning of the tau hyperparameter. The tau_adaptive is less accurate and a work in progress.
Run simulations in parallel
You can run the simulations on multiple cores by specifying the n_procs parameter
sim.simulate(max_t=150, max_iter=1000, n_rep=10, n_procs=4)
Accessing simulation results
You can access all the results or the results for a specific list of species
# Get all the results
results = sim.results
# Get results only for one or more species
results.get_species(["A", "C"])
You can also access the final states of all the simulation runs by
# Get results at the simulation endpoints
final_times, final_states = results.final
Additionally, you can access the state a particular time point of interest $t$. cayenne will interpolate the value from nearby time points to give an accurate estimate.
# Get results at timepoint "t"
t = 10.0
states = results.get_state(t) # returns a list of numpy arrays
Benchmarks
| direct | tau_leaping | tau_adaptive | |
|---|---|---|---|
| cayenne | ✔️ Most accurate yet | ✔️ Very fast but may need manual tuning | Less accurate than GillespieSSA's version |
| Tellurium | ❗ Inaccurate for 2nd order | N/A | N/A |
| GillespieSSA | Very slow | ❗ Inaccurate for initial zero counts | ❗ Inaccurate for initial zero counts |
| BioSimulator.jl | ❗ Inaccurate interpolation | ❗ Inaccurate for initial zero counts | ❗ Inaccurate for initial zero counts |
License
Copyright (c) 2018-2020, Dileep Kishore, Srikiran Chandrasekaran. Released under: Apache Software License 2.0
Credits
- Cython
- antimony
- pytest
- Cookiecutter
- audreyr/cookiecutter-pypackage
- black
- Logo made with logomakr
Metadata
Release files for cayenne 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cayenne-1.0.3.tar.gz | 1.1 MB | Without provenance | Details for cayenne-1.0.3.tar.gz |
Release files / cayenne-1.0.3.tar.gz
| Download URL | cayenne-1.0.3.tar.gz |
|---|---|
| Size | 1.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
897f2c6387f8ff09ae26a11128b8939e6350ff7f8794fbdf7f58015d1a176280
|
|
BLAKE2b-256 checksum How to use checksums |
22538fdf90083da0f74c38287e380b5e2f17ed923259baf4d572de180848b5ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.6.10
|
Security for cayenne 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.