Repository navigation
Description
What happens
parse_bngl_protocol, and with it Model.from_bngl(..., protocol=True), lists saveParameters and resetParameters among the pure build/IO directives (_BUILD_VERBS, python/bngsim/convert/_protocol.py:110-111). The comment there says none of them "alters the trajectory a consumer would compute". So both are recorded in spec.dropped and otherwise ignored: no warning, nothing in spec.lossy, and strict=True accepts them too.
But resetParameters() puts every constant parameter back to the values saveParameters() saved (BioNetGen 2.9.3, Perl2/BNGModel.pm, resetParameters). A setParameter between the two is undone before the next run, and the spec keeps it.
Repro
begin model
begin parameters
k 1
end parameters
begin molecule types
A(b)
end molecule types
begin seed species
A(b) 100
end seed species
begin observables
Molecules Atot A()
end observables
begin reaction rules
A(b) -> 0 k
end reaction rules
end model
generate_network({overwrite=>1})
saveParameters()
setParameter("k",2)
resetParameters()
simulate({method=>"ode",t_end=>1,n_steps=>1})
spec = bngsim.convert.parse_bngl_protocol("m.bngl", strict=False)
spec.steps # set_parameter k=2.0, then the simulate
spec.dropped # ('generate_network', 'saveParameters', 'resetParameters')
spec.lossy # ()No warning is raised, with or without strict. BNG2.pl, run on the same file, prints Reloaded parameters saved with label 'DEFAULT', writes k 1 into the .net it runs, and reports Atot 36.79 at t=1 (100·e⁻¹). Replaying the spec runs with k=2, which gives 13.53 (100·e⁻²).
In the corpus
18 of the 1,070 tracked .bngl files use saveParameters/resetParameters. In 4 of them, a setParameter falls between a save and a reset that comes before a later run, so the spec is wrong for that run:
parity_checks/bng_parity/models/slow/rulehub/Published/Lin2019/TCR_model.bnglparity_checks/bng_parity/models/glacial/rulehub/Published/Lin2019/ERK_model.bnglparity_checks/bng_parity/models/glacial/rulehub/Published/Lin2019/prion_model.bnglparity_checks/bng_parity/models/slow/rulehub/Published/Salazar-Cavazos2019/190127_CHO_EGFR_best-fit.bngl
In TCR_model.bngl, setParameter("lambda",0.1) precedes the std_scaling run, and resetParameters() follows it. The spec runs partial_scaling with lambda 0.1, where BNG2.pl runs it with the declared 1.
None of the 14 models #1366 lists uses either verb, so this does not affect that issue's models.
Who reads the spec
Model.from_bngl(protocol=True). Since bngl: warn when a source's first run starts from a state from_bngl drops (#1366) #1388, its docstring says the spec returns the dropped actions instead of the dropped-state warning.- The SED-ML/OMEX conversion in
bngsim.convert, which parses withstrict=strict. parity_checks/codegen_paths/_metrics.py, throughprimary_experiment().
Fix directions
- Carry them. Add
save_parameters/reset_parametersStateChangekinds with labels, assave_concentrations/reset_concentrationsalready have (issue Named saved concentration states + reset_conc-to-snapshot scan (parameter_scan/bifurcate after pre-equilibration) #11), and have the consumers apply them. - At least, flag them. Treat them as lossy, so a non-strict parse warns and records them in
spec.lossy, andstrict=Truerefuses. Refusing only when asetParameterfalls between a save and its reset would leave alone the 14 files where the pair changes nothing.
Related: addConcentration and bifurcate are not carried either, but the parser does warn about them ("unrecognized BNGL action").
Activity
Merge pull request #1484 from lanl/feat/1366-run-bngl-protocol