【问题标题】:How to read attributes for a sbml file with libsbml如何使用 libsbml 读取 sbml 文件的属性
【发布时间】:2021-01-22 13:25:13
【问题描述】:

我有一个来自 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()

【问题讨论】:

    标签: python xml sbml


    【解决方案1】:

    libsbml API 旨在直接模仿 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())
    

    【讨论】:

    • 谢谢!这正是我想要的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-25
    • 2020-06-17
    • 1970-01-01
    • 2013-02-10
    • 2021-10-23
    相关资源
    最近更新 更多