Parse CV Terms
1
0
Entering edit mode
7.3 years ago
Natasha ▴ 40

Dear All,

I am trying to retrieve the EC numbers from an SBML file.The file contains the annotations of the identifiers.

from libsbml import SBMLReader
import sys

def parse(filename):
'''Parses SBML file.'''
values = []
reader = SBMLReader()
document = reader.readSBML("H:\Biomodels\Recon_2_2.xml")
model = document.getModel()

for reaction in model.getListOfReactions():
    reac_values = [reaction.getId()]
    cv_terms = reaction.getCVTerms()

    if cv_terms:
        for cv_term in cv_terms:
            for idx in range(cv_term.getNumResources()):
                uri = cv_term.getResourceURI(idx)

                if 'ec-code' in uri or 'kegg.reaction' in uri:
                    reac_values.append(uri)

    values.append(reac_values)

return values


def main():
'''main method.'''
'''name  = open("H:\Biomodels\out.txt",'w')'''
'''sys.stdout = name'''
for values in parse(‪'recon2_2.xml'):


    print ('\t'.join(values))



if __name__ == '__main__':
main()
software error • 2.1k views
ADD COMMENT
2
Entering edit mode

You forgot to ask a question.

ADD REPLY
0
Entering edit mode

However,when I attempt to parse this file BMID000000101155 ,available on biomodels database,only the kegg.reaction i.e reaction id's are parsed.The xml file contains the ec numbers.Could you please help me to find why the EC numbers aren't parsed ? Should I use any other alternative in place of 'ec-code' in uri ?

PS:the code works for MODEL1603150001

I would be grateful for any help you can offer.

ADD REPLY
0
Entering edit mode
7.3 years ago

I don't know biomodels but the following xslt stylesheet seems to work (?) for the two cases I've tested.

e.g:

$ curl -s "https://www.ebi.ac.uk/biomodels-main/download?mid=BMID000000101155&anno=urn" | xsltproc tr.xsl - | sort| uniq 
R00006
R00014
R00200
R00226
R00235
R00431
R00538
R00623
R00625
....

$ curl -s  "https://www.ebi.ac.uk/biomodels-main/download?mid=MODEL1603150001&anno=urn" | xsltproc tr.xsl - | sort| uniq
R01512
R01518
ADD COMMENT
0
Entering edit mode

Thanks a lot for the help.The python script works for both the cases when I attempt to get the KEGG Reaction ID.I am facing issues in obtaining ec numbers from the file.(ec-code in uri works just for MODEL1603150001) Could you please help me with modifying the xslt stylesheet in order to obtain the EC numbers?

ADD REPLY
0
Entering edit mode

Hi Pierre,

If you don't mind, could you please tell me how to run the above xsl stylesheet and generate the results.I copied the code and generated a .xsl file.Using the input file as MODEL1603150001.xml, when I run with XSL Transformation in eclipse,the xsl file appears to have errors.

Any help would be appreciated.

ADD REPLY
0
Entering edit mode

the biostars formatting engine has messed-up my xslt code, I've replaced it with a gist. It should be ok now.

ADD REPLY
0
Entering edit mode

Thank you so much,the code works on eclipse now.I am able to obtain the ec numbers when kegg.reaction is replaced with ec-code.

In order to display both kegg.reaction and ec-code I use the OR operator.

<xsl:if test="@rdf:resource">
<xsl:choose>
<xsl:when test="starts-with(@rdf:resource,'urn:miriam:ec-code:' or 'urn:miriam:kegg.reaction')">
<xsl:value-of select="substring-after(@rdf:resource,'urn:miriam:ec-code:' or 'urn:miriam:kegg.reaction')"/>
<xsl:text>
</xsl:text>
</xsl:when>
<xsl:when test="starts-with(@rdf:resource,'&lt;a href=" http:="" identifiers.org="" ec-code="" 'or"="" rel="nofollow">http://identifiers.org/ec-code/'or 'http://identifiers.org/kegg.reaction/')">
<xsl:value-of select="substring-after(@rdf:resource,'&lt;a href=" http:="" identifiers.org="" ec-code="" '"="" rel="nofollow">http://identifiers.org/ec-code/' or 
 'http://identifiers.org/kegg.reaction/')"/>

<xsl:text>
</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:if>

This doesn't work for some reason.I would like to view the output file in this form,

R01058 2.3.1.1
R01177 4.3.2.2

Am I missing something?

ADD REPLY

Login before adding your answer.

Traffic: 2447 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6