How to I get the infix expression for the body in a SBML function defintion using python libsbml? How do I translate the body of a function definition in SBML into infix using python libsbml?

For example after loading the model using:

reader = libsbml.SBMLReader()
doc = reader.readSBMLFromString (r.getSBML())
model = doc.model
To do the translation you need to access the function definition. First, make sure there are function definitions in your model by using:

if model.getNumFunctionDefinitions() &gt; 0:
   # continue


To get the infix of the body for the ith function definition use the following code:

f = model.getFunctionDeinfition(i)
body = f.getBody()
print (libsbml.formulaToL3String(body))


As a side note you can also get the jth argument for the function definition using:

f = model.getFunctionDeinfition(i)
arg = f.getArgument(j)
print (libsbml.formulaToL3String(arg))