rebop

Fast stochastic simulator for chemical reaction networks

https://github.com/armavica/rebop

Science Score: 57.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 2 DOI reference(s) in README
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (9.9%) to scientific vocabulary

Keywords

gillespie monte-carlo science scientific-computing simulation systems-biology

Keywords from Contributors

hack interpretability meshing standardization bridges pinn pde pipeline-testing matrix-exponential robust
Last synced: 6 months ago · JSON representation ·

Repository

Fast stochastic simulator for chemical reaction networks

Basic Info
Statistics
  • Stars: 45
  • Watchers: 1
  • Forks: 6
  • Open Issues: 8
  • Releases: 5
Topics
gillespie monte-carlo science scientific-computing simulation systems-biology
Created almost 8 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog License Citation

README.md

| Rust | Python | | ------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | | Build status | Build status | | Crates.io | PyPI - Version | | Docs.rs | readthedocs.org |

rebop

rebop is a fast stochastic simulator for well-mixed chemical reaction networks.

Performance and ergonomics are taken very seriously. For this reason, two independent APIs are provided to describe and simulate reaction networks:

  • a macro-based DSL implemented by [define_system], usually the most efficient, but that requires to compile a rust program;
  • a function-based API implemented by the module [gillespie], also available through Python bindings. This one does not require a rust compilation and allows the system to be defined at run time. It is typically 2 or 3 times slower than the macro DSL, but still faster than all other software tried.

The macro DSL

It currently only supports reaction rates defined by the law of mass action. The following macro defines a dimerization reaction network naturally:

rust use rebop::define_system; define_system! { r_tx r_tl r_dim r_decay_mRNA r_decay_prot; Dimers { gene, mRNA, protein, dimer } transcription : gene => gene + mRNA @ r_tx translation : mRNA => mRNA + protein @ r_tl dimerization : 2 protein => dimer @ r_dim decay_mRNA : mRNA => @ r_decay_mRNA decay_protein : protein => @ r_decay_prot }

To simulate the system, put this definition in a rust code file and instantiate the problem, set the parameters, the initial values, and launch the simulation:

rust let mut problem = Dimers::new(); problem.r_tx = 25.0; problem.r_tl = 1000.0; problem.r_dim = 0.001; problem.r_decay_mRNA = 0.1; problem.r_decay_prot = 1.0; problem.gene = 1; problem.advance_until(1.0); println!("t = {}: dimer = {}", problem.t, problem.dimer);

Or for the classic SIR example:

```rust use rebop::define_system;

definesystem! { rinf rheal; SIR { S, I, R } infection : S + I => 2 I @ rinf healing : I => R @ r_heal }

fn main() { let mut problem = SIR::new(); problem.rinf = 1e-4; problem.rheal = 0.01; problem.S = 999; problem.I = 1; println!("time,S,I,R"); for t in 0..250 { problem.advance_until(t as f64); println!("{},{},{},{}", problem.t, problem.S, problem.I, problem.R); } } ```

which can produce an output similar to this one:

Typical SIR output

Python bindings

This API shines through the Python bindings which allow one to define a model easily:

```python import rebop

sir = rebop.Gillespie() sir.addreaction(1e-4, ['S', 'I'], ['I', 'I']) sir.addreaction(0.01, ['I'], ['R']) print(sir)

ds = sir.run({'S': 999, 'I': 1}, tmax=250, nb_steps=250) ```

You can test this code by installing rebop from PyPI with pip install rebop. To build the Python bindings from source, the simplest is to clone this git repository and use maturin develop.

The traditional API

The function-based API underlying the Python package is also available from Rust, if you want to be able to define models at run time (instead of at compilation time with the macro DSL demonstrated above). The SIR model is defined as:

```rust use rebop::gillespie::{Gillespie, Rate};

let mut sir = Gillespie::new([999, 1, 0]); // [ S, I, R] // S + I => 2 I with rate 1e-4 sir.addreaction(Rate::lma(1e-4, [1, 1, 0]), [-1, 1, 0]); // I => R with rate 0.01 sir.addreaction(Rate::lma(0.01, [0, 1, 0]), [0, -1, 1]);

println!("time,S,I,R"); for t in 0..250 { sir.advanceuntil(t as f64); println!("{},{},{},{}", sir.gettime(), sir.getspecies(0), sir.getspecies(1), sir.get_species(2)); } ```

Performance

Performance is taken very seriously, and as a result, rebop outperforms every other package and programming language that we tried.

Disclaimer: Most of this software currently contains much more features than rebop (e.g. spatial models, custom reaction rates, etc.). Some of these features might have required them to make compromises on speed. Moreover, as much as we tried to keep the comparison fair, some return too much or too little data, or write them on disk. The baseline that we tried to approach for all these programs is the following: the model was just modified, we want to simulate it N times and print regularly spaced measurement points. This means that we always include initialization or (re-)compilation time if applicable. We think that it is the most typical use-case of a researcher who works on the model. This benchmark methods allows to record both the initialization time (y-intercept) and the simulation time per simulation (slope).

