sbmlutils.comp.comp

Utilities for the creation and work with comp models.

Simplifies the port linking, submodel generation, …

Heavily used in the dynamic FBA simulator. Mainly in the model creation process. But the flattening parts also during the simulation of the dynamic FBA models.

Module Contents

Functions

create_ExternalModelDefinition(doc_comp, emd_id, source)

Create comp ExternalModelDefinition.

add_submodel_from_emd(model_comp, submodel_id, emd)

Add submodel to the model from given ExternalModelDefinition.

get_submodel_frameworks(doc)

Read the SBO terms of the submodels.

create_ports(model[, portRefs, idRefs, unitRefs, ...])

Create ports for given model.

_create_port(model, pid[, name, portRef, idRef, ...])

Create port in given model.

replace_elements(model, sid, ref_type, replaced_elements)

Replace elements in comp.

replace_element_in_submodels(model, sid, ref_type, ...)

Replace elements submodels with the identical id.

_create_replaced_element(model, sid, submodel, ...)

Create a replaced element.

replaced_by(model, sid, ref_type, submodel, replaced_by)

Create a ReplacedBy element.

_get_eplugin_by_sid(model, sid)

Get the comp plugin by sid.

_set_ref(sbaseref, ref_id, ref_type)

Set reference for given reference type in the object.

Attributes

logger

SBASE_REF_TYPE_PORT

SBASE_REF_TYPE_ID

SBASE_REF_TYPE_UNIT

SBASE_REF_TYPE_METAID

sbmlutils.comp.comp.logger[source]
sbmlutils.comp.comp.create_ExternalModelDefinition(doc_comp, emd_id, source)[source]

Create comp ExternalModelDefinition.

Parameters:
  • doc_comp (libsbml.CompSBMLDocumentPlugin) – SBMLDocument comp plugin

  • emd_id (str) – id of external model definition

  • source (str) – source

Returns:

Return type:

libsbml.ExternalModelDefinition

sbmlutils.comp.comp.add_submodel_from_emd(model_comp, submodel_id, emd)[source]

Add submodel to the model from given ExternalModelDefinition.

Parameters:
  • model_comp (libsbml.CompModelPlugin) – Model comp plugin

  • submodel_id (str) –

  • emd (libsbml.ExternalModelDefinition) –

Returns:

Return type:

libsbml.Submodel

sbmlutils.comp.comp.get_submodel_frameworks(doc)[source]

Read the SBO terms of the submodels.

These are used to distinguish the different frameworks of the submodels. :param doc: SBMLDocument :return:

Parameters:

doc (libsbml.SBMLDocument) –

Return type:

Dict[str, Any]

sbmlutils.comp.comp.create_ports(model, portRefs=None, idRefs=None, unitRefs=None, metaIdRefs=None, portType=factory.PortType.PORT, suffix=factory.PORT_SUFFIX)[source]

Create ports for given model.

Helper function to create port creation. :param model: SBML model :param portRefs: dict of the form {pid:portRef} :param idRefs: dict of the form {pid:idRef} :param unitRefs: dict of the form {pid:unitRef} :param metaIdRefs: dict of the form {pid:metaIdRef} :param portType: type of port :param suffix: suffix to use in port generation

Returns:

Parameters:
  • model (libsbml.Model) –

  • portRefs (Optional[Any]) –

  • idRefs (Optional[Any]) –

  • unitRefs (Optional[Any]) –

  • metaIdRefs (Optional[Any]) –

  • portType (sbmlutils.factory.PortType) –

  • suffix (str) –

Return type:

List[sbmlutils.factory.Port]

sbmlutils.comp.comp._create_port(model, pid, name=None, portRef=None, idRef=None, unitRef=None, metaIdRef=None, portType=factory.PortType.PORT)[source]

Create port in given model.

Parameters:
  • model (libsbml.Model) –

  • pid (str) –

  • name (Optional[str]) –

  • portRef (Optional[str]) –

  • idRef (Optional[str]) –

  • unitRef (Optional[str]) –

  • metaIdRef (Optional[str]) –

  • portType (sbmlutils.factory.PortType) –

Return type:

libsbml.Port

sbmlutils.comp.comp.SBASE_REF_TYPE_PORT = 'portRef'[source]
sbmlutils.comp.comp.SBASE_REF_TYPE_ID = 'idRef'[source]
sbmlutils.comp.comp.SBASE_REF_TYPE_UNIT = 'unitRef'[source]
sbmlutils.comp.comp.SBASE_REF_TYPE_METAID = 'metIdRef'[source]
sbmlutils.comp.comp.replace_elements(model, sid, ref_type, replaced_elements)[source]

Replace elements in comp.

Parameters:
  • model (libsbml.Model) –

  • sid (str) –

  • ref_type (str) –

  • replaced_elements (Dict[str, List[str]]) –

Returns:

Return type:

None

sbmlutils.comp.comp.replace_element_in_submodels(model, sid, ref_type, submodels)[source]

Replace elements submodels with the identical id.

For instance to replace all the units in the submodels.

Parameters:
  • model (libsbml.Model) –

  • sid (str) –

  • ref_type (str) –

  • submodels (List[str]) –

Returns:

Return type:

libsbml.ReplacedElement

sbmlutils.comp.comp._create_replaced_element(model, sid, submodel, replaced_id, ref_type)[source]

Create a replaced element.

Parameters:
  • model (libsbml.Model) –

  • sid (str) –

  • submodel (str) –

  • replaced_id (str) –

  • ref_type (str) –

Return type:

libsbml.ReplacedElement

sbmlutils.comp.comp.replaced_by(model, sid, ref_type, submodel, replaced_by)[source]

Create a ReplacedBy element.

The element with sid in the model is replaced by the replacing_id in the submodel with submodel_id.

Parameters:
  • model (libsbml.Model) –

  • sid (str) –

  • ref_type (str) –

  • submodel (str) –

  • replaced_by (str) –

Return type:

libsbml.ReplacedBy

sbmlutils.comp.comp._get_eplugin_by_sid(model, sid)[source]

Get the comp plugin by sid.

Parameters:
  • model (libsbml.Model) – SBMLModel instance

  • sid (str) – SBase id of object

Returns:

Return type:

Any

sbmlutils.comp.comp._set_ref(sbaseref, ref_id, ref_type)[source]

Set reference for given reference type in the object.

Objects can be

ReplacedBy ReplacedElement

Parameters:
  • sbaseref (libsbml.SBaseRef) –

  • ref_id (str) –

  • ref_type (str) –

Return type:

None