how to parse the annotation of the (species ,compartments) of SBML using libsbml

24 views
Skip to first unread message

cruise h

unread,
Mar 12, 2021, 6:21:33 AM3/12/21
to sbml-discuss
I know i shall send this to libsbml-discuss, but i can't join it. Sorry for the inconvient i have caused.
I have use RDFanootation in the libsbml ,but it only return a libsbml-history class, and i can't  get the information i need?
Can experts like you to tell me how to parse the annotation and get the databese URL for species and compartment?
Thankyou!

cruse hu

unread,
Mar 12, 2021, 8:12:23 AM3/12/21
to sbml-d...@googlegroups.com
more details, I use libsbml.RDFAnnotationParser_parseRDFAnnotation(a)
It returns:
<libsbml.ModelHistory proxy of <Swig Object of type 'ModelHistory_t *' at 0x0000022D7DFD79C0> >
It just returns a class of model history,  apparently, i can't read the annotation by it.

cruise h <howitwo...@gmail.com> 于2021年3月12日周五 下午7:21写道:
--
You received this message because you are subscribed to a topic in the Google Groups "sbml-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sbml-discuss/Y_3S0gk--P0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sbml-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sbml-discuss/c0bce674-774f-4121-b40b-fd294b40ccf6n%40googlegroups.com.

Frank Bergmann

unread,
Mar 12, 2021, 9:27:01 AM3/12/21
to sbml-d...@googlegroups.com
You have not indicated what programming language you use, so i hope it was python. LibSBML does all the work for the SBML supported MIRIAM subset for you, so an example for printing all resources for species / reactions could look like this: 

```
import libsbml


def print_terms(element):
  """prints resources and qualifier for sbase element"""
  num_terms = element.getNumCVTerms()
  for i in range(num_terms):
    term = element.getCVTerm(i)
    if term.getQualifierType() == libsbml.BIOLOGICAL_QUALIFIER:
      print('element qualifier is bq_{0}'.format(libsbml.BiolQualifierType_toString(term.getBiologicalQualifierType())))
    else:
      print('element qualifier is model_{0}'.format(libsbml.ModelQualifierType_toString(term.getBiologicalQualifierType())))
    num_resources = term.getNumResources()
    for j in range(num_resources):
      print('  {0}'.format(term.getResourceURI(j)))



doc = libsbml.readSBMLFromFile('BIOMD0000000001.xml')
model = doc.getModel()

for i in range(model.getNumSpecies()):
  species = model.getSpecies(i)
  print('annotatiosn for species {0}'.format(species.getId()))
  print_terms(species)
 
for i in range(model.getNumReactions()):
  reaction = model.getReaction(i)
  print('annotations for reaction {0}'.format(reaction.getId()))
  print_terms(reaction)

```

cheers
Frank


You received this message because you are subscribed to the Google Groups "sbml-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sbml-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sbml-discuss/CALSwGsFhed76jtyupwKaDZtuMOu9EWphnPGCPG%3DjZfOGoKg8iA%40mail.gmail.com.

Frank Bergmann

unread,
Mar 12, 2021, 9:29:29 AM3/12/21
to sbml-d...@googlegroups.com
and of course it should have been term.getModelQualifierType() in the else branch. 

We'll try to add an example in a future version of libSBML. 

cheers
Frank

cruse hu

unread,
Mar 12, 2021, 9:23:29 PM3/12/21
to sbml-d...@googlegroups.com
Yes, i use libsbml python API. It works! Thank you very much.

Frank Bergmann <frank.thom...@gmail.com> 于2021年3月12日周五 下午10:29写道:
Reply all
Reply to author
Forward
0 new messages