CRN-craft
Reproducible simulation and analysis of well-mixed chemical reaction networks, with a native Rust core. Models, requests and results are versioned JSON documents with strict input checks, explicit budgets and replayable seeds.
pip install crn-craft
Wheels for CPython 3.10 and newer (stable ABI) on Linux x86_64, Windows x64 and macOS (x86_64 and arm64); other platforms build from the source distribution with a Rust toolchain.
Example
Immigration–death (birth rate 4, death rate 0.2, starting from zero) has a
Poisson law with mean 20 (1 - exp(-0.2 t)): 12.64 at t = 5 and 17.29 at
t = 10. A model is built from Python calls; a number is a mass-action
constant, a string the reaction's whole propensity.
import crn_craft as crn
model = crn.Model("immigration_death")
model.add_parameter("k_in", 4.0).add_species("X")
model.add_reaction("k_in", [], ["X"], name="immigration") # string: whole propensity
model.add_reaction(0.2, ["X"], [], name="death") # number: mass action, 0.2 X
result = crn.ensemble(
model,
end=10.0,
report_times=[0.0, 5.0, 10.0],
replicates=1000,
seed=1,
threads=2,
method="static_direct",
keep_paths="all",
).simulate()
print(result.metadata["sampler"])
print(result.statistics["mean"])
print(result.statistics["median"])
print(result.rule_events.sum().to_dict())
print(result.paths.sel(variable="X").to_pandas().head(3)) # cells x times
chacha8-u53-ziggurat/rules-static-direct/1
X
time
0.0 0.000
5.0 12.623
10.0 17.305
X
time
0.0 0.0
5.0 12.0
10.0 17.0
{'immigration': 39800, 'death': 22495}
time 0.0 5.0 10.0
replicate
0 0.0 14.0 19.0
1 0.0 19.0 20.0
2 0.0 17.0 17.0
The means lie within one standard error of the exact 12.64 and 17.29. The same
seed gives the same result on every run and for every thread count.
result.statistics also holds the median and the 2.5% and 97.5% quantiles,
result.save("run.md") writes the model and the results to a markdown report
(.json writes a JSON report), and results are pandas DataFrames: per-replicate
records and rule counts, statistics by report time and trackers. Kept paths and
event logs are xarray DataArrays with the replicate first.
The same model has an exact distribution, from finite state projection, and a structural analysis:
import crn_craft as crn
model = crn.Model("immigration_death")
model.add_parameter("k_in", 4.0).add_species("X")
model.add_reaction("k_in", [], ["X"], name="immigration")
model.add_reaction(0.2, ["X"], [], name="death")
distribution = model.fsp(end=10.0, report_times=[10.0], bounds={"X": 60})
print(distribution)
print(distribution.mean) # 17.29, the exact mean at t = 10
report = model.analyze()
print(report["schema"], report["analysis"]["conservation"]["status"])
FspResult(61 states of X, 1 report times)
species X
time
10.0 17.293294
crn-craft.analysis/1.0 exact
What is included
- One engine and one API. A model is a
crn-craft.model/1.0document, a run request iscrn-craft.run/1.0, and the result iscrn-craft.result/1.0; the same contracts are used by the Rust crate and thecrn-craftcommand. - Exact stochastic simulation:
static_directwith the event selectorslinear,composition_rejection,sorting,rssa_crandauto,next_reaction, and the exacttreemethod for models whose species carry attributes (clones, sizes, lineages). - Explicitly approximate methods: Poisson leaping (
tau), fixed splitting (binomial) andhybridfor models with continuous variables. - Prepared runs and parameter binding for optimization loops
(
run.bind_parameters(...)), trackers, event logs and callbacks, and an opt-in compiled event loop (crn.compile_loop, needs a Rust toolchain). - Exact distributions (
Model.fsp), network analysis and conservation laws (Model.analyze), GillesPy2 export (Model.to_gillespy2), and strict SBML and BioNetGen import (crn.read_sbml,crn.read_bngl,crn-craft-import). - Quantile statistics and the median, and
Result.saveto markdown or JSON. - The
crn-craftcommand forcheck,run,verify(sealed archives),analyze,convertandexport. The native command-line tool (cargo install crn-craft-cli --locked) has the same commands. pip install "crn-craft[fit]"adds the pinned SciPy, fcmaes-rust and SQP-craft versions used by the fitting examples.
crn_craft.rules keeps the API of release 0.6.0 under its old name, with its
defaults, so code written for 0.6.0 keeps running with the same results.
Release 0.7.0 merged the earlier network engine into the one engine; the
changelog
has the migration tables. ODE right-hand sides and Jacobians are in the Rust
crate (crn_craft::kinetics). The optional diffsol BDF integrator with
forward sensitivities and the job worker for
optimization-jobs build from
the repository and are not part of the wheel.
Documentation
- Repository and README
- Tutorial
- Exact methods and selectors
- Model reference and mtDNA user manual
- Using CRN-craft from R through reticulate
- Optimization tutorials C1–C4
- Agent context
- Changelog
A successful numerical run is not biological validation. MIT licensed; see THIRD_PARTY_NOTICES.md for the Ziggurat tables adapted from Julia.
Metadata
Release files for crn-craft 0.7.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 |
|---|---|---|---|---|
| crn_craft-0.7.0.tar.gz | 745.7 kB | Without provenance | Details for crn_craft-0.7.0.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| crn_craft-0.7.0-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details for crn_craft-0.7.0-cp310-abi3-win_amd64.whl |
| crn_craft-0.7.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ x86-64 | Details for crn_craft-0.7.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
| crn_craft-0.7.0-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details for crn_craft-0.7.0-cp310-abi3-macosx_11_0_arm64.whl |
| crn_craft-0.7.0-cp310-abi3-macosx_10_12_x86_64.whl | CPython 3.10 | abi3 | macOS 10.12+ x86-64 | Details for crn_craft-0.7.0-cp310-abi3-macosx_10_12_x86_64.whl |
Total release size: 7.7 MB
Release files / crn_craft-0.7.0.tar.gz
| Download URL | crn_craft-0.7.0.tar.gz |
|---|---|
| Size | 745.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
adef7b3811263cac4f0aec6296bb6b419881b003c694d898a9242dec546aa52d
|
|
BLAKE2b-256 checksum How to use checksums |
cceb99ce671218ec8c4b32f312d15974ce5b049bfdef9f98d5dcae03ee1105ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / crn_craft-0.7.0-cp310-abi3-win_amd64.whl
| Download URL | crn_craft-0.7.0-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
0fbb0d13e7c2576f6d54f4587050483fc2480f37fbf960b9b9ffe2de9ef9ca2a
|
|
BLAKE2b-256 checksum How to use checksums |
453d0986cee4effc1f19a1107c3cfd333f77cd2d324e24f0d95c382c7383a5d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / crn_craft-0.7.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | crn_craft-0.7.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
0edecf0f14915d47c4f893ab7330b82b732fe1aacff0988a5ab0efeb1076e74b
|
|
BLAKE2b-256 checksum How to use checksums |
44dc1ffc6daf253b1652c6bb2ff0510c39a33c278be66619ad2a3e8c11533717
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / crn_craft-0.7.0-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | crn_craft-0.7.0-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
d1cb63a4e34716a981da3519aa7c00a9d5328fa71f6a12a7ad0d8ad02fdb9ecf
|
|
BLAKE2b-256 checksum How to use checksums |
356587d7571f95e4f4da2cbb19d8d4657f7400d93d7785dab18b8abff5f8cb2e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / crn_craft-0.7.0-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | crn_craft-0.7.0-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 1.7 MB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
112cda36b0804af14e0b4202b06c9e19a887c4164189742d925663ff6fbd5dd0
|
|
BLAKE2b-256 checksum How to use checksums |
06c7efe4bffac64fb0594135a93c4f7390287f030341573777b42f882e2dd68e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for crn-craft 0.7.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.