Parse and Generate


This function serves to test the package.


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







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.

  • 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.

Return type:



This function will overwrite files located at jsonFilePath and outputFilePath


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.

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


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.

  • 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.

Return type: