Skip to main content

CRN-craft

CRN-craft: chemical reaction networks in native Rust with stochastic simulation

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.

import crn_craft as crn

model = crn.load_example("immigration-death")
request = crn.ssa_spec(
    model, end=10.0, save_times=[0.0, 5.0, 10.0], replicates=1000, seed=1
)
result = crn.simulate_ssa(model, request)
print(result["sampler"])
print(result["statistics"]["mean"], result["statistics"]["mean_standard_error"])
xoshiro256pp-u53/direct_cr/inverse/fast-1
[[0.0], [12.618], [17.22500000000001]] [[0.0], [0.10959967193421745], [0.13107843665743252]]

Both means lie within one standard error of the exact values. The same seed gives the same result on every run and for every thread count.

What is included

  • Exact stochastic simulation: direct, cached_direct, direct_cr, sorting_direct and rssa_cr, with inverse or Ziggurat waiting times. fast (the default) emulates JumpProcesses.jl; fast=False selects the checked policy, which rejects lost increments and channels below the 53-bit selection resolution.
  • Prepared simulations and reusable parameter templates for optimization loops (crn.prepare_ssa, crn.prepare_parameters).
  • Sparse finite state projection (crn.fsp), explicitly approximate Poisson leaping (crn.tau), network analysis and conservation checks.
  • Strict SBML and BioNetGen import subsets (crn-craft-import) and the crn-craft command for archives, verification and export.
  • pip install "crn-craft[fit]" adds the pinned SciPy, fcmaes-rust and SQP-craft versions used by the fitting examples.

The rules engine for dynamic, attributed species is in the wheel as crn_craft.rules: prepared parallel ensembles, trackers, event logs and callbacks, and the mtDNA methods; see the mtDNA user manual. rules.Model builds models from Python calls, in the style of rebop: a numeric rate is a mass-action constant, a string the reaction's whole propensity. Results are pandas DataFrames (pandas is installed with the package): per-replicate records and rule counts, statistics by report time, kept paths by (replicate, time), trackers and event logs. Result.to_xarray() returns the paths as an xarray Dataset with pip install "crn-craft[xarray]". The same immigration–death model:

from crn_craft import rules

model = rules.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 = rules.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.statistics["mean"])
print(result.rule_events.sum().to_dict())
print(result.paths["X"].unstack("time").head(3))
           X
time
0.0    0.000
5.0   12.550
10.0  17.351
{'immigration': 40132, 'death': 22781}
time       0.0   5.0   10.0
replicate
0           0.0   7.0  19.0
1           0.0  13.0  20.0
2           0.0  18.0  25.0

The means lie within one standard error of the exact 12.64 and 17.29. Models may also declare continuous variables, ODEs between events that rates read (for example an ATP pool), which method="hybrid" simulates at declared tolerances. Release 0.3.0 changed the rules results from NumPy arrays to DataFrames; the changelog lists what to migrate. Its command-line tools (rules-check, rules) are in the native CLI (cargo install crn-craft-cli --locked, crates crn-craft and crn-craft-rules), which installs a crn-craft command of the same name as the wheel's. 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

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.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for crn-craft 0.3.0
File Size Uploaded Provenance Actions
crn_craft-0.3.0.tar.gz 458.1 kB Without provenance Details for crn_craft-0.3.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for crn-craft 0.3.0
File Actions
crn_craft-0.3.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for crn_craft-0.3.0-cp310-abi3-win_amd64.whl
crn_craft-0.3.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.3.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
crn_craft-0.3.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for crn_craft-0.3.0-cp310-abi3-macosx_11_0_arm64.whl
crn_craft-0.3.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for crn_craft-0.3.0-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 7.9 MB

Release files / crn_craft-0.3.0.tar.gz

Download URL crn_craft-0.3.0.tar.gz
Size 458.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e77febb0d8383b33be23099b8c0c9e23b2f717d67debc3f10f006e2449a1ac84
BLAKE2b-256 checksum
How to use checksums
2c135731645b9c2eb4ae7e1c333bce37b1352f457268697a89f03b8413464a7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","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.3.0-cp310-abi3-win_amd64.whl

Download URL crn_craft-0.3.0-cp310-abi3-win_amd64.whl
Size 1.8 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
2e1620d2b83626a204acff7ff9d1922a840e90c07c85a35b3913fa7313f93132
BLAKE2b-256 checksum
How to use checksums
8d8576a0fe857e62d16167543c3c8fff38069596ccef8cb654002000575463c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","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.3.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL crn_craft-0.3.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.0 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
8caa7f5faac7d875bc6dbb6e86aba7d14f2aa2986f0c79668576d4a08bb07ab2
BLAKE2b-256 checksum
How to use checksums
7acae41bc431a619d6de2bcf0b2f55244eb28de2f9a23bf28d33e2275b5423dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","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.3.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL crn_craft-0.3.0-cp310-abi3-macosx_11_0_arm64.whl
Size 1.8 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7542f618849430ac0155b07ab64bd16ab073732e68353057231202e56af49393
BLAKE2b-256 checksum
How to use checksums
3f35fefccdff5f55b14c6baa20ca5ab84a78ed42520d8b7f69d6d736e95450a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","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.3.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL crn_craft-0.3.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 1.9 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
1e7b6b18fbdbbc8a99996df2c78e6980f571923126ad97ce754f8fd68f00b45d
BLAKE2b-256 checksum
How to use checksums
28d9a988040fbb0af1d32f0bbebfb9b082916b8929dfe332d1049670d28e04bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","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.3.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.

Release history Release notifications | RSS feed

This release

0.3.0 This release

5 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page