I have a sbml model from Reactome, you can download it from https://reactome.org/content/detail/R-HSA-156581 and clicking sbml. For the <reaction>
, some of it have attribute of <listOfModifiers>
, and I'm trying to use libsbml or cobrapy for doing that.
My code read the sbml file, but how to get the attribute for <listOfModifiers>
?
sbml_test_file = "./R-HSA-156581.sbml"
# Using the libSBML python API
# http://model.caltech.edu/software/libsbml/5.18.0/docs/formatted/python-api/libsbml-python-reading-files.html
reader = libsbml.SBMLReader()
document = reader.readSBML(sbml_test_file)
model = document.getModel()
The libsbml API is designed to directly mimic the structure of SBML itself. So, once you have the model, you get the reactions from the model, and once you have a reaction, you get the reaction's modifiers:
import libsbml
sbml_test_file = "R-HSA-156581.sbml"
reader = libsbml.SBMLReader()
document = reader.readSBML(sbml_test_file)
model = document.getModel()
for r in range(model.getNumReactions()):
rxn = model.getReaction(r)
for m in range(rxn.getNumModifiers()):
mod = rxn.getModifier(m)
print(mod.getId(), "in reaction", rxn.getId())