libSBML C++ API 5.10.0
LibSBML is an application programming interface (API) library for reading, writing and manipulating files and data streams containing SBML content. Developers can embed the library in their applications, saving themselves the work of implementing their own parsing, manipulation and validation software. At the API level, the library provides the same interface to data structures independently of whether the model originated in SBML Level 1, 2 or 3. The library currently also offers the ability to translate many models between SBML Levels and Versions.
LibSBML is written in ISO standard C++ and C and is highly portable. It is
currently supported on the Linux, Mac OS X, and Microsoft Windows
operating systems, but it has been known to run under FreeBSD and Solaris
with little or no modifications. The library provides language bindings
for C, C++, C#, Java, Python, Perl, MATLAB, Octave, and Ruby. The package
is distributed in both source-code form and as precompiled dynamic
libraries for the Microsoft Windows, Linux and Apple Mac OS X
operating systems; they are available from the
project on SourceForge.net.
One of the features of libSBML is its facilities for manipulating mathematical formulas supporting differences in representation between SBML Level 1 and higher Levels of SBML. LibSBML provides an API that allows working with formulas in both text-string and MathML form, and to interconvert mathematical expressions between these forms. The utility of this facility extends beyond converting between SBML Level 1 and other Levels. Many software packages provide users with the ability to express formulas for such things as reaction rate expressions, and these packages' interfaces often let users type in the formulas directly as text strings. LibSBML saves application programmers the work of developing formula manipulation and translation functionality. It makes it possible to translate those formula strings directly into Abstract Syntax Trees (ASTs), manipulate them using AST operations, and write them out in the MathML format of SBML Levels 2 and 3.
Another feature of libSBML is the validation it performs on SBML inputs at the time of parsing files and data streams. This helps verify the correctness of models in a way that goes beyond simple syntactic validation. Still another invaluable feature of libSBML is the domain-specific operations it provides beyond simple SBML-specific accessor facilities. Examples of such operations include obtaining a count of the number of boundary condition species, determining the modifier species of a reaction (assuming the reaction provides kinetics), and constructing the stoichiometric matrix for all reactions in a model.
Some of the other features of libSBML include the following:
<sbml>element (logging a warning).
getVersion()methods, among other things.
<annotation>elements by providing parsing and manipulation functions that treat the annotations in terms of XMLNode objects implemented by the new XML layer. Both ModelHistory and CVTerm follow the general libSBML format of providing getters and setters for each variable stored within the class.
.bz2, libSBML will automatically uncompress the file upon reading it. Similarly, if the file to be written has one of those extensions, libSBML will write it out in compressed form. (The compression library incorporated by libSBML is MiniZip 1.01e, written by Gilles Vollant and made freely available for all uses including commercial applications.)
In SBML Level 1, mathematical formulas are represented as text strings using a C-like syntax. This representation was chosen because of its simplicity, widespread familiarity and use in applications such as Gepasi and Jarnac, whose authors contributed to the initial design of SBML. In SBML Levels 2 and 3, there was a need to expand the mathematical vocabulary of Level 1 to include additional functions (both built-in and user-defined), mathematical constants, logical operators, relational operators and a special symbol to represent time. Rather than growing the simple C-like syntax into something more complicated and esoteric in order to support these features, and consequently having to manage two standards in two different formats (XML and text string formulas), SBML Levels 2 and 3 leverage an existing standard for expressing mathematical formulas, namely the content portion of MathML.
LibSBML provides an abstraction for working with mathematical expressions in both text-string and MathML form: Abstract Syntax Trees (ASTs). Abstract Syntax Trees are well-known in the computer science community; they are simple recursive data structures useful for representing the syntactic structure of sentences in certain kinds of languages (mathematical or otherwise). Much as libSBML allows programmers to manipulate SBML at the level of domain-specific objects, regardless of SBML Level or version, it also allows programmers to work with mathematical formula at the level of ASTs regardless of whether the original format was C-like infix or MathML. LibSBML goes one step further by allowing programmers to work exclusively with infix formula strings and instantly convert them to the appropriate MathML whenever needed.