Example programs using libSBML

The following are example programs demonstrating the use of different libSBML API calls. The programs are available in different programming languages. (Due to limited resources, not all programs are available in all programming languages supported by libSBML.) Further below, you can also find examples of using SBML Level 3 packages.

Simple programs

Name Description C C++ C# Java JS Perl PHP Python R Ruby
echoSBML Echoes (and in the process, pretty prints) an SBML model.
readSBML A simple command-line program that reads an SBML file and prints some statistics about it.
printSBML Prints information about the top-level model in the given SBML file.
printSupported Prints the supported SBML Levels and Versions for this copy of libSBML.
printRegisteredPackages Prints the SBML Level 3 packages registered/installed in this copy of libSBML.

More advanced programs

Name Description C C++ C# Java JS Perl PHP Python R Ruby
addCVTerms Adds controlled vocabulary terms to a species in a model.
addCustomValidator Example of creating a custom validator to be called during validation.
addModelHistory Adds a model history to a model.
addingEvidenceCodes_1 Adds controlled vocabulary terms to a reaction in a model.
addingEvidenceCodes_2 Adds evidence codes to a species in a model.
appendAnnotation Adds annotation strings to a model and a species.
callExternalValidator Example that shows how to call an external program for validation.
convertSBML Example demonstrating how to convert SBML documents between SBML Levels.
createExampleSBML Lengthy example of creating SBML models presented in the SBML specification.
getAllElementsWithNotes Demonstrates how to use the element filter class to search the model for elements with specific attributes .
inlineFunctionDefintions Loads an SBML File and inlines all the function definitions found in the model.
printAnnotation Prints the annotation strings for each element in a given model.
printMath Prints the rule, reaction, and event formulas in a given SBML document.
printNotes Prints the notes strings for each element in a given model.
printRegisteredPackages A command-line program that prints the package plug-ins that are registered with this copy of libSBML.
printUnits A command-line program that prints information about the units of measurement used in a given SBML file.
promoteParameters Promote all local parameters in the model to global parameters.
renameSId Program that renames a specific SId and updates all references to it in a given model.
rngvalidator Example of creating a RELAX NG (RNG) validator to be called during validation.
setIdFromNames Program that renames all SIds that also have names specified. The new identifiers will be derived from the name, with all invalid characters removed.
setNamesFromIds Program that changes all objects name attribute values to match their id attribute values.
stripPackage Strips the given SBML Level 3 package from the given SBML file.
translateL3Math Translates infix formulas into MathML and vice-versa, using the SBML Level 3 parser instead of the old Level 1 parser.
translateMath Translates infix formulas into MathML and vice-versa.
unsetAnnotation Unsets the annotation for each element in the given SBML file.
unsetNotes Unsets the notes for each element in the given SBML file.
validateSBML Validates one or more SBML files.

Programs using SBML Level 3 packages

The libSBML API documentation has examples programs using libSBML plug-ins that support SBML LevelĀ 3 packages. Please consult the appropriate libSBML API documentation for your programming language.