LibSBML comes with a selection of complete Java example programs. They can
be found in the libSBML directory named examples/java
located at
the top level of the libSBML distribution. The following is a list of the
example programs provided:
echoSBML.java
: Echos (and in
the process, pretty prints) an SBML model.readSBML.java
: A simple
command-line program that reads an SBML file and prints some statistics
about it.printSBML.java
: Prints
information about the top-level model in the given SBML file.printRegisteredPackages.java
:
Prints the SBML Level 3 packages registered/installed in this copy of
libSBML.printsupported.java
:
Prints the supported SBML Levels and Versions for this copy of libSBML.addCVTerms.java
:
Adds controlled vocabulary terms to a species in a model.addCustomValidator.java
:
Example of creating a custom validator to be called during validation.addModelHistory.java
:
Adds a model history to a model.addingEvidenceCodes_1.java
:
Adds controlled vocabulary terms to a reaction in a model.addingEvidenceCodes_2.java
:
Adds evidence codes to a species in a model.appendAnnotation.java
:
Adds annotation strings to a model and a species.callExternalValidator.java
:
Example that shows how to call an external program for validation.convertSBML.java
:
Example demonstrating how to convert SBML documents between SBML Levels.createExampleSBML.java
:
Lengthy example of creating SBML models presented in the SBML specification.getAllElementsWithNotes.java
:
Demonstrates how to use the element filter class to search the model
for elements with specific attributes .printAnnotation.java
:
Prints the annotation strings for each element in a given model.printMath.java
:
Prints the rule, reaction, and event formulas in a given SBML document.printNotes.java
:
Prints the notes strings for each element in a given model.printRegisteredPackages.java
:
A command-line program that prints the package plug-ins that are
registered with this copy of libSBML.printUnits.java
:
A command-line program that prints information about the units
of measurement used in a given SBML file.promoteParameters.java
:
Promote all local parameters in the model to global parameters.setIdFromNames.java
:
Program that renames all SIds that also have names specified. The new
identifiers will be derived from the name, with all invalid characters removed.stripPackage.java
:
Strips the given SBML Level 3 package from the given SBML file.translateMath.java
:
Translates infix formulas into MathML and vice-versa.unsetAnnotation.java
:
Unsets the annotation for each element in the given SBML file.unsetNotes.java
:
Unsets the notes for each element in the given SBML file.validateSBML.java
:
Validates one or more SBML files.The following examples use specific libSBML plug-ins to support SBML Level 3 packages. The use of these packages requires your copy of libSBML to have been configured to enable the appropriate plug-in. The default installation of libSBML comes with the packages below already enabled, but beware that if you built libSBML from source code and disabled one or more of these packages, then their features will not be available.
The Flux Balance Constraints package has the nickname “fbc”. The libSBML classes that implement this package are marked with the symbol fbc in the libSBML documentation.
fbc_example1.java
:
Simple example of writing a model that uses the SBML Level 3 Flux
Balance Constraints package.convertCobraToFbc.java
:
Example of converting a COBRA-style SBML Level 2 model to SBML
Level 3 using the Flux Balance Constraints package.convertFbcToCobra.java
:
Example of converting an SBML Level 3 model using the Flux
Balance Constraints package to a COBRA-style SBML Level 2 model.The Hierarchical Model Composition package has the nickname “comp”. The libSBML classes that implement this package are marked with the symbol comp in the libSBML documentation.
flattenModel.java
:
Model flattening example.The Layout package has the nickname “layout”. The libSBML classes that implement this package are marked with the symbol layout in the libSBML documentation.
layout_example1.java
:
An example layout.layout_example1_L3.java
:
An SBML Level 3 example.
The Qualitative Models package has the nickname “qual”. The libSBML classes that implement this package are marked with the symbol qual in the libSBML documentation.
qual_example1.java
:
An example of creating a model using SBML Level 3 Qualitative Models.