sbmlutils.comp.flatten

Helpers for model flattening.

Module Contents

Functions

flatten_sbml(sbml_path, sbml_flat_path[, leave_ports])

Flatten given SBML file.

flatten_sbml_doc(doc[, sbml_flat_path, leave_ports])

Flatten SBMLDocument.

flatten_external_model_definitions(doc[, validate])

Convert all ExternalModelDefinitions to ModelDefinitions.

Attributes

logger

sbmlutils.comp.flatten.logger[source]
sbmlutils.comp.flatten.flatten_sbml(sbml_path, sbml_flat_path, leave_ports=True)[source]

Flatten given SBML file.

Parameters:
  • sbml_path (pathlib.Path) – input path to SBML file to flatten (should be a comp model)

  • sbml_flat_path (pathlib.Path) – output path for flat SBML

  • leave_ports (bool) – boolean flag to leave ports in flattened model.

Returns:

flattened SBMLDocument

Return type:

libsbml.SBMLDocument

sbmlutils.comp.flatten.flatten_sbml_doc(doc, sbml_flat_path=None, leave_ports=True)[source]

Flatten SBMLDocument.

Validation should be performed before the flattening and is not part of the flattening routine. If an output path is provided the file is written to the output path.

Parameters:
  • doc (libsbml.SBMLDocument) – SBMLDocument to flatten.

  • sbml_flat_path (Optional[pathlib.Path]) – Path to write flattended SBMLDocument to

  • leave_ports (bool) – flag to leave ports

Returns:

SBMLDocument

Return type:

libsbml.SBMLDocument

sbmlutils.comp.flatten.flatten_external_model_definitions(doc, validate=False)[source]

Convert all ExternalModelDefinitions to ModelDefinitions.

I.e. the definition of models in external files are read and directly included in the top model. The resulting comp model consists than only of a single file.

The model refs in the submodel do not change in the process, so no need to update the submodels.

Parameters:
  • doc (libsbml.SBMLDocument) – SBMLDocument

  • validate (bool) – validation flag

Returns:

SBMLDocument with ExternalModelDefinitions replaced

Return type:

libsbml.SBMLDocument