首页 > 解决方案 > 如何在 SBML 中为基因添加注释?

问题描述

我有一个基因组规模的化学计量代谢模型iMM904.xml,当我在文本编辑器中打开它时,我可以看到某些基因添加了注释,例如

<fbc:geneProduct fbc:id="G_YLR189C" fbc:label="YLR189C" metaid="G_YLR189C">
<annotation>
  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:bqbiol="http://biomodels.net/biology-qualifiers/">
    <rdf:Description rdf:about="#G_YLR189C">
      <bqbiol:isEncodedBy>
        <rdf:Bag>
          <rdf:li rdf:resource="http://identifiers.org/ncbigene/850886" />
          <rdf:li rdf:resource="http://identifiers.org/sgd/S000004179" />
        </rdf:Bag>
      </bqbiol:isEncodedBy>
    </rdf:Description>
  </rdf:RDF>
</annotation>
</fbc:geneProduct>

如何访问和更改此注释?当我尝试

import cbmpy as cbm

cmod = cbm.CBRead.readSBML3FBC('iMM904.xml')

gene = cmod.getGene('G_YLR189C')

print gene.getAnnotations()

我只看到一个空字典。

另外,我怎么能添加注释last modified by和实际注释呢?

标签: pythoncbmpysbml

解决方案


在 CBMPy 中,您可以通过三种不同的方式向 SBML 文件添加注释:

1)MIRIAM注释,

2) 任意键值对和

3)人类可读的笔记

这应该涵盖您在问题中提到的所有要点。我演示了如何将它们用于基因输入,但相同的命令可用于注释物种(代谢物)和反应。

1. MIRIAM注解

要访问现有的 MIRIAM 注释 - 您在问题中显示的注释 - 您可以使用:

import cbmpy as cbm

mod = cbm.CBRead.readSBML3FBC('iMM904.xml.gz')

# access gene directly by its locus tag which avoids dealing with the "G_" in the ID
gene = mod.getGeneByLabel('YLR189C')

gene.getMIRIAMannotations()

这将给出:

{'encodes': (),
 'hasPart': (),
 'hasProperty': (),
 'hasTaxon': (),
 'hasVersion': (),
 'is': (),
 'isDerivedFrom': (),
 'isDescribedBy': (),
 'isEncodedBy': ('http://identifiers.org/ncbigene/850886',
  'http://identifiers.org/sgd/S000004179'),
 'isHomologTo': (),
 'isPartOf': (),
 'isPropertyOf': (),
 'isVersionOf': (),
 'occursIn': ()}

如您所见,它包含您在 SBML 文件中看到的条目。

如果您现在要添加 MIRIAM 注释,可以使用两种方法:

A)让 CBMPy 为您创建 url:

gene.addMIRIAMannotation('is', 'UniProt Knowledgebase', 'Q06321')

B)输入您自己的网址:

# made up protein!
gene.addMIRIAMuri('is', 'http://identifiers.org/uniprot/P12345')

如果你现在检查gene.getMIRIAMannotations(),你会看到(我剪掉了几个空条目):

'is': ('http://identifiers.org/uniprot/Q06321',
  'http://identifiers.org/uniprot/P12345'),
 'isDerivedFrom': (),
 'isDescribedBy': (),
 'isEncodedBy': ('http://identifiers.org/ncbigene/850886',
  'http://identifiers.org/sgd/S000004179'),

因此,您的两个条目都已添加(再次重申:该P12345条目仅用于演示,请勿在您的实际模型中使用它!)。

如果您不知道正确的数据库标识符,CBMPy 也会帮助您,例如,如果您尝试:

gene.addMIRIAMannotation('is', 'uniprot', 'Q06321')

它会打印

"uniprot" is not a valid entity were you looking for one of these:

    UNII
    UniGene
    UniParc
    UniPathway Compound
    UniPathway Reaction
    UniProt Isoform
    UniProt Knowledgebase
    UniSTS
    Unimod
    Unipathway
    Unit Ontology
    Unite
INFO: Invalid entity: "uniprot" MIRIAM entity NOT set

其中包含'UniProt Knowledgebase'我们上面使用的。

2.添加任意键值对。

并非所有内容都可以使用 MIRIAM 注释方案进行注释,但您可以轻松创建自己的key-value-pairs. 使用您的示例,

gene.setAnnotation('last_modified_by', 'Vinz')

键和值是完全任意的,

gene.setAnnotation('arbitrary key', 'arbitrary value')

如果你现在打电话

gene.getAnnotations()

你收到

{'arbitrary key': 'arbitrary value', 'last_modified_by': 'Vinz'}

如果要访问某个密钥,可以使用

gene.getAnnotation('last_modified_by')

产生

'Vinz'

3.添加注释

如果你想写实际的评论,前两个选项都不合适,但你可以使用:

gene.setNotes('This is my favorite gene')

您可以使用

gene.getNotes()

如果您现在使用(确保使用 FBCV2!)导出模型:

cbm.CBWrite.writeSBML3FBCV2(mod, 'iMM904_edited.xml')

然后在你的文本编辑器中打开模型,你会看到所有的注解都被添加进去了:

<fbc:geneProduct metaid="meta_G_YLR189C" fbc:id="G_YLR189C" fbc:label="YLR189C">
  <notes>
    <html:body>This is my favorite gene</html:body>
  </notes>
  <annotation>
    <listOfKeyValueData xmlns="http://pysces.sourceforge.net/KeyValueData">
      <data id="arbitrary key" value="arbitrary value"/>
      <data id="last_modified_by" value="Vinz"/>
    </listOfKeyValueData>
    <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#" xmlns:vCard4="http://www.w3.org/2006/vcard/ns#" xmlns:bqbiol="http://biomodels.net/biology-qualifiers/" xmlns:bqmodel="http://biomodels.net/model-qualifiers/">
      <rdf:Description rdf:about="#meta_G_YLR189C">
        <bqbiol:is>
          <rdf:Bag>
            <rdf:li rdf:resource="http://identifiers.org/uniprot/Q06321"/>
            <rdf:li rdf:resource="http://identifiers.org/uniprot/P12345"/>
          </rdf:Bag>
        </bqbiol:is>
        <bqbiol:isEncodedBy>
          <rdf:Bag>
            <rdf:li rdf:resource="http://identifiers.org/ncbigene/850886"/>
            <rdf:li rdf:resource="http://identifiers.org/sgd/S000004179"/>
          </rdf:Bag>
        </bqbiol:isEncodedBy>
      </rdf:Description>
    </rdf:RDF>
  </annotation>
</fbc:geneProduct>

推荐阅读