Open DeepaMahm opened 2 years ago
Hi Deepa, this is not supported at the moment, but multiple users asked for the functionality. This will be supported in the next version. Best Matthias
Hi Matthias,
Could you please let me know if this feature has been added now?
I tried to view the differential equations by importing the file in COPASI. All the rate expressions are divided by volume (this gives rise to inconsistent units). i.e the RHS of the differential equation is not in amounts (moles/s).
.
The same rate expression, when viewed in SBML4Humans, doesn't have a volume factor in the denominator.
Hello Matthias,
I would be interested in this feature as well. Do you think this will be implemented in the near future?
Best regards and Thank You Luis
Hello @lmandl ,
I hope the following is useful for you.
"""Print ODEs."""
from pathlib import Path
from typing import Dict
from sbmlutils.console import console
import libsbml
def print_odes(sbmlpath: Path) -> None:
"""Prints ODS in given model.
Converts reaction to rate rules.
"""
print(sbmlpath)
doc = libsbml.readSBMLFromFile(str(sbmlpath))
# inline function definitions
props = libsbml.ConversionProperties()
props.addOption('expandFunctionDefinitions', True)
doc.convert(props)
# convert reactions to ODEs
props = libsbml.ConversionProperties()
props.addOption('replaceReactions', True)
doc.convert(props)
mod = doc.getModel()
# print list of odes
odes: Dict[str, str] = {}
for rule in mod.getListOfRules():
if not isinstance(rule, libsbml.RateRule):
continue
variable_id = rule.getVariable()
left_side: str = f"d{variable_id}/dt"
right_side: str = rule.getFormula()
odes[left_side] = right_side
# console.print(f"{left_side:10} = {right_side}")
console.print(odes)
if __name__ == "__main__":
print_odes('model.xml')
Awesome! Thanks for the quick and great reply.
Hi @matthiaskoenig,
Could you please let me know if we can view the differential equations in the report that is generated via SBML4HUMANS? I could view the fluxes in the report but not the differential equations expressed as a function of fluxes.
Thank you, Deepa