Skip to content

BNGsim integration: in-process simulation, multi-format support, Python 3.12 fixes #66

@wshlavacek

Description

@wshlavacek

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_resources and distutils imports for Python 3.12+ / setuptools ≥81 compatibility
  • Made Atomizer an optional dependency (pip install bionetgen[atomizer])
  • Added pyproject.toml with ruff (16 rule categories) and mypy configuration
  • Expanded test suite from ~4k to ~15k lines

Issues addressed

Fully closes:

Substantially addresses:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions