Read SBML Documents

Parse an SBML Document

The easiest way to parse SBML documents is using the validator. It will validate the file and provides you with the occurred error if the document is not valid. However, if the document is valid you get the SBML model for free:

// create a SBML validator
SBMLValidator validator = new SBMLValidator ();

// is that document valid?
if (!validator.validate (document))
   // if not: print the error (which is an exception)
   System.err.println (validator.getError ());

// get the document
SBMLDocument doc = validator.getDocument ();

You may provide the document as an XML string, a File object pointing to a file on the disk, a URL to a model on the internet, or an already parsed TreeDocument. Please read ModelRetriever to learn how to restrict the access to local/remote files. (see also source:src/test/java/de/unirostock/sems/ParseExample.java)

Last modified 3 years ago Last modified on Mar 5, 2014, 2:33:26 PM
authorship