如何使用libsbml读取sbml文件的属性

2024-05-18 05:52:27 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个来自Reactome的sbml模型,您可以从https://reactome.org/content/detail/R-HSA-156581下载它并单击sbml。对于<reaction>,其中一些具有<listOfModifiers>属性,我正在尝试使用libsbml或cobrapy来实现这一点

我的代码读取了sbml文件,但是如何获取<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()

Tags: httpsorg模型testmodel属性documentreader
1条回答
网友
1楼 · 发布于 2024-05-18 05:52:27

libsbmlapi被设计为直接模拟SBML本身的结构。因此,一旦你有了模型,你就可以从模型中得到反应,一旦你有了反应,你就可以得到反应的修改器:

    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())

相关问题 更多 >