Skip to main content
PyBioNetGen

A simple CLI for BioNetGen

BNG CLI build status Open in Remote - Containers Documentation Status Downloads Downloads

This is a simple CLI and a library for BioNetGen modeling language. PyBioNetGen also includes a heavily updated version of Atomizer which allows for conversion of models written in Systems Biology Markup Language (SBML) into BioNetGen language (BNGL) format.

Please see the documentation to learn how to use PyBioNetGen.

Installation

You will need both python (3.7 and above) and perl installed. Once both are available you can use the following pip command to install the package

$ pip install bionetgen

Optional: in-process simulation with BNGsim

PyBioNetGen can optionally use BNGsim as an in-process simulation engine (ODE/SSA/NFsim, multi-format input). This is fully opt-in: if BNGsim is not installed, every simulation uses the existing subprocess BNG2.pl path and behavior is unchanged. BNGsim is never a required dependency.

BNGsim is a compiled extension and is not on PyPI yet, so pip install bionetgen[bngsim] will not resolve until it is published. To try it now, install a prebuilt wheel from the release assets (macOS / Python 3.12; build from source on other platforms). PyBioNetGen requires BNGsim 0.9.10 or newer. Set BIONETGEN_NO_BNGSIM=1 to force the legacy subprocess path even when BNGsim is installed. See the BNGsim documentation page for details.

Features

PyBioNetGen comes with a command line interface (CLI), based on cement framework, as well as a functional library that can be imported. The CLI can be used to run BNGL models, generate Jupyter notebooks and do rudimentary plotting.

The library side provides a simple BNGL model runner as well as a model object that can be manipulated and used to get libRoadRunner simulators for the model.

PyBioNetGen also includes a heavily updated version of Atomizer which allows for conversion of SBML models into BNGL format. Atomizer can also be used to automatically try to infer the internal structure of SBML species during the conversion, see here for more information. Please note that this version of Atomizer is the main supported version and the version distributed with BioNetGen will eventually be deprecated.

The model object requires a system call to BioNetGen so the initialization can be relatively costly, in case you would like to use it for parallel applications, use the libRoadRunner simulator instead, unless you are doing NFSim simulations.

Usage

Sample CLI usage

$ bionetgen -h # help on every subcommand
$ bionetgen run -h # help on run subcommand
$ bionetgen run -i mymodel.bngl -o output_folder # this runs the model in output_folder

Sample library usage

import bionetgen 

ret = bionetgen.run("/path/to/mymodel.bngl", out="/path/to/output/folder")
# out keyword is optional, if not given, 
# generated files will be deleted after running
res = ret.results['mymodel']
# res will be a numpy record array of your gdat results

model = bionetgen.bngmodel("/path/to/mymodel.bngl")
# model will be a python object that contains all model information
print(model.parameters) # this will print only the parameter block in BNGL format
print(model) # this will print the entire BNGL
model.parameters.k = 1 # setting parameter k to 1
with open("new_model.bngl", "w") as f:
    f.write(str(model)) # writes the changed model to new_model file

# this will give you a libRoadRunner instance of the model
librr_sim = model.setup_simulator()

You can find more tutorials here.

Environment Setup

The following demonstrates setting up and working with a development environment:

### create a virtualenv for development

$ make virtualenv

$ source env/bin/activate


### run bionetgen cli application

$ bionetgen --help


### run pytest / coverage

$ make test

Docker

Included is a basic Dockerfile for building and distributing BioNetGen CLI, and can be built with the included make helper:

$ make docker

$ docker run -it bionetgen --help

Publishing to PyPI

You can use make dist command to make the distribution and push to PyPI with

python -m twine upload dist/*

You'll need to have a PyPI API token created, see here for more information.

Release files for bionetgen 0.8.7

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

Source distribution (sdist)

Source distribution for bionetgen 0.8.7
File Size Uploaded
bionetgen-0.8.7.tar.gz 11.9 MB Details

Built distribution (wheel)

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

Total release size: 23.9 MB

Release files / bionetgen-0.8.7.tar.gz

Download URL bionetgen-0.8.7.tar.gz
Size 11.9 MB
Tags Source
SHA-256 checksum
How to use checksums
4cb84c427948627b79032c34a10784b449667a17cabbe69ae23109f5ebde71f6
BLAKE2b-256 checksum
How to use checksums
1c910c8785008f802d311d52b4fe9f8906b26b0c6a5d6af28d95e64706530a70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / bionetgen-0.8.7-py3-none-any.whl

Download URL bionetgen-0.8.7-py3-none-any.whl
Size 12.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
95c6ff9cf2349dd20280dcd2388a723df72f2283783d0d233a780874ba3628a8
BLAKE2b-256 checksum
How to use checksums
93c8309cd3f0ec83aae0316ebb20c521e5934c9dd393f87687c55ae332b221f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.8.7 This release

2 release files

0.8.6

2 release files

0.8.5

2 release files

0.8.4

2 release files

0.8.3

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.9

2 release files

0.7.8

2 release files

0.7.7

2 release files

0.7.6

2 release files

0.7.5

2 release files

0.7.4

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.0

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.9

2 release files

0.5.8

2 release files

0.5.7

2 release files

0.5.6

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.9

2 release files

0.4.7

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.9

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

1 release file

0.3.1

2 release files

0.3.0

2 release files

0.2.9

2 release files

0.2.7

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