LibSBML is an
open-source
Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use and view the source code, design documents, or content of the product. The open source model is a decentrali ...
software library
In computing, a library is a collection of resources that can be leveraged during software development to implement a computer program. Commonly, a library consists of executable code such as compiled functions and classes, or a library can ...
that provides an
application programming interface
An application programming interface (API) is a connection between computers or between computer programs. It is a type of software Interface (computing), interface, offering a service to other pieces of software. A document or standard that des ...
(API) for the
SBML
The Systems Biology Markup Language (SBML) is a representation format, based on XML, for communicating and storing computational models of biological processes. It is a free and open standard with widespread software support and a community of us ...
(Systems Biology Markup Language ) format. The libSBML library can be embedded in a
software application
Application software is any computer program that is intended for end-user use not computer operator, operating, system administration, administering or computer programming, programming the computer. An application (app, application program, sof ...
or used in a web
servlet
A Jakarta Servlet, formerly Java Servlet is a Java software component that extends the capabilities of a server. Although servlets can respond to many types of requests, they most commonly implement web containers for hosting web applicat ...
(such as one that might be served by
Apache Tomcat
Apache Tomcat (called "Tomcat" for short) is a free and open-source implementation of the Jakarta Servlet, Jakarta Expression Language, and WebSocket technologies. It provides a "pure Java" HTTP web server environment in which Java code can also ...
) as part of the application or servlet's implementation of support for reading, writing, and manipulating SBML documents and data streams. The core of libSBML is written in ISO standard
C++; the library provides API for many programming languages via interfaces generated with the help of
SWIG
The Simplified Wrapper and Interface Generator (SWIG) is an open-source software tool used to connect computer programs or libraries written in C or C++ with scripting languages such as Lua, Perl, PHP, Python, R, Ruby, Tcl, and other lang ...
.
The libSBML library is
free software
Free software, libre software, libreware sometimes known as freedom-respecting software is computer software distributed open-source license, under terms that allow users to run the software for any purpose as well as to study, change, distribut ...
released under the terms of the
GNU Lesser General Public License
The GNU Lesser General Public License (LGPL) is a free-software license published by the Free Software Foundation (FSF). The license allows developers and companies to use and integrate a software component released under the LGPL into their own ...
(LGPL) as published by the
Free Software Foundation
The Free Software Foundation (FSF) is a 501(c)(3) non-profit organization founded by Richard Stallman on October 4, 1985. The organisation supports the free software movement, with the organization's preference for software being distributed ...
; either version 2.1 of the License, or any later version. LibSBML was developed thanks to funding from many agencies, particularly the
National Institute of General Medical Sciences
The National Institute of General Medical Sciences (NIGMS) is one of the National Institutes of Health, National Institutes of Health (NIH), the principal medical research agency of the United States Federal government of the United States, Fe ...
(NIGMS, USA) as well as the
Defense Advanced Research Projects Agency
The Defense Advanced Research Projects Agency (DARPA) is a research and development agency of the United States Department of Defense responsible for the development of emerging technologies for use by the military. Originally known as the Adva ...
(DARPA, USA) under th
Bio-SPICEprogram.
Description
The Systems Biology Markup Language (
SBML
The Systems Biology Markup Language (SBML) is a representation format, based on XML, for communicating and storing computational models of biological processes. It is a free and open standard with widespread software support and a community of us ...
) is an XML-based format for encoding
computational model
A computational model uses computer programs to simulate and study complex systems using an algorithmic or mechanistic approach and is widely used in a diverse range of fields spanning from physics, engineering, chemistry and biology to economics ...
s of a sort common in
systems biology
Systems biology is the computational modeling, computational and mathematical analysis and modeling of complex biological systems. It is a biology-based interdisciplinary field of study that focuses on complex interactions within biological system ...
. Although SBML is based upon
XML
Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing data. It defines a set of rules for encoding electronic document, documents in a format that is both human-readable and Machine-r ...
, and thus software developers ''could'' support SBML using off-the-shelf XML parser libraries, libSBML offers numerous advantages that make it easier for developers to implement support for SBML in their software. The premise behind the development of libSBML is that it is more convenient and efficient for developers to start with a higher-level API tailored specifically to SBML and its distinctive features than it is to start with a plain XML parser library.
Significant features of libSBML
The following is a partial list of libSBML's features:
* ''Supports all Levels and Versions of SBML'' with common API classes and methods, thus smoothing the differences between different flavors of SBML from the perspective of the application software.
* ''Provides facilities for manipulating mathematical formulas'' in both text-string format and
MathML
Mathematical Markup Language (MathML) is a pair of mathematical markup languages, an application of XML for describing mathematical notations and capturing both its structure and content. Its aim is to natively integrate mathematical formulae ...
2.0 format, as well as the ability to interconvert mathematical expressions between these forms. Internally, libSBML uses familiar
Abstract Syntax Tree
An abstract syntax tree (AST) is a data structure used in computer science to represent the structure of a program or code snippet. It is a tree representation of the abstract syntactic structure of text (often source code) written in a formal ...
s (ASTs) to represent formulas, and provides AST-oriented methods for calling applications.
* ''Performs validation'' of XML and SBML 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.
* ''Offers support for dimensional analysis and unit checking''. LibSBML implements a thorough system for dimensional analysis and checking units of quantities in a model.
* ''Provides facilities for the creation and manipulation of SBML annotations and notes''. These have a specific format dictated by the SBML specifications. The formats and standards supported by libSBML include
MIRIAM
Miriam (, lit. ‘rebellion’) is described in the Hebrew Bible as the daughter of Amram and Jochebed, and the older sister of Moses and Aaron. She was a prophetess and first appears in the Book of Exodus.
The Torah refers to her as "Miria ...
(Minimal Information Requested in the Annotation of a Model) and SBO (the
Systems Biology Ontology).
* ''Supports transparently reading and writing compressed files'' in the
ZIP,
GZIP
gzip is a file format and a software application used for file compression and decompression. The program was created by Jean-loup Gailly and Mark Adler as a free software replacement for the compress program used in early Unix systems, and ...
and
BZIP
bzip2 is a free and open-source file compression program that uses the Burrows–Wheeler algorithm. It only compresses single files and is not a file archiver. It relies on separate external utilities such as tar for tasks such as handli ...
formats.
* ''Provides interfaces for the
C,
C++,
C#,
Java
Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
,
Python
Python may refer to:
Snakes
* Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia
** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia
* Python (mythology), a mythical serpent
Computing
* Python (prog ...
,
Perl
Perl is a high-level, general-purpose, interpreted, dynamic programming language. Though Perl is not officially an acronym, there are various backronyms in use, including "Practical Extraction and Reporting Language".
Perl was developed ...
,
MATLAB
MATLAB (an abbreviation of "MATrix LABoratory") is a proprietary multi-paradigm programming language and numeric computing environment developed by MathWorks. MATLAB allows matrix manipulations, plotting of functions and data, implementat ...
,
Octave
In music, an octave (: eighth) or perfect octave (sometimes called the diapason) is an interval between two notes, one having twice the frequency of vibration of the other. The octave relationship is a natural phenomenon that has been referr ...
, and
Ruby
Ruby is a pinkish-red-to-blood-red-colored gemstone, a variety of the mineral corundum ( aluminium oxide). Ruby is one of the most popular traditional jewelry gems and is very durable. Other varieties of gem-quality corundum are called sapph ...
'' programming languages. The C and C++ interfaces are implemented natively; the C#, Java, Perl, Python, and Ruby interfaces are implemented using
SWIG
The Simplified Wrapper and Interface Generator (SWIG) is an open-source software tool used to connect computer programs or libraries written in C or C++ with scripting languages such as Lua, Perl, PHP, Python, R, Ruby, Tcl, and other lang ...
, the Simplified Wrapper Interface Generator; and the MATLAB and Octave interfaces are implemented through custom hand-written code.
* ''Provides many convenience methods'', such as for obtaining a count of the number of boundary condition species, determining the modifier species of a reaction (assuming the reaction provides kinetics), constructing the stoichiometric matrix for all reactions in a model, and more.
Manipulation of mathematical formulas
Some further explanations may be warranted concerning libSBML's support for working with mathematical formulas. 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
Mathematical Markup Language (MathML) is a pair of mathematical markup languages, an application of XML for describing mathematical notations and capturing both its structure and content. Its aim is to natively integrate mathematical formulae ...
.
As mentioned above, LibSBML provides an abstraction for working with mathematical expressions in both text-string and MathML form: Abstract Syntax Trees (ASTs).
Abstract Syntax Tree
An abstract syntax tree (AST) is a data structure used in computer science to represent the structure of a program or code snippet. It is a tree representation of the abstract syntactic structure of text (often source code) written in a formal ...
s 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.
Dependencies
LibSBML requires a separate library to do low-level read/write operations on XML. It can use any one of three XML parser libraries:
Xerces,
expat
An expatriate (often shortened to expat) is a person who resides outside their native country.
The term often refers to a professional, skilled worker, or student from an affluent country. However, it may also refer to retirees, artists and ...
or
libxml2
libxml2 is a software library for parsing XML documents. It is also the basis for the libxslt library which processes XSLT-1.0 stylesheets.
Description
Written in the C programming language, libxml2 provides bindings to C++, Ch, XSH, ...
. Users can specify which library they wish to use at libSBML compilation time. LibSBML hides the differences between these parser libraries behind an abstraction layer; it seamlessly uses whichever library against which a given instance of libSBML has been compiled. (However, released binary distributions of libSBML all make use of the
libxml2
libxml2 is a software library for parsing XML documents. It is also the basis for the libxslt library which processes XSLT-1.0 stylesheets.
Description
Written in the C programming language, libxml2 provides bindings to C++, Ch, XSH, ...
library.)
Usage
LibSBML uses software objects (i.e., instances of
classes) that correspond to SBML components, with
member variable
In object-oriented programming
Object-oriented programming (OOP) is a programming paradigm based on the concept of '' objects''. Objects can contain data (called fields, attributes or properties) and have actions they can perform (called ...
s representing the attributes of the corresponding SBML objects. The libSBML API is constructed to provide an intuitive way of relating SBML and the code needed to create or manipulate it with a class hierarchy that mimics the SBML structure. More information about the libSBML objects is available in th
libSBML API documentation
Reading and writing SBML
LibSBML enables reading from and writing to either files or strings. Once an SBML document is read, libSBML stores the SBML content in an SBMLDocument object. This object can be written out again later. The following is an example written in
Python
Python may refer to:
Snakes
* Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia
** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia
* Python (mythology), a mythical serpent
Computing
* Python (prog ...
:
>>> import libsbml
>>>
>>> # read a document
>>> doc = libsbml.readSBMLFromFile(filename)
>>> doc = libsbml.readSBMLFromString(string)
>>>
>>> # helper function that takes either a string
>>> # or filename as argument
>>> doc = libsbml.readSBML(filename)
>>> doc = libsbml.readSBML(string)
>>>
>>> # write a document
>>> libsbml.writeSBMLToFile(doc, filename)
True
>>>
>>> libsbml.writeSBMLToString(doc)
'\n
\n
\n
\n'
Creating and manipulating SBML
The libSBML API allows easy creation of objects and subobjects representing SBML elements and the subelements contained within them. The following is an example written in
C++:
void createSBML()
Accessing attributes
Each component in SBML has a number of attributes associated with it. These are stored as member variables of a given class, and libSBML provides functions to retrieve and query these values. The syntax of these functions is consistent throughout libSBML. The following is an example written in
Python
Python may refer to:
Snakes
* Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia
** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia
* Python (mythology), a mythical serpent
Computing
* Python (prog ...
:
>>> import libsbml
>>>
>>> # create an SBML Level 3 Version 1 document
>>> sbmlns = libsbml.SBMLNamespaces(3, 1)
>>> doc = libsbml.SBMLDocument(sbmlns)
>>>
>>> #create the model as a sub element of the document
>>> model = doc.createModel()
>>>
>>> #create a compartment as a sub element of the model
>>> compartment = model.createCompartment()
>>>
>>> # set the attributes on the compartment
>>> # note a return value of 0 indicates success
>>> compartment.setId("cell")
0
>>> compartment.setSize(2.3)
0
>>> compartment.setSpatialDimensions(3)
0
>>> compartment.setUnits("litre")
0
>>> compartment.setConstant(True)
0
>>>
>>> # get the attribute values
>>> compartment.getId()
'cell'
>>> compartment.getSpatialDimensions()
3
>>>
>>> # examine the status of the attribute
>>> compartment.isSetSize()
True
>>> compartment.getSize()
2.3
>>>
>>> #unset an attribute value
>>> compartment.unsetSize()
0
>>> compartment.isSetSize()
False
>>> compartment.getSize()
nan
See also
*
JSBML
*
libxml2
libxml2 is a software library for parsing XML documents. It is also the basis for the libxslt library which processes XSLT-1.0 stylesheets.
Description
Written in the C programming language, libxml2 provides bindings to C++, Ch, XSH, ...
*
Xerces
*
Expat
An expatriate (often shortened to expat) is a person who resides outside their native country.
The term often refers to a professional, skilled worker, or student from an affluent country. However, it may also refer to retirees, artists and ...
*
XML validation
XML validation is the process of checking a document written in XML (eXtensible Markup Language) to confirm that it is both well-formed and also "valid" in that it follows a defined structure. A well-formed document follows the basic syntactic rul ...
*
XML
Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing data. It defines a set of rules for encoding electronic document, documents in a format that is both human-readable and Machine-r ...
*
BioModels Database
BioModels is a free and open-source repository for storing, exchanging and retrieving quantitative models of biological interest created in 2006. All the models in the curated section of BioModels Database have been described in peer-reviewed scie ...
*
BioPAX BioPAX (Biological Pathway Exchange) is a RDF/OWL-based
standard language to represent biological pathways at the molecular and cellular level. Its major use is to facilitate the exchange of pathway data. Pathway data captures our understanding of ...
*
CellML
CellML is an XML based markup language for describing mathematical models. Although it could theoretically describe any mathematical model, it was originally created with the Physiome Project in mind, and hence used primarily to describe models r ...
*
MIASE
The minimum information about a simulation experiment (MIASE){{cite journal, author1=D. Waltemath , author2=Richard Adams , author3=Daniel A. Beard , author4=rank T. Bergmann , author5=Upinder S. Bhalla , author6=Randall Britten , author7=Vijayalak ...
*
MIRIAM
Miriam (, lit. ‘rebellion’) is described in the Hebrew Bible as the daughter of Amram and Jochebed, and the older sister of Moses and Aaron. She was a prophetess and first appears in the Book of Exodus.
The Torah refers to her as "Miria ...
*
Systems Biology Ontology (SBO)
*
MathML
Mathematical Markup Language (MathML) is a pair of mathematical markup languages, an application of XML for describing mathematical notations and capturing both its structure and content. Its aim is to natively integrate mathematical formulae ...
References
{{Reflist, 2
External links
libSBML Home Page
C++ libraries
Free software programmed in C++
Software using the GNU Lesser General Public License
Cross-platform free software
Free computer libraries
Free science software
Articles with example Python (programming language) code