Closed jonrkarr closed 3 years ago
@jonrkarr thanks for the report, I will look into it.
BIOMD0000000012_url.xml.psc.txt
The bug is in the SBML parser. The <ln/>
MathML operator is translated to math.log10
in the PSC file. Corrected PSC file attached above. This gives the correct results. @bgoli you wrote the SBML conversion code, would you be able to pinpoint this quickly?
The problem lies within the internal MathML translations of libsbml
.
>>> import libsbml as SBML
>>> r = SBML.SBMLReader()
>>> d = r.readSBMLFromFile('BIOMD0000000012_url.xml')
>>> m = d.getModel()
>>> a = m.getListOfRules()[0]
>>> a.getFormula()
'tau_mRNA / log(2)'
Upon reading a document, MathML <ln/>
is translated to log
in the formula (see above).
Upon writing the document with d.toSBML()
, any log
in the formula is back-translated to <ln/>
in the MathML, and any ln
in the formula is also back-translated to <ln/>
. If the formula contains log10
, this is translated to
<log/>
<logbase>
<cn type="integer"> 10 </cn>
</logbase>
How do other tools deal with this? Clearly it means that we cannot use symmetrical translation tables in pysces.core2.PyscesCore2Interfaces.CoreToSBML.NumpyToMathML
and pysces.core2.InfixParser.MyInfixLexer.MathmlToNumpy_funcs
.
Maybe Frank Bergmann could shed light on how COPASI does it.
Thanks for the explanation. GillesPy2 has similar issue with this model. I only realized this from your explanation about ln. In their case, they raise an exception which indicates they don't know how to interpret ln.
@jmrohwer thanks for finding the problem this, I will look into this in more detail. We probably notice the problem as we use the L2 infix translator while COPASI would use the ASTnodes directly.
This #45 fixes it, but I am not sure if you would want to make more significant changes in terms of using the AST nodes vs infix translator. Also, SBML export from the PSC file does not work 100% (assignment rules are not properly translated), this most probably has to do with PySCeS still using SBML L2 internally.
Fixed in #53
This was noticed by @freiburgermsu.
Example model (Elowitz repressilator model)
Example results
PySCeS
PySCeS' results are internally consistent between CVODE and LSODA, but different from that of other tools that also use LSODA and CVODE
COPASI (LSODA)
OpenCOR (CVODE)
Interactive versions of the same results