Skip to main content

BioCRNPyler — Biomolecular Chemical Reaction Network Compiler

Python toolbox to create CRN models in SBML for biomolecular mechanisms

Build Status PyPI version Binder

Docs

BioCRNPyler (pronounced Bio-Compiler) is a Python package for the creation, manipulation, and study of the structure, dynamics, and functions of complex biochemical networks.

Example 1: Building Simple CRNs by Hand

BioCRNpyler allows for CRNs to be built by hand, adding Species and Reactions manually.

from biocrnpyler import Species, Reaction, ChemicalReactionNetwork
# let's build the following CRN
# A -->[k1] 2B
# B -->[k2] C+D
# Species
A = Species("A")
B = Species("B")
C = Species("C")
D = Species("D")

#Reaction Rates
k1 = 3.
k2 = 1.4

#Reaction Objects
R1 = Reaction.from_massaction([A], [B, B], k_forward = k1)
R2 = Reaction.from_massaction([B], [C, D], k_forward = k2)

#Make a CRN
CRN = ChemicalReactionNetwork(species = [A, B, C, D], reactions = [R1, R2])
print(CRN)

Example 2: Compiling Complex CRNs from Specifications

BioCRNpyler also allows for higher level descriptions to be compiled into a CRN. In the below example, a piece of synthetic DNA with two promoters pointing in opposite directions is constructed from a list of DNAparts which are combined together in a DNA_construct and then simulated in a TxTlExtract context, which represents a cell-free bacterial lysate with machinery like Ribosomes and Polymerases modeled explicitly.

Specification to CRN Illustration

from biocrnpyler.components import Promoter, RegulatedPromoter, CombinatorialPromoter
from biocrnpyler.components import RBS, CDS, Terminator, DNA_construct
from biocrnpyler.mixtures import TxTlExtract

#Define a set of DNA parts
ptet = RegulatedPromoter("ptet",["tetr"],leak=True) #this is a promoter repressed by tetR and has a leak reaction
pconst = Promoter("pconst") #constitutive promoter
pcomb = CombinatorialPromoter("pcomb",["arac","laci"], leak=False, tx_capable_list = [["arac"], ["laci"]]) #the Combinations A and B or just A or just B be transcribed
utr1 = RBS("UTR1") #regular RBS
utr2 = RBS("UTR1") #regular RBS
gfp = CDS("GFP","GFP") #a CDS has a name and a protein name. so this one is called GFP and the protein is also called GFP
fusrfp = CDS("fusRFP","RFP",no_stop_codons=["forward"]) #you can say that a protein has no stop codon. This is a little different from a fusion protein, because in this case you are saying that the ribosome reads through two proteins but still produces two distinct proteins, rather than one fused protein. This can happen in the case of the ta peptide which causes a peptide bond not to be formed while making a protein.
rfp = CDS("RFP","RFP") #regular RFP
cfp = CDS("CFP","CFP") #cfp
t16 = Terminator("t16") #a terminator stops transcription

#Combine the parts together in a DNA_construct with their directions
construct = DNA_construct([[ptet,"forward"],[utr1,"forward"],[gfp,"forward"],[t16,"forward"],[t16,"reverse"],[rfp,"reverse"],[utr1,"reverse"],[pconst,"reverse"]])

#some very basic parameters are defined - these are sufficient for the whole model to compile!
parameters={"cooperativity":2,"kb":100, "ku":10, "ktx":.05, "ktl":.2, "kdeg":2,"kint":.05}

#Place the construct in a context (TxTlExtract models a bacterial lysate with machinery like Ribosomes and Polymerases modelled explicitly)
myMixture = TxTlExtract(name = "txtl", parameters = parameters, components = [construct])

#Compile the CRN
myCRN = myMixture.compile_crn()

#plotting not shown - but BioCRNpyler automatically produces interactive reaction network graphs to help visualize and debug complex CRNs!

More advanced examples can be found in the example folder, here's the first file in the Tutorial series: Building CRNs

Installation

Install the latest version of BioCRNPyler::

$ pip install biocrnpyler

To plot the chemical reaction networks and simulate them, you may find it useful to install additional software:

To simulate SBML models, run pip install bioscrape on your terminal. To visualize CRNs, run pip install networkx

Further details about the installation process can be found in the BioCRNPyler wiki

Bugs

Please report any bugs that you find here. Or, even better, fork the repository on GitHub, and create a pull request (PR). We welcome all changes, big or small, and we will help you make the PR if you are new to git (just ask on the issue and/or see contribution guidelines).

Versions

BioCRNpyler versions:

  • 1.3.0 (latest release): To install run pip install biocrnpyler
  • 1.2.0 (previous stable release): To install run pip install biocrnpyler==1.2.0
  • 1.1.1 (compatible only with python <= 3.10): To install run pip install biocrnpyler==1.1.1
  • 0.9.0 (beta release): To install run pip install biocrnpyler==0.9.0
  • 0.2.1 (alpha release): To install run pip install biocrnpyler==0.2.1

License

Released under the BSD 3-Clause License (see LICENSE)

Copyright (c) 2025, Build-A-Cell. All rights reserved.

Metadata

Release files for BioCRNpyler 1.3.4

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

Source distribution (sdist)

Source distribution for BioCRNpyler 1.3.4
File Size Uploaded
biocrnpyler-1.3.4.tar.gz 18.1 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for BioCRNpyler 1.3.4
File Interpreter ABI Platform
biocrnpyler-1.3.4-py3-none-any.whl Python 3 none any Details

Total release size: 18.4 MB

Release files / biocrnpyler-1.3.4.tar.gz

Download URL biocrnpyler-1.3.4.tar.gz
Size 18.1 MB
Tags Source
SHA-256 checksum
How to use checksums
21a7b33a7042e3b41033f524baa5f3deb5b74c4adac45cee4b4bd6bfb33b39ca
BLAKE2b-256 checksum
How to use checksums
82ab078e34884d7b7407840f65b5b7276ce71743c3af3e402e9959d4248a4ae8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / biocrnpyler-1.3.4-py3-none-any.whl

Download URL biocrnpyler-1.3.4-py3-none-any.whl
Size 286.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8b9fecc9e3945054d20472e59e16af1ad5691c4640758d367b91a3495616cdbf
BLAKE2b-256 checksum
How to use checksums
7e15f81fe1246ee4d590a92ef1b58ecff3061d401939b9e8aa8692343f907e55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

1.3.4 This release

2 release files

1.3.3

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.2

2 release files

1.1.1

1 release file

1.1.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.2.1

2 release files

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