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()
You forgot to ask a question.
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.