Parse and Generate

utilities.TestPackage()

This function serves to test the package.

Notes

The function raises a warning about trying to set a constant species and 6 numbers.

1.27949533562e-06

9.42747177955e-10

1.33080766722e-07

9.79758065656e-08

4.05696056523e-07

2.66117319017e-05

These are the average relative errors for species, parameters, and compartments between the model results generated using SBMLtoODEpy and results calculated by COPASI for six different models provided in the sbmltoodepy/sbml_files subdirectory: Smallbone2013, Borisov2009, Guyton1972, Kerkhoven2013, Waugh2006, and Zi2011, respectively.

This function is intended as to serve as an example of using the sample models.

utilities.ParseAndCreateModel(inputFilePath, jsonFilePath=None, outputFilePath=None, className='SBMLmodel')

This function parses an SBML model file and generates a Python file implementing the model.

Parameters:
  • inputFilePath (str) – Location of the SBML model to be parsed
  • jsonFilePath (str, optional) – If provided, a json file containing the data for each of the model components will be created. If a file exists at the provided location, the file will be overwritten. Otherwise, this functionality is skipped and just a Python file will be generated.
  • outputFilePath (str, optional) – Location where the Python file will be created. If a file exists at the provided location, the file will be overwritten. If a location is not provided, the file path of the generated python file will be based on the inputFilePath
  • className (str, optional) – Name of the class that implements the SBML model.
Returns:

Return type:

None

Warning

This function will overwrite files located at jsonFilePath and outputFilePath

Notes

ParseAndCreateModel is intended to combine most of the functionality provided by this package. The intent is for this function to be suitable for most applications.

parse.ParseSBMLFile(filePath)
Parameters:filePath (string) – File path of the SBML model to be parsed
Returns:An object containing the model’s components and their properties.
Return type:ModelData

Notes

This function manages the process extracting an SBML model’s elements using libSBML. The design intent is for the DumpToJSON method of the returned ModelData instance to be called, or the ModelData instance passed to the GenerateModel function.

modulegeneration.GenerateModel(modelData, outputFilePath, objectName='SBMLmodel')

This function takes model data, either from ParseSBMLFIle() or imported from a .json file, and generates a Python file containing a class that implements the SBML model.

Parameters:
  • modelData (ModelData) – An object containing all of the model components and values.
  • outputFilePath (str) – The desired file path of the resulting python file.
  • objectName (str) – The name of the class defined in the resulting python file.
Returns:

Return type:

None