Assume I have an infix expression such as k1*s1, how do I use libsbml to translate this expression to mathml using the python interface?
It’s quite straightforward to convert infix to mathml using libsbml. Make sure you have libsbml installed in python by typing
pip install python-libsbml
at the windows/Mac/Linux command line or
!pip install python-libsbml
if you are running a Jupyter notebook. Some tools such as Tellurium already have libsbml preinstalled.
At the python command line type
to import the package. To enter the infix expression type the following:
p = libsbml.parseFormula ('k1*s1')
To generate the mathml type
print (libsbml.writeMathMLToString (p))