libSBML Perl API  libSBML 5.10.0 Perl API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SBMLReader.h File Reference

Reads an SBML Document into memory. More...

Include dependency graph for SBMLReader.h:
This graph shows which files directly or indirectly include this file:

Classes

class  SBMLReader
 {core} Methods for reading SBML from files and text strings. More...
 

Functions

SBMLDocument_treadSBML (const char *filename)
 Reads an SBML document from the given file filename. More...
 
SBMLDocument_treadSBMLFromFile (const char *filename)
 Reads an SBML document from the given file filename. More...
 
SBMLDocument_treadSBMLFromString (const char *xml)
 Reads an SBML document from the given XML string xml. More...
 

Detailed Description

Reads an SBML Document into memory.

Author
Ben Bornstein

Function Documentation

SBMLDocument_t* readSBML ( const char *  filename)

Reads an SBML document from the given file filename.

If filename does not exist, or it is not an SBML file, an error will be logged in the error log of the SBMLDocument object returned by this method. Calling programs can inspect this error log to determine the nature of the problem. Please refer to the definition of SBMLDocument_t for more information about the error reporting mechanism.

SBMLReader_t *sr;
SBMLDocument_t *d;

sr = SBMLReader_create();

d = SBMLReader_readSBML(reader, filename);

if (SBMLDocument_getNumErrors(d) > 0)
{
if (XMLError_getId(SBMLDocument_getError(d, 0)) == SBML_READ_ERROR_FILE_NOT_FOUND)
if (XMLError_getId(SBMLDocument_getError(d, 0)) == SBML_READ_ERROR_NOT_SBML)
}

If the filename ends with .gz, the file will be read as a gzip file. Similary, if the filename ends with .zip or .bz2, the file will be read as a zip or bzip2 file, respectively. Otherwise, the fill will be read as an uncompressed file. If the filename ends with .zip, only the first file in the archive will be read if the zip archive contains two or more files.

To read a gzip/zip file, underlying libSBML needs to be linked with zlib at compile time. Also, underlying libSBML needs to be linked with bzip2 to read a bzip2 file. File unreadable error will be logged if a compressed file name is given and underlying libSBML is not linked with the corresponding required library. SBMLReader_hasZlib() and SBMLReader_hasBzip2() can be used to check whether libSBML is linked with each library.

Returns
a pointer to the SBMLDocument read.
Examples:
addCustomValidator.cpp, addCVTerms.cpp, addingEvidenceCodes_1.cpp, addingEvidenceCodes_2.cpp, addModelHistory.cpp, appendAnnotation.cpp, callExternalValidator.cpp, convertSBML.cpp, echoSBML.cpp, inlineFunctionDefintions.cpp, printMath.cpp, printSBML.cpp, printUnits.cpp, promoteParameters.cpp, rngvalidator.cpp, and stripPackage.cpp.
SBMLDocument_t* readSBMLFromFile ( const char *  filename)

Reads an SBML document from the given file filename.

If filename does not exist, or it is not an SBML file, an error will be logged in the error log of the SBMLDocument object returned by this method. Calling programs can inspect this error log to determine the nature of the problem. Please refer to the definition of SBMLDocument_t for more information about the error reporting mechanism.

SBMLReader_t *sr;
SBMLDocument_t *d;

sr = SBMLReader_create();

d = SBMLReader_readSBML(reader, filename);

if (SBMLDocument_getNumErrors(d) > 0)
{
if (XMLError_getId(SBMLDocument_getError(d, 0)) == SBML_READ_ERROR_FILE_NOT_FOUND)
if (XMLError_getId(SBMLDocument_getError(d, 0)) == SBML_READ_ERROR_NOT_SBML)
}

If the filename ends with .gz, the file will be read as a gzip file. Similary, if the filename ends with .zip or .bz2, the file will be read as a zip or bzip2 file, respectively. Otherwise, the fill will be read as an uncompressed file. If the filename ends with .zip, only the first file in the archive will be read if the zip archive contains two or more files.

To read a gzip/zip file, underlying libSBML needs to be linked with zlib at compile time. Also, underlying libSBML needs to be linked with bzip2 to read a bzip2 file. File unreadable error will be logged if a compressed file name is given and underlying libSBML is not linked with the corresponding required library. SBMLReader_hasZlib() and SBMLReader_hasBzip2() can be used to check whether libSBML is linked with each library.

Returns
a pointer to the SBMLDocument read.
Examples:
translateL3Math.cpp.
SBMLDocument_t* readSBMLFromString ( const char *  xml)

Reads an SBML document from the given XML string xml.

If the string does not begin with XML declaration,

<?xml version='1.0' encoding='UTF-8'?>

an XML declaration string will be prepended.

This method will report an error if the given string xml is not SBML. The error will be logged in the error log of the SBMLDocument_t structure returned by this method. Calling programs can inspect this error log to determine the nature of the problem. Please refer to the definition of SBMLDocument for more information about the error reporting mechanism.

Returns
a pointer to the SBMLDocument_t read.
Note
When using this method to read an SBMLDocument that uses the SBML L3 Hierarchical Model Composition package (comp) the document location cannot be set automatically. Thus, if the model contains references to ExternalModelDefinitions, it will be necessary to manually set the document URI location (setLocationURI) in order to facilitate resolving these models.