petab.sbml

Functions for interacting with SBML models

Functions

get_model_for_condition(petab_problem[, ...])

Create an SBML model for the given condition.

get_model_parameters(sbml_model[, with_values])

Return SBML model parameters which are not Rule targets

get_sbml_model(filepath_or_buffer)

Get an SBML model from file or URL or file handle

globalize_parameters(sbml_model[, ...])

Turn all local parameters into global parameters with the same properties

is_sbml_consistent(sbml_document[, check_units])

Check for SBML validity / consistency

load_sbml_from_file(sbml_file)

Load SBML model from file

load_sbml_from_string(sbml_string)

Load SBML model from string

log_sbml_errors(sbml_document[, ...])

Log libsbml errors

write_sbml(sbml_doc, filename)

Write PEtab visualization table

petab.sbml.get_model_for_condition(petab_problem: Problem, sim_condition_id: str | None = None, preeq_condition_id: str | None = None) Tuple[SBMLDocument, Model][source]

Create an SBML model for the given condition.

Creates a copy of the model and updates parameters according to the PEtab files. Estimated parameters are set to their nominalValue. Observables defined in the observables table are not added to the model.

Parameters:
  • petab_problem – PEtab problem

  • sim_condition_id – Simulation conditionId for which to generate a model

  • preeq_condition_id – Preequilibration conditionId of the settings for which to generate a model. This is only used to determine the relevant output parameter overrides. Preequilibration is not encoded in the resulting model.

Returns:

The generated SBML document, and SBML model

petab.sbml.get_model_parameters(sbml_model: Model, with_values=False) List[str] | Dict[str, float][source]

Return SBML model parameters which are not Rule targets

Parameters:
  • sbml_model – SBML model

  • with_values – If False, returns list of SBML model parameter IDs which are not Rule targets. If True, returns a dictionary with those parameter IDs as keys and parameter values from the SBML model as values.

petab.sbml.get_sbml_model(filepath_or_buffer) Tuple[SBMLReader, SBMLDocument, Model][source]

Get an SBML model from file or URL or file handle

Parameters:

filepath_or_buffer – File or URL or file handle to read the model from

Returns:

The SBML document, model and reader

petab.sbml.globalize_parameters(sbml_model: Model, prepend_reaction_id: bool = False) None[source]

Turn all local parameters into global parameters with the same properties

Local parameters are currently ignored by other PEtab functions. Use this function to convert them to global parameters. There may exist local parameters with identical IDs within different kinetic laws. This is not checked here. If in doubt that local parameter IDs are unique, enable prepend_reaction_id to create global parameters named ${reaction_id}_${local_parameter_id}.

Parameters:
  • sbml_model – The SBML model to operate on

  • prepend_reaction_id – Prepend reaction id of local parameter when creating global parameters

petab.sbml.is_sbml_consistent(sbml_document: SBMLDocument, check_units: bool = False) bool[source]

Check for SBML validity / consistency

Parameters:
  • sbml_document – SBML document to check

  • check_units – Also check for unit-related issues

Returns:

False if problems were detected, otherwise True

petab.sbml.load_sbml_from_file(sbml_file: str) Tuple[SBMLReader, SBMLDocument, Model][source]

Load SBML model from file

Parameters:

sbml_file – Filename of the SBML file

Returns:

The SBML reader, document, model

petab.sbml.load_sbml_from_string(sbml_string: str) Tuple[SBMLReader, SBMLDocument, Model][source]

Load SBML model from string

Parameters:

sbml_string – Model as XML string

Returns:

The SBML document, model and reader

petab.sbml.log_sbml_errors(sbml_document: SBMLDocument, minimum_severity=1) None[source]

Log libsbml errors

Parameters:
  • sbml_document – SBML document to check

  • minimum_severity – Minimum severity level to report (see libsbml documentation)

petab.sbml.write_sbml(sbml_doc: SBMLDocument, filename: Path | str) None[source]

Write PEtab visualization table

Parameters:
  • sbml_doc – SBML document containing the SBML model

  • filename – Destination file name