— the global portal for all things SBML



Language: Java
Summary Library for exploiting MIRIAM-compliant annotations in SBML.
Author(s) Neil Swainston (neil.swainston AT
Needs libSBML version 4


This is an ever-growing collection of classes that read and write MIRIAM-compliant SBML annotations. Over time, they may actually crystallise into a number of useful applications. However, the point of them isn't the applications that exist currently but the ones that can be built with them in future.

Some of the applications under development were explained at the meeting in Cambridge in March 2009. The associated presentation is available at slideshare.

An application note has been published in Bioinformatics.

libAnnotationSBML: a library for exploiting SBML annotations. Swainston N, Mendes P. Bioinformatics (2009) 25(17):2292-2293.

Installation instructions

  1. Install libSBML 4 if you have not already done so.
  2. Find a location in your file system where you want to copy the files.
  3. Copy the SVN link and use it in your SVN client to check out a copy of the files.
  4. The associated code will compile if all of the jars in the lib directory AND sbmlj.jar are in the classpath.


An example of writing and reading annotations using Species would be as follows. However, the SbmlUtils class works on any Sbase.

import java.util.*;
import org.sbml.libsbml.*;
import org.mcisb.ontology.*;
import org.mcisb.ontology.chebi.*;
import org.mcisb.sbml.*;

 * @author Neil Swainston
public class LibAnnotationSBMLExample
    System.loadLibrary( "sbmlj" );
   * @param args
   * @throws Exception 
  public static void main( String[] args ) throws Exception
    // Create an SBML Species.
    Species species = new Species( 2, 4 );
    species.setId( "id1" );
    // Use the OntologyUtils class to generate a OntologyTerm representing CHEBI:15377.
    OntologyTerm chebiTerm = OntologyUtils.getInstance().getOntologyTerm( Ontology.CHEBI, "CHEBI:15377" );
    // Use the SbmlUtils class to add the OntologyTerm to the Species.
    SbmlUtils sbmlUtils = new SbmlUtils();
    sbmlUtils.addOntologyTerm( species, chebiTerm, libsbmlConstants.BIOLOGICAL_QUALIFIER, libsbmlConstants.BQB_IS );
    // Print the now annotated Species out to screen.
    System.out.println( species.toSBML() );
    // Read the OntologyTerms associated with a species.
    // The terms are returned as a Map of OntologyTerms to predicates.
    Map<OntologyTerm,int[]> ontologyTermToPredicates = sbmlUtils.getOntologyTerms( species );
    for( Map.Entry<OntologyTerm,int[]> entry : ontologyTermToPredicates.entrySet() )
      OntologyTerm currentOntologyTerm = entry.getKey();
      int[] predicates = entry.getValue();
      // Uses ChEBI webservice to determine that CHEBI:15377 is 'water'.
      System.out.println( "Name: " + currentOntologyTerm.getName() );

      // Uses ChEBI webservice to determine that water's formula is H2O. No kidding!!
      System.out.println( "Formula: " + ( (ChebiTerm)currentOntologyTerm ).getFormula() ); 
      System.out.println( predicates[ 0 ] ); // libsbmlConstants.BIOLOGICAL_QUALIFIER
      System.out.println( predicates[ 1 ] ); // libsbmlConstants.BQB_IS

Known problems/issues

Continually in development, so realistically, one or two. But hopefully not many.

Licensing terms and distribution

This software is released under the terms of the Academic Free License ("AFL") v3.0.

Retrieved from ""

This page was last modified 16:47, 3 May 2010.

Please use our issue tracking system for any questions or suggestions about this website. This page was last modified 16:47, 3 May 2010.