sbml_to_bngl writes simulate actions with no tolerances, so BNG2.pl runs BIOMD0000000571 at its default atol=1e-8 and 57 of 76 species miss by up to 2.6x their peak; event-free models get no actions block, and there is no sedml= input

Open
#1,830 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
backend, databases

Research direction

Start in bngsim.convert.sbml_to_bngl and compare its generated simulate actions with the issue’s reproduced tolerances and event-free examples. Then read sbml_to_net for its SED-ML handling and warning; the issue proposes carrying time-course settings into BNGL actions and correcting that warning. Done means generated actions preserve the requested simulation settings and avoid the demonstrated default-tolerance error, including for event-free models.

Written by the indexing model from the issue text.

Description

Summary

bngsim.convert.sbml_to_bngl(strict=True) translates fixed-time SBML events into a BNGL actions block (#224 phase 2), but the simulate actions it writes carry no atol/rtol. BNG2.pl then runs run_network -a 1e-08 -r 1e-08, its defaults. On a model in molar units, where species sit at 1e-7 to 1e-12, that absolute tolerance is larger than the solution. The converted file reports ok=True, lossy=[], dropped=[], but BNG2.pl's trajectory is wrong.

Related gaps in the same channel:

  • Event-free models get no actions block at all (BIOMD0000000883, BIOMD0000000667, BIOMD0000001065), so BNG2.pl on the file only reads the model. Fixed-time-event models do get generate_network + simulate.
  • There is no sedml= argument. sbml_to_net has one, but sbml_to_bngl cannot carry the model's own horizon, output grid or tolerances into the actions.
  • sbml_to_net's warning points at a tool that doesn't exist. For a model with events it says "emit them as a SED-ML sidecar instead", but sbml_to_bngl is the converter that carries fixed-time events, as BNGL actions.

Reproduction (bngsim 0.17.2, BioNetGen 2.9.3, libRoadRunner 2.11.0)

Model: BIOMD0000000571 (Nishio 2008, E. coli phosphotransferase system), sys-bio/temp-biomodels @ 6a09daf46af1bb89e4857436b623a7b8720863ad, final/BIOMD0000000571/BIOMD0000000571_url.xml (sha256 9410de3b8aff1ec7…, as in parity_checks/rr_parity/temp_biomodels_manifest.json). One event: at time >= 500, Glucose := 2e-9.

from bngsim.convert import sbml_to_bngl
rep = sbml_to_bngl("BIOMD0000000571_url.xml", "nishio.bngl", strict=True)
# rep.ok == True, rep.lossy == [], rep.dropped == []

The actions it writes:

generate_network({overwrite=>1})
simulate({method=>"ode",t_start=>0,t_end=>500,n_steps=>100})
setConcentration("@comp1:Glucose()",2e-09)
simulate({method=>"ode",t_start=>500,t_end=>1000,n_steps=>100,continue=>1})

perl BNG2.pl nishio.bngl was compared, at every .gdat time except the t=500 phase boundary, with bngsim Model.from_sbml on the SBML (rtol 1e-10, atol 1e-14). Errors are max |diff| / peak per species, using the observable named after each SBML species ID. bngsim and libRoadRunner agree on the SBML to 2.8e-7.

BNG2.pl run species > 1e-4 of peak worst
actions as written (BNG defaults atol = rtol = 1e-8) 57 of 76 2.57 x peak (CRPsite_cyaA at t = 525: BNG2.pl -7.9e-11; bngsim and roadrunner 7.73e-13). Already > 1e-4 at t = 5, and 4.7e-2 before the event.
same actions plus atol=>1e-14, rtol=>1e-10 0 of 76 9.9e-5 (IICB_Mlc)

The converted model itself is exact. bngsim integrating the .net that BNG2.pl generates from nishio.bngl matches bngsim on the SBML with zero difference over 0–470. So the 1e-4 left in the second row is run_network's own integration, and the first row is the tolerance alone.

Suggested directions

  1. Write atol/rtol into every generated simulate. Take them from the SED-ML when one is given, and otherwise from a scale-aware default rather than BNG's absolute 1e-8.
  2. Accept sedml= as sbml_to_net does. Emit its time course (initial time, output start, end, points, tolerances) as the actions, including for event-free models, which today get no simulate at all.
  3. Point sbml_to_net's dropped-events warning at sbml_to_bngl, which carries fixed-time events.

Found while building the SBML ODE suite of lanl/bngsim-benchmarks, which drives BioNetGen's run_network as a reference engine.

Dominant language
Python
Stars
3
Forks
6
Avg merge
1d 1h
Merged PRs (30d)
295

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from lanl/bngsim

All issues in lanl/bngsim

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.