-
Notifications
You must be signed in to change notification settings - Fork 6
BNGsim integration: in-process simulation, multi-format support, Python 3.12 fixes #66
Description
I've been working on integrating BNGsim into PyBioNetGen on my fork. The changes are in versions 0.9.0 and 0.9.1. I'd like to contribute them back upstream if there's interest. Happy to open a PR.
What it does
BNGsim is a C++ simulation engine with Python bindings that can load and simulate BioNetGen network files (.net), SBML, and Antimony models in-process. It is a dependency of PyBNF (PyBioNetFit). The repo will be published at github.com/lanl/bngsim but is not yet public.
The integration adds an optional in-process simulation path that replaces subprocess calls to run_network and NFsim. If BNGsim is not installed, everything falls back to the existing subprocess path — no behavior change for current users.
New capabilities:
- In-process ODE, SSA, and NFsim simulation via BNGsim
- Direct support for
.net, SBML (.xml), and Antimony (.ant) input formats with auto-detection tfun(inline tabulated functions) support via BNGsim- Codegen (compiled C RHS) for accelerated ODE simulation
- Threaded parameter scanning and steady-state solving
- CLI flags:
--method,--format,--no-bngsim - Library API:
simulator=,method=,t_span=,n_points=,format=
Engineering improvements:
- Replaced
pkg_resourcesanddistutilsimports for Python 3.12+ / setuptools ≥81 compatibility - Made Atomizer an optional dependency (
pip install bionetgen[atomizer]) - Added
pyproject.tomlwith ruff (16 rule categories) and mypy configuration - Expanded test suite from ~4k to ~15k lines
Issues addressed
Fully closes:
- distutils was deprecated in Python 3.12 #58 —
distutilsdeprecated in Python 3.12 - pkg_resources update breaks bngl #59 —
pkg_resourcesupdate breaks bngl - PyBioNetGen fails with setuptools ≥81 (Python 3.12) #61 — PyBioNetGen fails with setuptools ≥81
- Feature request: support for
tfun(inline tabulated functions) #65 —tfunsupport
Substantially addresses:
- Suggestion: remove requirement for specific file extensions #6 — Remove requirement for specific file extensions (format auto-detection + explicit
format=hint) - Suggestion: use py-perl5 for more seamless bridge to
BNGL2.pl#22 — Seamless bridge to BNG2.pl (in-process simulation eliminates Perl for the simulation step)
Scope
74 files changed, ~14,850 insertions, ~520 deletions. The core addition is bionetgen/core/tools/bngsim_bridge.py (2,249 lines). The rest is CLI/API integration, packaging fixes, lint config, and tests.