libsbml - python: best way to work with annotation

39 views
Skip to first unread message

Mikołaj Dziurzynski

unread,
Jul 29, 2020, 10:52:23 AM7/29/20
to sbml-interoperability
Hello,

I just started working with SBM format using python API for libSBML. The library contains a lot of useful methods but I haven't found anything for management of <sbml:annotation> tag contents. Is there maybe a library or a software build for managing these annotations in more 'programmatic' way, than just string management, as shown in this libSBML tutorial http://sbml.org/Software/libSBML/5.18.0/docs/python-api/append_annotation_8py-example.html ?

In my case I have a lot of species, reactions and geneProducts to annotate with links to different databases. I would like to make something like this:

<reaction id="R_O2thr" fast="false" reversible="true" name="O2 transport (diffusion), chloroplast" metaid="R_O2thr" sboTerm="SBO:0000185" fbc:upperFluxBound="cobra_default_ub" fbc:lowerFluxBound="cobra_default_lb">
 
<listOfReactants>
   
<speciesReference species="M_o2_c" stoichiometry="1" constant="true"/>
 
</listOfReactants>
 
<listOfProducts>
   
<speciesReference species="M_o2_h" stoichiometry="1" constant="true"/>
 
</listOfProducts>
</reaction>

into something like this:

<reaction id="R_O2thr" fast="false" reversible="true" name="O2 transport (diffusion), chloroplast" metaid="R_O2thr" sboTerm="SBO:0000185" fbc:upperFluxBound="cobra_default_ub" fbc:lowerFluxBound="cobra_default_lb">
 
<sbml:annotation xmlns:sbml="http://www.sbml.org/sbml/level3/version1/core">
   
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
     
<rdf:Description rdf:about="#R_O2thr">
       
<bqbiol:is xmlns:bqbiol="http://biomodels.net/biology-qualifiers/">
         
<rdf:Bag>
           
<rdf:li rdf:resource="http://identifiers.org/bigg.reaction/O2thr"/>
           
<rdf:li rdf:resource="http://identifiers.org/biocyc/META:TRANS-RXN0-474"/>
           
<rdf:li rdf:resource="http://identifiers.org/metanetx.reaction/MNXR102090"/>
           
<rdf:li rdf:resource="http://identifiers.org/seed.reaction/rxn09641"/>
           
<rdf:li rdf:resource="http://identifiers.org/seed.reaction/rxn05468"/>
           
<rdf:li rdf:resource="http://identifiers.org/seed.reaction/rxn09031"/>
           
<rdf:li rdf:resource="http://identifiers.org/seed.reaction/rxn09032"/>
           
<rdf:li rdf:resource="http://identifiers.org/seed.reaction/rxn09734"/>
         
</rdf:Bag>
       
</bqbiol:is>
     
</rdf:Description>
   
</rdf:RDF>
 
</sbml:annotation>
 
<listOfReactants>
   
<speciesReference species="M_o2_c" stoichiometry="1" constant="true"/>
 
</listOfReactants>
 
<listOfProducts>
   
<speciesReference species="M_o2_h" stoichiometry="1" constant="true"/>
 
</listOfProducts>
</reaction>


I will be very grateful for any recommendations and tips and tricks:)

Best,
Mikolaj

Frank T. Bergmann

unread,
Jul 29, 2020, 10:56:40 AM7/29/20
to sbml-interoperability
Hello Mikolaj, 

I came across the same issue some time ago. And solved it with the script attached. Basically i was adding metadata information to an existing model, from an excel file. Maybe it can help you get started. You will see how to use the CVTerms and add them to an element, or update existing ones and just add further information to the bag. 

cheers
Frank
add_metadata_to_file.py

Mikołaj Dziurzynski

unread,
Jul 29, 2020, 4:19:03 PM7/29/20
to sbml-interoperability
Hi Frank,

thank you for the script, it helps a lot. I also haven't looked inside get/setCVTerms methods and so thank you for pointing me there as well.

Best,
Mikolaj

Matthias König

unread,
Jul 29, 2020, 8:02:06 PM7/29/20
to sbml-inter...@googlegroups.com
Hi Mikolaj,

if you interested in annotating existing models you could use the following

Best Matthias

--
You received this message because you are subscribed to the Google Groups "sbml-interoperability" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sbml-interoperab...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sbml-interoperability/43d33a7e-7430-46a8-beb1-24e2222c1d83o%40googlegroups.com.


--
Matthias König, PhD.
Junior Group Leader LiSyM - Systems Medicine of the Liver
Humboldt Universität zu Berlin, Institute of Biology, Institute for Theoretical Biology
  https://livermetabolism.com
koni...@googlemail.com
https://github.com/matthiaskoenig
Tel: +49 30 2093 98435

Mikołaj Dziurzynski

unread,
Jul 30, 2020, 3:47:02 AM7/30/20
to sbml-inter...@googlegroups.com
Hi Matthias,

That is exactly what I was looking for! Thank you!

Best,
Mikolaj

Reply all
Reply to author
Forward
0 new messages