StochSS / GillesPy2

Modeling toolkit for biochemical simulation
http://gillespy2.readthedocs.io/
GNU General Public License v3.0
72 stars 32 forks source link

SBML math import imprudently replaces `ln` with `log` #459

Closed jonrkarr closed 3 years ago

jonrkarr commented 3 years ago

gillespy2.sbml.SBMLimport.__get_math does not translate rate law expressions correctly. The method needs to only replace the word ln with log rather than replacing ln with log everywhere. Even this will fail in cases where species and parameters have ids that are equal to the names of mathematical functions, whereas SBML can distinguish between these cases.

Example using the files in this archive

import gillespy2

# original model which cannot be simulated due to incorrect parsing of the SBML
# `Reason Given: name 'Clog' is not defined`
model = gillespy2.import_SBML('BIOMD0000000297.xml')[0]
results = model.run(solver=gillespy2.ODESolver)

# edited model with different specices names can be simulated (e.g, replaced `ln` in names with `lg`)
# - `Cln` --> `Clg`
# - `kdcln` --> `kdclg`
# - `kscln` --> `ksclg`
model = gillespy2.import_SBML('BIOMD0000000297-edited.xml')[0]
results = model.run(solver=gillespy2.ODESolver)
briandrawert commented 3 years ago

Issue resolved with #460