Many small benchmarks on toy examples are tracked to guide the development. To compare the performance with other software, we used a real-world model of low-medium size (9 species and 16 reactions): the Vilar oscillator (Mechanisms of noise-resistance in genetic oscillators, Vilar et al., PNAS 2002). Here, we simulate this model from t=0 to t=200, reporting the state at time intervals of 1 time unit.

Vilar oscillator benchmark

We can see that rebop's macro DSL is the fastest of all, both in time per simulation, and with compilation time included. The second fastest is rebop's traditional API invoked by convenience through the Python bindings.

Features to come

  • compartment volumes
  • arbitrary reaction rates
  • other SSA algorithms
  • tau-leaping
  • adaptive tau-leaping
  • hybrid models (continuous and discrete)
  • SBML
  • CLI interface
  • parameter estimation
  • local sensitivity analysis
  • parallelization

Features probably not to come

  • events
  • space (reaction-diffusion systems)
  • rule modelling

Benchmark ideas

  • DSMTS
  • purely decoupled exponentials
  • ring
  • Toggle switch
  • LacZ, LacY/LacZ (from STOCKS)
  • Lotka Volterra, Michaelis--Menten, Network (from StochSim)
  • G protein (from SimBiology)
  • Brusselator / Oregonator (from Cellware)
  • GAL, repressilator (from Dizzy)

Similar software

Maintained

Seem unmaintained

License: MIT

Owner

  • Name: Virgile Andreani
  • Login: Armavica
  • Kind: user
  • Location: Boston

Hi! I am a physicist by training with a PhD in computational biology. I love Rust, Monte-Carlo methods and scientific computing.

Citation (CITATION.cff)

# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: rebop
message: >-
  If you use this software, please cite it using the
  metadata from this file.
type: software
authors:
  - given-names: Virgile
    family-names: Andreani
    orcid: "https://orcid.org/0000-0002-2383-1478"
identifiers:
  - type: doi
    value: 10.5281/zenodo.15381302
repository-code: "https://github.com/Armavica/rebop"
url: "https://armavica.github.io/rebop/"
abstract: Fast stochastic simulator for chemical reaction networks
license: MIT
version: 0.9.2
date-released: "2025-05-11"

GitHub Events

Total
  • Create event: 51
  • Release event: 3
  • Issues event: 5
  • Watch event: 1
  • Delete event: 54
  • Issue comment event: 29
  • Push event: 104
  • Pull request review comment event: 4
  • Pull request review event: 5
  • Pull request event: 66
  • Fork event: 3
Last Year
  • Create event: 51
  • Release event: 3
  • Issues event: 5
  • Watch event: 1
  • Delete event: 54
  • Issue comment event: 29
  • Push event: 104
  • Pull request review comment event: 4
  • Pull request review event: 5
  • Pull request event: 66
  • Fork event: 3

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 221
  • Total Committers: 7
  • Avg Commits per committer: 31.571
  • Development Distribution Score (DDS): 0.068
Past Year
  • Commits: 110
  • Committers: 7
  • Avg Commits per committer: 15.714
  • Development Distribution Score (DDS): 0.136
Top Committers
Name Email Commits
Virgile Andreani a****a@u****r 206
Mauro Silberberg m****r@g****m 5
dependabot[bot] 4****] 4
armavicas-release-app[bot] 1****] 3
github-actions[bot] 4****] 1
armavica-s-release-app[bot] 1****] 1
Jonas Pleyer 5****r 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 14
  • Total pull requests: 91
  • Average time to close issues: 14 days
  • Average time to close pull requests: 21 days
  • Total issue authors: 3
  • Total pull request authors: 7
  • Average comments per issue: 0.71
  • Average comments per pull request: 0.47
  • Merged pull requests: 77
  • Bot issues: 0
  • Bot pull requests: 20
Past Year
  • Issues: 5
  • Pull requests: 71
  • Average time to close issues: about 1 month
  • Average time to close pull requests: 15 days
  • Issue authors: 3
  • Pull request authors: 6
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.61
  • Merged pull requests: 58
  • Bot issues: 0
  • Bot pull requests: 16
Top Authors
Issue Authors
  • Armavica (10)
  • dave-doty (2)
  • maurosilber (2)
Pull Request Authors
  • Armavica (71)
  • armavicas-release-app[bot] (11)
  • dependabot[bot] (10)
  • maurosilber (10)
  • github-actions[bot] (2)
  • jonaspleyer (2)
  • quffaro (1)
  • armavica-s-release-app[bot] (1)
Top Labels
Issue Labels
Pull Request Labels
dependencies (10) github_actions (5)

Dependencies

Cargo.toml cargo
  • criterion 0.3.5 development
  • pyo3 0.15.1
  • rand 0.8.4
  • rand_distr 0.4.3
.github/workflows/rust.yml actions
  • actions/checkout v2 composite
pyproject.toml pypi
  • xarray >= 2023.01