libSBML in R: How to get Species metaIds

34 views
Skip to first unread message

hypo ks

unread,
Mar 18, 2022, 9:53:31 AM3/18/22
to sbml-discuss
Hi

I am using the libSBML package in R and trying to get the species reference/database identifiers but do not know which function i can use to retrieve the mapping.
---
      <species boundaryCondition="false" compartment="in" constant="false" hasOnlySubstanceUnits="true" id="_2_oxoglutarate__in_" metaid="_2_oxoglutarate__in_" name="2-oxoglutarate">
        <annotation>
          <rdf:RDF>
            <rdf:Description rdf:about="#_2_oxoglutarate__in_">
              <bqmodel:is>
                <rdf:Bag>
                  <rdf:li rdf:resource="http://identifiers.org/pubchem.substance/164533"/>
                </rdf:Bag>
              </bqmodel:is>
              <bqmodel:is>
----

# R code snippet:

  document  = readSBML(xml_file);
  model = SBMLDocument_getModel(document);

  num_species = Model_getNumSpecies(model)

  for (i in seq(1,num_species) {
       species = Model_getSpecies(model, i);
       id = Species_getId(species);
       # what function to use to get rdf:resource id?#
    }

-----

Any advice would be appreciated. Thank you!

Frank Bergmann

unread,
Mar 21, 2022, 4:46:30 AM3/21/22
to sbml-discuss
This might be best discuss in the libSBML Group (https://groups.google.com/g/libsbml-development), but here just a snippet that would explain the basics: 

---

document <- readSBML(xml_file);
model <- document$getModel();
num_species <- model$getNumSpecies()

for (i in seq(0,num_species-1)) { # indices in the libSBML start at 0
  species <- model$getSpecies(i);
  id = species$getId();

 
  # what function to use to get rdf:resource id?#
  num_terms <- species$getNumCVTerms()
  for (j in seq(0,num_terms-1))
  {
    term <- species$getCVTerm(j)
    num_resources <- term$getNumResources()
    for (k in seq(0,num_resources-1))
    {
      print(term$getResourceURI(k))
    }
  }
 
  # alternatively you can handle the RDF yourself using
  annotations <- species$getAnnotationString()
  #...
}

---

best
Frank


Reply all
Reply to author
Forward
0 new messages