The JigCell SBML parser is a complete library written in Java for reading, writing, and working with SBML Level 2 files. Download the JigCell SBML parser as part of the JigCell distribution. The source code and instructions for building the JigCell SBML parser are avilable from the same location.
The source code for the JigCell SBML parser is divided into several packages.
jigcell.sbml2.mathpackage contains classes for processing MathML.
jigcell.sbml2.jeppackage is the Java Expression Parser, which is used for handling infix expressions.
jigcell.sbml2.testspackage contains unit tests and models for the JigCell SBML parser.
SBML files are handled by the
SBMLLevel2Document class. This
class contains a static method
readDocument that gives several
ways to load SBML documents. The JigCell SBML parser is quite tolerant of
errors in SBML files, but will throw an exception from this method if it has to
give up. You can also create instances of the
class to make a new document not based on any existing model.
SBMLLevel2Document class also handles writing SBML
documents. Once you've obtained an instance of
call the method
writeDocument to write the SBML document to a
file, writer, or output stream. In addition, every SBML element has overridden
toString method to produce the SBML equivalent to that
element. Any individual SBML element can be serialized by calling
toString, even if there isn't a containing SBML document.
The methods and classes of the JigCell SBML parser have been given names
that match the SBML Level 2 specification. For example, the name of the class
that represents an SBML compartment is called
Compartment and the
outside property of a compartment is accessed by calling
setOutside. All of the settable
properties for SBML elements have similarly named pairs of get and set methods.
Readonly properties only have a get method.
When working with SBML elements, the JigCell SBML parser allows you to use
either the id of the element or a copy of the element itself. Every property in
the SBML specification that is an SBML id can be set either as a string
containing the id or with an instance of an SBML element that the id can refer
to. The species property of a species reference is represented with an SBML id.
There is a version of the
setSpecies method that takes a string,
and a version that takes an instance of the
Species class. Reverse
lookups are also supported. The plain
getSpecies method returns
the SBML id, while an overloaded version that takes an instance of a model
searches for a species with that particular id in the model. All of the search
capabilities can also be accessed directly in the
Model class to
aid locating SBML elements in a model.
Finally, the JigCell SBML parser provides other services for working with
SBML models. Many of the SBML classes support performing semantic queries that
analyze the structure of the SBML model. For instance, the
isSetByEvent methods that
can tell whether other elements in the SBML model will affect this instance.
Model class can check to see if any reactions use
local parameters, and the
UnitDefinition class has a wide variety
of methods for testing whether units are being used correctly. Every SBML
element supports an
isValid method that analyzes whether the
element will convert to legal SBML when saved.
The JigCell SBML parser also includes a tool for working with algebraic
conservation relations in an SBML model. The
ConservationRelationFinder class takes an instance of an SBML
model, and detects all of the present algebraic conservation relations. You can
also use this class to validate that a particular set of algebraic conservation
relations is consistent with the SBML model.