stochmod
Constrained tau-leap-like stochastic simulator for SBML models, adapted from SPARCED-style simulation.
stochmod ingests SBML in Python, generates per-model C propensity code, compiles it into a cached shared library, and runs simulation through a pybind11 core with sparse CSC stoichiometry.
Install
pip install stochmod
For development from a clone:
pip install -e ".[dev]"
Requirements
- Python 3.10+
- A C compiler (
gcc,clang, or MSVCcl) for first-time model builds (per-model codegen at runtime) - CMake 3.18+ only when building the Python extension from source (binary wheels from PyPI already include it)
Quickstart
from stochmod import StochasticModule
mod = StochasticModule("model.xml")
traj = mod.run(start=0.0, stop=10.0, step=0.1) # shape: (n_steps, n_species)
print(mod.species_names)
print(mod.parameter_ids)
print(mod.initial_state)
print(mod.parameter_values)
mod.update("k1", 0.5)
mod.set_state([100.0, 0.0])
mod.set_parameters([0.1, 1.0])
Trajectory columns follow mod.species_names index order. Row 0 is the initial state.
Cache
Compiled model libraries are stored under:
$HOME/.cache/stochmod/<hash>/(default)- or a custom cache root via
StochasticModule(sbml_path, cache_dir="/path/to/cache/root")
Each cache entry contains sparse stoichiometry arrays, generated C sources, and libmodel.so / libmodel.dll / libmodel.dylib.
SBML support (v1)
- SBML Level 3 Version 2 kinetic models
- Species, parameters, compartments, reactions with MathML kinetic laws
- Species amounts used as-is from SBML (
initialAmountorinitialConcentration * compartment size)
Not supported in v1: events, assignment/rate rules, algebraic constraints.
API
| Method / property | Description |
|---|---|
StochasticModule(sbml_path, cache_dir=None, verbose=None) |
Parse SBML, build/load cached model |
run(start, stop, step) |
Simulate; returns [n_steps, n_species] NumPy array |
update(key, val) |
Update species, parameter, or compartment by SBML id |
set_state(vector) |
Replace all species amounts |
set_parameters(vector) |
Replace all parameter values |
species_names |
Species ids in column order |
parameter_ids |
Global parameter ids |
initial_state |
Current species amount vector |
parameter_values |
Current parameter vector |
Tests
pytest
Publishing
See PUBLISHING.md for PyPI release steps (wheels CI + Trusted Publishing).
License
MIT — see LICENSE.txt.
Metadata
Release files for stochmod 0.1.0
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 |
|---|---|---|---|---|
| stochmod-0.1.0.tar.gz | 1.3 MB | Without provenance | Details for stochmod-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| stochmod-0.1.0-cp312-cp312-win_amd64.whl | CPython 3.12 | CPython 3.12 | Windows x86-64 | Details for stochmod-0.1.0-cp312-cp312-win_amd64.whl |
Total release size: 1.4 MB
Release files / stochmod-0.1.0.tar.gz
| Download URL | stochmod-0.1.0.tar.gz |
|---|---|
| Size | 1.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a199f7489060d59af4045d9a8012a67e6dc962f94d547289371b78c75b7e477b
|
|
BLAKE2b-256 checksum How to use checksums |
25192e201ff6fe1d40a29fabad61ee2ed273e8c72a28c628e6dd0d9a19479eb4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Release files / stochmod-0.1.0-cp312-cp312-win_amd64.whl
| Download URL | stochmod-0.1.0-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 121.3 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
46277ffbdbb07396e5ca53c7754a499f94fdc41c06ed61fb6148d99aed5fcb4f
|
|
BLAKE2b-256 checksum How to use checksums |
18be1ed52779b3ee1e738f81d0d27265960f23dccc4e43818ed50df997e63c9b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Security for stochmod 0.1.0
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.