sbmlutils.factory

Factory for creating SBML objects.

This module provides definitions of helper functions for the creation of SBML objects. These are the low level helpers to create models from scratch and are used in the higher level SBML factories.

The general workflow to create new SBML models isto create a lists/iterables of SBMLObjects by using the respective classes in this module, e.g. Compartment, Parameter, Species.

The actual SBase objects are than created in the SBMLDocument/Model by calling

create_objects(model, objects)

These functions DO NOT take care of the order of the creation, but the order must be correct in the model definition files. To create complete models one should use the modelcreator functionality, which takes care of the order of object creation.

Module Contents

Classes

ReactionEquation

Representation of stoichiometric equations with modifiers.

ValidationOptions

Options for SBML validator.

ModelUnits

Class for storing model units information.

KeyValuePair

KeyValuePair.

UnitDefinition

Unit.

Units

Base class for unit definitions.

Function

SBML FunctionDefinitions.

Parameter

Parameter.

Compartment

Compartment.

Species

Species.

InitialAssignment

InitialAssignments.

AssignmentRule

AssignmentRule.

RateRule

RateRule.

AlgebraicRule

AlgebraicRule.

Reaction

Reaction.

Event

Event.

Constraint

Constraint.

UncertParameter

UncertParameter.

UncertSpan

UncertSpan.

Uncertainty

Uncertainty.

ExchangeReaction

Exchange reactions define substances which can be exchanged.

GeneProduct

GeneProduct.

UserDefinedConstraintComponent

UserDefinedConstraintComponent.

UserDefinedConstraint

UserDefinedConstraint.

FluxObjective

FluxObjective.

Objective

Objective.

ModelDefinition

ModelDefinition.

ExternalModelDefinition

ExternalModelDefinition.

Submodel

Submodel.

ReplacedElement

ReplacedElement.

ReplacedBy

ReplacedBy.

Deletion

Deletion.

PortType

Supported port types.

Port

Port.

Package

Supported/tested packages.

ModelDict

ModelDict.

Model

Model.

Document

Document.

FactoryResult

Data structure for model creation.

Functions

create_model(model, filepath[, sbml_level, ...])

Create SBML model from models.

Attributes

SBML_LEVEL

SBML_VERSION

PORT_SUFFIX

PORT_UNIT_SUFFIX

UnitType

Formula

class sbmlutils.factory.ReactionEquation(reactants=None, products=None, modifiers=None, reversible=True)[source]

Representation of stoichiometric equations with modifiers.

Parameters:
  • reactants (Optional[List[EquationPart]]) –

  • products (Optional[List[EquationPart]]) –

  • modifiers (Optional[List[str]]) –

  • reversible (bool) –

static from_str(equation_str)[source]

Parse components of equation string.

Parameters:

equation_str (str) –

Return type:

ReactionEquation

_parse_equation(equation_str)[source]
Parameters:

equation_str (str) –

Return type:

None

_parse_modifiers(s)[source]
Parameters:

s (str) –

Return type:

None

_parse_half_equation(string)[source]

Parse half-equation.

Only ‘+ supported in equation !, do not use negative stoichiometries.

Parameters:

string (str) –

Return type:

List[EquationPart]

static _parse_reactant(item)[source]

Parse stoichiometry, species, sid information.

Parameters:

item (str) –

Return type:

EquationPart

static _to_string_side(items)[source]
Parameters:

items (Iterable[EquationPart]) –

Return type:

str

_to_string_modifiers()[source]
Return type:

str

to_string(modifiers=False)[source]

Get string representation of equation.

Parameters:

modifiers (bool) –

Return type:

str

info()[source]

Print overview of parsed equation.

Return type:

None

static help()[source]

Get help information string.

Return type:

str

class sbmlutils.factory.ValidationOptions[source]

Options for SBML validator.

Controls the consistency checks that are performed when SBMLDocument.checkConsistency() is called.

  • general_consistency: Correctness and consistency of

specific SBML language constructs. Performing this set of checks is highly recommended. With respect to the SBML specification, these concern failures in applying the validation rules numbered 2xxxx in the Level 2 Versions 2-4 and Level 3 Versions 1-2 specifications.

  • ìdentifier_consistency: Correctness and consistency of

identifiers used for model entities. An example of inconsistency would be using a species identifier in a reaction rate formula without first having declared the species. With respect to the SBML specification, these concern failures in applying the validation rules numbered 103xx in the Level 2 Versions 2-4 and Level 3 Versions 1-2 specifications.

  • units_consistency: Consistency of measurement units

associated with quantities in a model. With respect to the SBML specification, these concern failures in applying the validation rules numbered 105xx in the Level 2 Versions 2-4 and Level 3 Versions 1-2 specifications.

  • mathml_consistency: Syntax of MathML constructs. With

respect to the SBML specification, these concern failures in applying the validation rules numbered 102xx in the Level 2 Versions 2-4 and Level 3 Versions 1-2 specifications.

  • sbo_consistency: Consistency and validity of SBO

identifiers (if any) used in the model. With respect to the SBML specification, these concern failures in applying the validation rules numbered 107xx in the Level 2 Versions 2-4 and Level 3 Versions 1-2 specifications.

  • overdetermined_model: Static analysis of whether the

system of equations implied by a model is mathematically overdetermined. With respect to the SBML specification, this is validation rule #10601 in the Level 2 Versions 2-4 and Level 3 Versions 1-2 specifications.

  • modeling_practise: Additional checks for recommended

good modeling practice. (These are tests performed by libSBML and do not have equivalent SBML validation rules.) By default, all validation checks are applied to the model in an SBMLDocument object unless SBMLDocument.setConsistencyChecks() is called to indicate that only a subset should be applied. Further, this default (i.e., performing all checks) applies separately to each new SBMLDocument object created. In other words, each time a model is read using SBMLReader.readSBML(), SBMLReader.readSBMLFromString(), or the global functions readSBML() and readSBMLFromString(), a new SBMLDocument is created and for that document, a call to SBMLDocument.checkConsistency() will default to applying all possible checks. Calling programs must invoke SBMLDocument.setConsistencyChecks() for each such new model if they wish to change the consistency checks applied.

  • internal_consistency: Additional checks that model is consistent XML.

  • log_errors Boolean flag to log errors.

log_errors: bool = True
internal_consistency: bool = True
general_consistency: bool = True
identifier_consistency: bool = True
mathml_consistency: bool = True
units_consistency: bool = True
sbo_consistency: bool = True
overdetermined_model: bool = True
modeling_practice: bool = True
sbmlutils.factory.SBML_LEVEL = 3[source]
sbmlutils.factory.SBML_VERSION = 1[source]
sbmlutils.factory.PORT_SUFFIX = '_port'[source]
sbmlutils.factory.PORT_UNIT_SUFFIX = '_unit_port'[source]
sbmlutils.factory.UnitType[source]
class sbmlutils.factory.ModelUnits(time=None, extent=None, substance=None, length=None, area=None, volume=None)[source]

Class for storing model units information.

The ModelUnits define globally the units for time, extent, substance, length, area and volume.

The following SBML Level 3 base units can be used.

ampere farad joule lux radian volt avogadro gram katal metre second watt becquerel gray kelvin mole siemens weber candela henry kilogram newton sievert coulomb hertz litre ohm steradian dimensionless item lumen pascal tesla

Parameters:
  • time (UnitType) –

  • extent (UnitType) –

  • substance (UnitType) –

  • length (UnitType) –

  • area (UnitType) –

  • volume (UnitType) –

static set_model_units(model, model_units)[source]

Set the main units in model from dictionary.

Setting the model units is important for understanding the model dynamics. Allowed keys are:

time extent substance length area volume

Parameters:
  • model (libsbml.Model) – SBMLModel

  • model_units (ModelUnits) – dict of units

Returns:

Return type:

None

class sbmlutils.factory.KeyValuePair(key, value, uri, sid=None, name=None, sboTerm=None, metaId=None, notes=None, annotations=None, keyValuePairs=None, port=None, uncertainties=None, replacedBy=None)[source]

Bases: Sbase

KeyValuePair.

Parameters:
  • key (str) –

  • value (Optional[str]) –

  • uri (Optional[str]) –

  • sid (Optional[str]) –

  • name (Optional[str]) –

  • sboTerm (Optional[str]) –

  • metaId (Optional[str]) –

  • notes (Optional[str]) –

  • annotations (OptionalAnnotationsType) –

  • keyValuePairs (Optional[List[KeyValuePair]]) –

  • port (Any) –

  • uncertainties (Optional[List[Uncertainty]]) –

  • replacedBy (Optional[Any]) –

create_sbml(sbase)[source]

Create KeyValuePair on object.

Parameters:

sbase (libsbml.SBase) –

Return type:

libsbml.KeyValuePair

class sbmlutils.factory.UnitDefinition(sid, definition=None, name=None, sboTerm=None, metaId=None, annotations=None, notes=None, keyValuePairs=None, port=None, replacedBy=None)[source]

Bases: Sbase

Unit.

Corresponds to the information in the libsbml.UnitDefinition.

Parameters:
  • sid (str) –

  • definition (Optional[str]) –

  • name (Optional[str]) –

  • sboTerm (Optional[str]) –

  • metaId (Optional[str]) –

  • annotations (OptionalAnnotationsType) –

  • notes (Optional[str]) –

  • keyValuePairs (Optional[List[KeyValuePair]]) –

  • port (Any) –

  • replacedBy (Optional[Any]) –

class Config[source]

Pydantic configuration.

arbitrary_types_allowed = True[source]
_pint2sbml[source]
_prefixes[source]
create_sbml(model)[source]

Create libsbml.UnitDefinition.

Parameters:

model (libsbml.Model) –

Return type:

Optional[libsbml.UnitDefinition]

_set_fields(sbase, model)[source]

Set fields on libsbml.UnitDefinition.

Parameters:
  • sbase (libsbml.UnitDefinition) –

  • model (libsbml.Model) –

Return type:

None

static _create_unit(udef, kind, exponent, scale=0, multiplier=1.0)[source]

Create libsbml.Unit.

Parameters:
  • udef (libsbml.UnitDefinition) –

  • kind (str) –

  • exponent (float) –

  • scale (int) –

  • multiplier (float) –

Return type:

libsbml.Unit

static get_uid_for_unit(unit)[source]

Get unit id for given definition string.

Parameters:

unit (Union[UnitDefinition, str]) –

Return type:

Optional[str]

class sbmlutils.factory.Units[source]

Base class for unit definitions.

dimensionless[source]
ampere[source]
becquerel[source]
candela[source]
degree_Celsius[source]
coulomb[source]
farad[source]
gram[source]
gray[source]
hertz[source]
item[source]
kelvin[source]
kilogram[source]
liter[source]
litre[source]
meter[source]
metre[source]
mole[source]
newton[source]
ohm[source]
second[source]
volt[source]
classmethod attributes()[source]

Get the attributes list.

Return type:

List[Tuple[str, Union[str, UnitDefinition]]]

classmethod create_unit_definitions(model)[source]

Create the libsbml.UnitDefinitions in the model.

Parameters:

model (libsbml.Model) –

Return type:

None

class sbmlutils.factory.Function(sid, value, name=None, sboTerm=None, metaId=None, annotations=None, notes=None, keyValuePairs=None, port=None, uncertainties=None, replacedBy=None)[source]

Bases: Sbase

SBML FunctionDefinitions.

FunctionDefinitions consist of a lambda expression in the value field, e.g.,

lambda(x,y, piecewise(x,gt(x,y),y) ) # definition of minimum function lambda(x, sin(x) )

Parameters:
  • sid (str) –

  • value (str) –

  • name (Optional[str]) –

  • sboTerm (Optional[str]) –

  • metaId (Optional[str]) –

  • annotations (OptionalAnnotationsType) –

  • notes (Optional[str]) –

  • keyValuePairs (Optional[List[KeyValuePair]]) –

  • port (Any) –

  • uncertainties (Optional[List[Uncertainty]]) –

  • replacedBy (Optional[Any]) –

create_sbml(model)[source]

Create FunctionDefinition SBML in model.

Parameters:

model (libsbml.Model) –

Return type:

libsbml.FunctionDefinition

_set_fields(sbase, model)[source]
Parameters:
  • sbase (libsbml.FunctionDefinition) –

  • model (libsbml.Model) –

Return type:

None

class sbmlutils.factory.Parameter(sid, value=None, unit=None, constant=True, name=None, sboTerm=None, metaId=None, annotations=None, notes=None, keyValuePairs=None, port=None, uncertainties=None, replacedBy=None)[source]

Bases: ValueWithUnit

Parameter.

Parameters:
  • sid (str) –

  • value (Optional[Union[str, float]]) –

  • unit (UnitType) –

  • constant (bool) –

  • name (Optional[str]) –

  • sboTerm (Optional[str]) –

  • metaId (Optional[str]) –

  • annotations (OptionalAnnotationsType) –

  • notes (Optional[str]) –

  • keyValuePairs (Optional[List[KeyValuePair]]) –

  • port (Any) –

  • uncertainties (Optional[List[Uncertainty]]) –

  • replacedBy (Optional[Any]) –

create_sbml(model)[source]

Create Parameter SBML in model.

Parameters:

model (libsbml.Model) –

Return type:

libsbml.Parameter

_set_fields(sbase, model)[source]

Set fields.

Parameters:
  • sbase (libsbml.Parameter) –

  • model (libsbml.Model) –

Return type:

None

class sbmlutils.factory.Compartment(sid, value, unit=None, constant=True, spatialDimensions=3, name=None, sboTerm=None, metaId=None, annotations=None, notes=None, keyValuePairs=None, port=None, uncertainties=None, replacedBy=None)[source]

Bases: ValueWithUnit

Compartment.

Parameters:
  • sid (str) –

  • value (Union[str, float]) –

  • unit (UnitType) –

  • constant (bool) –

  • spatialDimensions (float) –

  • name (Optional[str]) –

  • sboTerm (Optional[str]) –

  • metaId (Optional[str]) –

  • annotations (OptionalAnnotationsType) –

  • notes (Optional[str]) –

  • keyValuePairs (Optional[List[KeyValuePair]]) –

  • port (Any) –

  • uncertainties (Optional[List[Uncertainty]]) –

  • replacedBy (Optional[Any]) –

create_sbml(model)[source]

Create Compartment SBML in model.

Parameters:

model (libsbml.Model) –

Return type:

libsbml.Compartment

_set_fields(sbase, model)[source]

Set fields on Compartment.

Parameters:
  • sbase (libsbml.Compartment) –

  • model (libsbml.Model) –

Return type:

None

class sbmlutils.factory.Species(sid, compartment, initialAmount=None, initialConcentration=None, substanceUnit=None, hasOnlySubstanceUnits=False, constant=False, boundaryCondition=False, charge=None, chemicalFormula=None, conversionFactor=None, name=None, sboTerm=None, metaId=None, annotations=None, notes=None, keyValuePairs=None, port=None, uncertainties=None, replacedBy=None)[source]

Bases: Sbase

Species.

Parameters:
  • sid (str) –

  • compartment (str) –

  • initialAmount (Optional[float]) –

  • initialConcentration (Optional[float]) –

  • substanceUnit (UnitType) –

  • hasOnlySubstanceUnits (bool) –

  • constant (bool) –

  • boundaryCondition (bool) –

  • charge (Optional[float]) –

  • chemicalFormula (Optional[str]) –

  • conversionFactor (Optional[str]) –

  • name (Optional[str]) –

  • sboTerm (Optional[str]) –

  • metaId (Optional[str]) –

  • annotations (OptionalAnnotationsType) –

  • notes (Optional[str]) –

  • keyValuePairs (Optional[List[KeyValuePair]]) –

  • port (Any) –

  • uncertainties (Optional[List[Uncertainty]]) –

  • replacedBy (Optional[Any]) –

create_sbml(model)[source]

Create Species SBML in model.

Parameters:

model (libsbml.Model) –

Return type:

libsbml.Species

_set_fields(sbase, model)[source]

Set fields on libsbml.Species.

Parameters:
  • sbase (libsbml.Species) –

  • model (libsbml.Model) –

Return type:

None

class sbmlutils.factory.InitialAssignment(symbol, value, unit=Units.dimensionless, sid=None, name=None, sboTerm=None, metaId=None, annotations=None, notes=None, keyValuePairs=None, port=None, uncertainties=None, replacedBy=None)[source]

Bases: Value

InitialAssignments.

The unit attribute is only for the case where a parameter must be created (which has the unit). In case of an initialAssignment of a value the units have to be defined in the math.

Parameters:
  • symbol (str) –

  • value (Union[str, float]) –

  • unit (UnitType) –

  • sid (Optional[str]) –

  • name (Optional[str]) –

  • sboTerm (Optional[str]) –

  • metaId (Optional[str]) –

  • annotations (OptionalAnnotationsType) –

  • notes (Optional[str]) –

  • keyValuePairs (Optional[List[KeyValuePair]]) –

  • port (Any) –

  • uncertainties (Optional[List[Uncertainty]]) –

  • replacedBy (Optional[Any]) –

create_sbml(model)[source]

Create InitialAssignment.

Creates a required parameter if the symbol for the initial assignment does not exist in the model.

Parameters:

model (libsbml.Model) –

Return type:

libsbml.InitialAssignment

class sbmlutils.factory.AssignmentRule(variable, value, unit=Units.dimensionless, sid=None, name=None, sboTerm=None, metaId=None, annotations=None, notes=None, keyValuePairs=None, port=None, uncertainties=None, replacedBy=None)[source]

Bases: ValueWithUnit, RuleWithVariable

AssignmentRule.

The unit attribute is only for the case where a parameter must be created (which has the unit). In case of an initialAssignment of a value the units have to be defined in the math.

Parameters:
  • variable (str) –

  • value (Union[str, float]) –

  • unit (UnitType) –

  • sid (Optional[str]) –

  • name (Optional[str]) –

  • sboTerm (Optional[str]) –

  • metaId (Optional[str]) –

  • annotations (OptionalAnnotationsType) –

  • notes (Optional[str]) –

  • keyValuePairs (Optional[List[KeyValuePair]]) –

  • port (Any) –

  • uncertainties (Optional[List[Uncertainty]]) –

  • replacedBy (Optional[Any]) –

__repr__()[source]

Get string representation.

Return type:

str

create_sbml(model)[source]

Create AssignmentRule.

Parameters:

model (libsbml.Model) –

Return type:

libsbml.AssignmentRule

class sbmlutils.factory.RateRule(variable, value, unit=Units.dimensionless, sid=None, name=None, sboTerm=None, metaId=None, annotations=None, notes=None, keyValuePairs=None, port=None, uncertainties=None, replacedBy=None)[source]

Bases: ValueWithUnit, RuleWithVariable

RateRule.

Parameters:
  • variable (str) –

  • value (Union[str, float]) –

  • unit (UnitType) –

  • sid (Optional[str]) –

  • name (Optional[str]) –

  • sboTerm (Optional[str]) –

  • metaId (Optional[str]) –

  • annotations (OptionalAnnotationsType) –

  • notes (Optional[str]) –

  • keyValuePairs (Optional[List[KeyValuePair]]) –

  • port (Any) –

  • uncertainties (Optional[List[Uncertainty]]) –

  • replacedBy (Optional[Any]) –

__repr__()[source]

Get string representation.

Return type:

str

create_sbml(model)[source]

Create RateRule.

Parameters:

model (libsbml.Model) –

Return type:

libsbml.RateRule

class sbmlutils.factory.AlgebraicRule(sid, value, unit=Units.dimensionless, name=None, sboTerm=None, metaId=None, annotations=None, notes=None, keyValuePairs=None, port=None, uncertainties=None, replacedBy=None)[source]

Bases: ValueWithUnit, RuleWithVariable

AlgebraicRule.

Parameters:
  • sid (str) –

  • value (Union[str, float]) –

  • unit (UnitType) –

  • name (Optional[str]) –

  • sboTerm (Optional[str]) –

  • metaId (Optional[str]) –

  • annotations (OptionalAnnotationsType) –

  • notes (Optional[str]) –

  • keyValuePairs (Optional[List[KeyValuePair]]) –

  • port (Any) –

  • uncertainties (Optional[List[Uncertainty]]) –

  • replacedBy (Optional[Any]) –

__repr__()[source]

Get string representation.

Return type:

str

create_sbml(model)[source]

Create AlgebraicRule.

Parameters:

model (libsbml.Model) –

Return type:

libsbml.AlgebraicRule

sbmlutils.factory.Formula[source]
class sbmlutils.factory.Reaction(sid, equation, formula=None, pars=None, rules=None, compartment=None, fast=False, reversible=None, lowerFluxBound=None, upperFluxBound=None, geneProductAssociation=None, name=None, sboTerm=None, metaId=None, annotations=None, notes=None, keyValuePairs=None, port=None, uncertainties=None, replacedBy=None)[source]

Bases: Sbase

Reaction.

Class for creating libsbml.Reaction.

Equations are of the form ‘1.0 S1 + 2 S2 => 2.0 P1 + 2 P2 [M1, M2]’

The equation consists of - substrates concatenated via ‘+’ on the left side

(with optional stoichiometric coefficients)

  • separation characters separating the left and right equation sides: ‘<=>’ or ‘<->’ for reversible reactions, ‘=>’ or ‘->’ for irreversible reactions (irreversible reactions are written from left to right)

  • products concatenated via ‘+’ on the right side (with optional stoichiometric coefficients)

  • optional list of modifiers within brackets [] separated by ‘,’

Examples of valid equations are:

‘1.0 S1 + 2 S2 => 2.0 P1 + 2 P2 [M1, M2]’, ‘c__gal1p => c__gal + c__phos’, ‘e__h2oM <-> c__h2oM’, ‘3 atp + 2.0 phos + ki <-> 16.98 tet’, ‘c__gal1p => c__gal + c__phos [c__udp, c__utp]’, ‘A_ext => A []’, ‘=> cit’, ‘acoa =>’,

Parameters:
  • sid (str) –

  • equation (Union[sbmlutils.reaction_equation.ReactionEquation, str]) –

  • formula (Optional[Union[Formula, Tuple[str, UnitType], str]]) –

  • pars (Optional[List[Parameter]]) –

  • rules (Optional[List[AssignmentRule]]) –

  • compartment (Optional[str]) –

  • fast (bool) –

  • reversible (Optional[bool]) –

  • lowerFluxBound (Optional[str]) –

  • upperFluxBound (Optional[str]) –

  • geneProductAssociation (Optional[str]) –

  • name (Optional[str]) –

  • sboTerm (Optional[str]) –

  • metaId (Optional[str]) –

  • annotations (OptionalAnnotationsType) –

  • notes (Optional[str]) –

  • keyValuePairs (Optional[List[KeyValuePair]]) –

  • port (Any) –

  • uncertainties (Optional[List[Uncertainty]]) –

  • replacedBy (Optional[Any]) –

static _process_equation(equation)[source]

Process reaction equation.

Parameters:

equation (Union[sbmlutils.reaction_equation.ReactionEquation, str]) –

Return type:

sbmlutils.reaction_equation.ReactionEquation

static _process_formula(formula)[source]

Process reaction formula (kinetic law).

Parameters:

formula (Optional[Union[Formula, Tuple[str, UnitType], str]]) –

Return type:

Optional[Formula]

create_sbml(model)[source]

Create Reaction SBML in model.

Parameters:

model (libsbml.Model) –

Return type:

libsbml.Reaction

_set_fields(sbase, model)[source]

Set fields in libsbml.Reaction.

Parameters:
  • sbase (libsbml.Reaction) –

  • model (libsbml.Model) –

Return type:

None

static set_kinetic_law(model, reaction, formula)[source]

Set the kinetic law in reaction based on given formula.

Parameters:
  • model (libsbml.Model) –

  • reaction (libsbml.Reaction) –

  • formula (str) –

Return type:

libsbml.KineticLaw

class sbmlutils.factory.Event(sid, trigger, assignments=None, trigger_persistent=True, trigger_initialValue=False, useValuesFromTriggerTime=True, priority=None, delay=None, name=None, sboTerm=None, metaId=None, annotations=None, notes=None, keyValuePairs=None, port=None, uncertainties=None, replacedBy=None)[source]

Bases: Sbase

Event.

Trigger have the format of a logical expression:

time%200 == 0

Assignments have the format

sid = value

Parameters:
  • sid (str) –

  • trigger (str) –

  • assignments (Optional[Dict[str, Union[str, float]]]) –

  • trigger_persistent (bool) –

  • trigger_initialValue (bool) –

  • useValuesFromTriggerTime (bool) –

  • priority (Optional[str]) –

  • delay (Optional[str]) –

  • name (Optional[str]) –

  • sboTerm (Optional[str]) –

  • metaId (Optional[str]) –

  • annotations (OptionalAnnotationsType) –

  • notes (Optional[str]) –

  • keyValuePairs (Optional[List[KeyValuePair]]) –

  • port (Any) –

  • uncertainties (Optional[List[Uncertainty]]) –

  • replacedBy (Optional[Any]) –

create_sbml(model)[source]

Create Event SBML in model.

Parameters:

model (libsbml.Model) –

Return type:

libsbml.Event

_set_fields(sbase, model)[source]

Set fields in libsbml.Event.

Parameters:
  • sbase (libsbml.Event) –

  • model (libsbml.Model) –

Return type:

None

static _trigger_from_time(t)[source]

Create trigger from given time point.

Parameters:

t (float) –

Return type:

str

static _assignments_dict(species, values)[source]
Parameters:
  • species (List[str]) –

  • values (List[str]) –

Return type:

Dict[str, str]

class sbmlutils.factory.Constraint(sid, math, message=None, name=None, sboTerm=None, metaId=None, annotations=None, notes=None, keyValuePairs=None, port=None, uncertainties=None, replacedBy=None)[source]

Bases: Sbase

Constraint.

The Constraint object is a mechanism for stating the assumptions under which a model is designed to operate. The constraints are statements about permissible values of different quantities in a model.

The message must be well formated XHTML, e.g.,

message=’<body xmlns=”http://www.w3.org/1999/xhtml”>ATP must be non-negative</body>’

Parameters:
  • sid (str) –

  • math (str) –

  • message (Optional[str]) –

  • name (Optional[str]) –

  • sboTerm (Optional[str]) –

  • metaId (Optional[str]) –

  • annotations (OptionalAnnotationsType) –

  • notes (Optional[str]) –

  • keyValuePairs (Optional[List[KeyValuePair]]) –

  • port (Any) –

  • uncertainties (Optional[List[Uncertainty]]) –

  • replacedBy (Optional[Any]) –

create_sbml(model)[source]

Create Constraint SBML in model.

Parameters:

model (libsbml.Model) –

Return type:

libsbml.Constraint

_set_fields(sbase, model)[source]

Set fields on libsbml.Constraint.

Parameters:
  • sbase (libsbml.Constraint) –

  • model (libsbml.Model) –

Return type:

None

class sbmlutils.factory.UncertParameter(type, value=None, var=None, unit=None)[source]

UncertParameter.

FIXME: This is an SBase!

Parameters:
  • type (str) –

  • value (Optional[float]) –

  • var (Optional[str]) –

  • unit (UnitType) –

class sbmlutils.factory.UncertSpan(type, valueLower=None, varLower=None, valueUpper=None, varUpper=None, unit=None)[source]

UncertSpan.

FIXME: This is an SBase!

Parameters:
  • type (str) –

  • valueLower (Optional[float]) –

  • varLower (Optional[str]) –

  • valueUpper (Optional[float]) –

  • varUpper (Optional[str]) –

  • unit (UnitType) –

class sbmlutils.factory.Uncertainty(sid=None, formula=None, uncertParameters=None, uncertSpans=None, name=None, sboTerm=None, metaId=None, annotations=None, notes=None, keyValuePairs=None, port=None, replacedBy=None)[source]

Bases: Sbase

Uncertainty.

Uncertainty information for Sbase.

Parameters:
  • sid (Optional[str]) –

  • formula (Optional[str]) –

  • uncertParameters (Optional[List[UncertParameter]]) –

  • uncertSpans (Optional[List[UncertSpan]]) –

  • name (Optional[str]) –

  • sboTerm (Optional[str]) –

  • metaId (Optional[str]) –

  • annotations (OptionalAnnotationsType) –

  • notes (Optional[str]) –

  • keyValuePairs (Optional[List[KeyValuePair]]) –

  • port (Any) –

  • replacedBy (Optional[Any]) –

create_sbml(sbase, model)[source]

Create libsbml Uncertainty.

Parameters:
  • sbase (libsbml.SBase) –

  • model (libsbml.Model) –

Returns:

Return type:

libsbml.Uncertainty

class sbmlutils.factory.ExchangeReaction(species_id, compartment=None, fast=False, reversible=True, lowerFluxBound=None, upperFluxBound=None, geneProductAssociation=None, name=None, metaId=None, annotations=None, notes=None, keyValuePairs=None, port=None, uncertainties=None, replacedBy=None)[source]

Bases: Reaction

Exchange reactions define substances which can be exchanged.

This is important for FBC models.

EXCHANGE_IMPORT (-INF, 0): is defined as negative flux through the exchange reaction, i.e. the upper bound must be 0, the lower bound some negative value,

e.g. -INF

EXCHANGE_EXPORT (0, INF): is defined as positive flux through the exchange reaction,

i.e. the lower bound must be 0, the upper bound some positive value, e.g. INF

Parameters:
  • species_id (str) –

  • compartment (Optional[str]) –

  • fast (bool) –

  • reversible (bool) –

  • lowerFluxBound (Optional[str]) –

  • upperFluxBound (Optional[str]) –

  • geneProductAssociation (Optional[str]) –

  • name (Optional[str]) –

  • metaId (Optional[str]) –

  • annotations (OptionalAnnotationsType) –

  • notes (Optional[str]) –

  • keyValuePairs (Optional[List[KeyValuePair]]) –

  • port (Any) –

  • uncertainties (Optional[List[Uncertainty]]) –

  • replacedBy (Optional[Any]) –

PREFIX = 'EX_'[source]
class sbmlutils.factory.GeneProduct(sid, label, associatedSpecies=None, name=None, sboTerm=None, metaId=None, annotations=None, notes=None, keyValuePairs=None, port=None, uncertainties=None, replacedBy=None)[source]

Bases: Sbase

GeneProduct.

GeneProduct is a new FBC class derived from SBML SBase that inherits metaid and sboTerm, as well as the subcomponents for Annotation and Notes. The purpose of this class is to define a single gene product. It implements two required attributes id and label as well as two optional attributes name and associatedSpecies.

Parameters:
  • sid (str) –

  • label (str) –

  • associatedSpecies (Optional[str]) –

  • name (Optional[str]) –

  • sboTerm (Optional[str]) –

  • metaId (Optional[str]) –

  • annotations (OptionalAnnotationsType) –

  • notes (Optional[str]) –

  • keyValuePairs (Optional[List[KeyValuePair]]) –

  • port (Any) –

  • uncertainties (Optional[List[Uncertainty]]) –

  • replacedBy (Optional[Any]) –

create_sbml(model)[source]

Create GeneProduct.

Parameters:

model (libsbml.Model) –

Return type:

libsbml.GeneProduct

class sbmlutils.factory.UserDefinedConstraintComponent(coefficient, variable, variableType=None, sid=None, name=None, sboTerm=None, metaId=None, annotations=None, notes=None, keyValuePairs=None, port=None, uncertainties=None, replacedBy=None)[source]

Bases: Sbase

UserDefinedConstraintComponent.

Parameters:
  • coefficient (float) –

  • variable (str) –

  • variableType (Optional[str]) –

  • sid (Optional[str]) –

  • name (Optional[str]) –

  • sboTerm (Optional[str]) –

  • metaId (Optional[str]) –

  • annotations (OptionalAnnotationsType) –

  • notes (Optional[str]) –

  • keyValuePairs (Optional[List[KeyValuePair]]) –

  • port (Any) –

  • uncertainties (Optional[List[Uncertainty]]) –

  • replacedBy (Optional[Any]) –

create_sbml(constraint)[source]

Create Objective.

Parameters:

constraint (libsbml.UserDefinedConstraint) –

Return type:

libsbml.UserDefinedConstraintComponent

class sbmlutils.factory.UserDefinedConstraint(lowerBound, upperBound, components=None, variableType=libsbml.FBC_VARIABLE_TYPE_LINEAR, sid=None, name=None, sboTerm=None, metaId=None, annotations=None, notes=None, keyValuePairs=None, port=None, uncertainties=None, replacedBy=None)[source]

Bases: Sbase

UserDefinedConstraint.

The FBC UserDefinedConstraint class is derived from SBML SBase and inherits metaid and sboTerm, as well as the subcomponents for Annotation and Notes. It’s purpose is to define non-stoichiometric constraints, that is constraints that are not necessarily defined by the stoichiometrically coupled reaction network. In order to achieve, we defined a new type of linear constraint, the UserDefinedConstraint

Parameters:
  • lowerBound (str) –

  • upperBound (str) –

  • components (Optional[Union[List[UserDefinedConstraintComponent], Dict[str, float]]]) –

  • variableType (str) –

  • sid (Optional[str]) –

  • name (Optional[str]) –

  • sboTerm (Optional[str]) –

  • metaId (Optional[str]) –

  • annotations (OptionalAnnotationsType) –

  • notes (Optional[str]) –

  • keyValuePairs (Optional[List[KeyValuePair]]) –

  • port (Any) –

  • uncertainties (Optional[List[Uncertainty]]) –

  • replacedBy (Optional[Any]) –

create_sbml(model)[source]

Create UserDefinedConstraint.

Parameters:

model (libsbml.Model) –

Return type:

libsbml.UserDefinedConstraint

class sbmlutils.factory.FluxObjective(reaction, coefficient, variableType, sid=None, name=None, sboTerm=None, metaId=None, annotations=None, notes=None, keyValuePairs=None, port=None, uncertainties=None, replacedBy=None)[source]

Bases: Sbase

FluxObjective.

Parameters:
  • reaction (str) –

  • coefficient (float) –

  • variableType (str) –

  • sid (Optional[str]) –

  • name (Optional[str]) –

  • sboTerm (Optional[str]) –

  • metaId (Optional[str]) –

  • annotations (OptionalAnnotationsType) –

  • notes (Optional[str]) –

  • keyValuePairs (Optional[List[KeyValuePair]]) –

  • port (Any) –

  • uncertainties (Optional[List[Uncertainty]]) –

  • replacedBy (Optional[Any]) –

fbc_variable_types: Set[str][source]
classmethod normalize_variable_type(variable_type)[source]

Normalize variable type.

Parameters:

variable_type (str) –

Return type:

str

create_sbml(objective)[source]

Create Objective.

Parameters:

objective (libsbml.Objective) –

Return type:

libsbml.FluxObjective

class sbmlutils.factory.Objective(sid, objectiveType=libsbml.OBJECTIVE_TYPE_MAXIMIZE, active=True, fluxObjectives=None, variableType=libsbml.FBC_VARIABLE_TYPE_LINEAR, name=None, sboTerm=None, metaId=None, annotations=None, notes=None, keyValuePairs=None, port=None, uncertainties=None, replacedBy=None)[source]

Bases: Sbase

Objective.

Parameters:
  • sid (str) –

  • objectiveType (str) –

  • active (bool) –

  • fluxObjectives (Optional[Union[List[FluxObjective], Dict[str, float]]]) –

  • variableType (str) –

  • name (Optional[str]) –

  • sboTerm (Optional[str]) –

  • metaId (Optional[str]) –

  • annotations (OptionalAnnotationsType) –

  • notes (Optional[str]) –

  • keyValuePairs (Optional[List[KeyValuePair]]) –

  • port (Any) –

  • uncertainties (Optional[List[Uncertainty]]) –

  • replacedBy (Optional[Any]) –

objective_types: Set[str][source]
classmethod normalize_objective_type(objective_type)[source]

Normalize objective type.

Parameters:

objective_type (str) –

Return type:

str

create_sbml(model)[source]

Create Objective.

Parameters:

model (libsbml.Model) –

Return type:

libsbml.Objective

class sbmlutils.factory.ModelDefinition(sid, name=None, sboTerm=None, metaId=None, annotations=None, notes=None, keyValuePairs=None, units=None, compartments=None, species=None)[source]

Bases: Sbase

ModelDefinition.

Parameters:
  • sid (str) –

  • name (Optional[str]) –

  • sboTerm (Optional[str]) –

  • metaId (Optional[str]) –

  • annotations (OptionalAnnotationsType) –

  • notes (Optional[str]) –

  • keyValuePairs (Optional[List[KeyValuePair]]) –

  • units (Optional[Type[Units]]) –

  • compartments (Optional[List[Compartment]]) –

  • species (Optional[List[Species]]) –

create_sbml(model)[source]

Create ModelDefinition.

Parameters:

model (libsbml.Model) –

Return type:

libsbml.ModelDefinition

_set_fields(sbase, model)[source]

Set fields on ModelDefinition.

Parameters:
  • sbase (libsbml.ModelDefinition) –

  • model (libsbml.Model) –

Return type:

None

class sbmlutils.factory.ExternalModelDefinition(sid, source, modelRef, md5=None, name=None, sboTerm=None, metaId=None, annotations=None, notes=None, keyValuePairs=None)[source]

Bases: Sbase

ExternalModelDefinition.

Parameters:
  • sid (str) –

  • source (str) –

  • modelRef (str) –

  • md5 (Optional[str]) –

  • name (Optional[str]) –

  • sboTerm (Optional[str]) –

  • metaId (Optional[str]) –

  • annotations (OptionalAnnotationsType) –

  • notes (Optional[str]) –

  • keyValuePairs (Optional[List[KeyValuePair]]) –

create_sbml(model)[source]

Create ExternalModelDefinition.

Parameters:

model (libsbml.Model) –

Return type:

libsbml.ExternalModelDefinition

_set_fields(sbase, model)[source]

Set fields on ExternalModelDefinition.

Parameters:
  • sbase (libsbml.ExternalModelDefinition) –

  • model (libsbml.Model) –

Return type:

None

class sbmlutils.factory.Submodel(sid, modelRef=None, timeConversionFactor=None, extentConversionFactor=None, name=None, sboTerm=None, metaId=None, annotations=None, notes=None, keyValuePairs=None)[source]

Bases: Sbase

Submodel.

Parameters:
  • sid (str) –

  • modelRef (Optional[str]) –

  • timeConversionFactor (Optional[str]) –

  • extentConversionFactor (Optional[str]) –

  • name (Optional[str]) –

  • sboTerm (Optional[str]) –

  • metaId (Optional[str]) –

  • annotations (OptionalAnnotationsType) –

  • notes (Optional[str]) –

  • keyValuePairs (Optional[List[KeyValuePair]]) –

create_sbml(model)[source]

Create SBML Submodel.

Parameters:

model (libsbml.Model) –

Return type:

libsbml.Submodel

_set_fields(sbase, model)[source]
Parameters:
  • sbase (libsbml.Submodel) –

  • model (libsbml.Model) –

Return type:

None

class sbmlutils.factory.ReplacedElement(sid, elementRef, submodelRef, deletion=None, conversionFactor=None, portRef=None, idRef=None, unitRef=None, metaIdRef=None, name=None, sboTerm=None, metaId=None, annotations=None, notes=None, keyValuePairs=None)[source]

Bases: SbaseRef

ReplacedElement.

Parameters:
  • sid (str) –

  • elementRef (str) –

  • submodelRef (str) –

  • deletion (Optional[str]) –

  • conversionFactor (Optional[str]) –

  • portRef (Optional[str]) –

  • idRef (Optional[str]) –

  • unitRef (Optional[str]) –

  • metaIdRef (Optional[str]) –

  • name (Optional[str]) –

  • sboTerm (Optional[str]) –

  • metaId (Optional[str]) –

  • annotations (OptionalAnnotationsType) –

  • notes (Optional[str]) –

  • keyValuePairs (Optional[List[KeyValuePair]]) –

create_sbml(model)[source]

Create SBML ReplacedElement.

Parameters:

model (libsbml.Model) –

Return type:

libsbml.ReplacedElement

_set_fields(sbase, model)[source]
Parameters:
  • sbase (libsbml.ReplacedElement) –

  • model (libsbml.Model) –

Return type:

None

class sbmlutils.factory.ReplacedBy(sid, elementRef, submodelRef, portRef=None, idRef=None, unitRef=None, metaIdRef=None, name=None, sboTerm=None, metaId=None, annotations=None, notes=None, keyValuePairs=None)[source]

Bases: SbaseRef

ReplacedBy.

Parameters:
  • sid (str) –

  • elementRef (str) –

  • submodelRef (str) –

  • portRef (Optional[str]) –

  • idRef (Optional[str]) –

  • unitRef (Optional[str]) –

  • metaIdRef (Optional[str]) –

  • name (Optional[str]) –

  • sboTerm (Optional[str]) –

  • metaId (Optional[str]) –

  • annotations (OptionalAnnotationsType) –

  • notes (Optional[str]) –

  • keyValuePairs (Optional[List[KeyValuePair]]) –

create_sbml(sbase, model)[source]

Create SBML ReplacedBy.

Parameters:
  • sbase (libsbml.SBase) –

  • model (libsbml.Model) –

Return type:

libsbml.ReplacedBy

_set_fields(rby, model)[source]

Set fields in ReplacedBy.

Parameters:
  • rby (libsbml.ReplacedBy) –

  • model (libsbml.Model) –

Return type:

None

class sbmlutils.factory.Deletion(sid, submodelRef, portRef=None, idRef=None, unitRef=None, metaIdRef=None, name=None, sboTerm=None, metaId=None, annotations=None, notes=None, keyValuePairs=None)[source]

Bases: SbaseRef

Deletion.

Parameters:
  • sid (str) –

  • submodelRef (str) –

  • portRef (Optional[str]) –

  • idRef (Optional[str]) –

  • unitRef (Optional[str]) –

  • metaIdRef (Optional[str]) –

  • name (Optional[str]) –

  • sboTerm (Optional[str]) –

  • metaId (Optional[str]) –

  • annotations (OptionalAnnotationsType) –

  • notes (Optional[str]) –

  • keyValuePairs (Optional[List[KeyValuePair]]) –

create_sbml(model)[source]

Create SBML Deletion.

Parameters:

model (libsbml.Model) –

Return type:

libsbml.Deletion

_set_fields(sbase, model)[source]

Set fields on Deletion.

Parameters:
  • sbase (libsbml.Deletion) –

  • model (libsbml.Model) –

Return type:

None

class sbmlutils.factory.PortType[source]

Bases: str, enum.Enum

Supported port types.

PORT = 'port'[source]
INPUT_PORT = 'input port'[source]
OUTPUT_PORT = 'output port'[source]
class sbmlutils.factory.Port(sid, portRef=None, idRef=None, unitRef=None, metaIdRef=None, portType=PortType.PORT, name=None, sboTerm=None, metaId=None, annotations=None, notes=None, keyValuePairs=None)[source]

Bases: SbaseRef

Port.

Ports are stored in an optional child ListOfPorts object, which, if present, must contain one or more Port objects. All of the Ports present in the ListOfPorts collectively define the ‘port interface’ of the Model.

Parameters:
  • sid (str) –

  • portRef (Optional[str]) –

  • idRef (Optional[str]) –

  • unitRef (Optional[str]) –

  • metaIdRef (Optional[str]) –

  • portType (Optional[PortType]) –

  • name (Optional[str]) –

  • sboTerm (Optional[str]) –

  • metaId (Optional[str]) –

  • annotations (OptionalAnnotationsType) –

  • notes (Optional[str]) –

  • keyValuePairs (Optional[List[KeyValuePair]]) –

create_sbml(model)[source]

Create SBML for Port.

Parameters:

model (libsbml.Model) –

Return type:

libsbml.Port

_set_fields(sbase, model)[source]

Set fields on Port.

Parameters:
  • sbase (libsbml.Port) –

  • model (libsbml.Model) –

Return type:

None

class sbmlutils.factory.Package[source]

Bases: str, enum.Enum

Supported/tested packages.

COMP = 'comp'[source]
COMP_V1 = 'comp-v1'[source]
DISTRIB = 'distrib'[source]
DISTRIB_V1 = 'distrib-v1'[source]
FBC = 'fbc'[source]
FBC_V2 = 'fbc-v2'[source]
FBC_V3 = 'fbc-v3'[source]
class sbmlutils.factory.ModelDict[source]

Bases: TypedDict

ModelDict.

The ModelDict allows to define the Model as dictionary and then use:

md: ModelDict Model(**md)

For model construction. If possible use the Model object directly.

sid: str[source]
name: str | None[source]
sboTerm: str | None[source]
metaId: str | None[source]
annotations: OptionalAnnotationsType[source]
notes: str | None[source]
keyValuePairs: List[KeyValuePair] | None[source]
packages: List[Package] | None[source]
creators: List[pymetadata.core.creator.Creator] | None[source]
model_units: ModelUnits | None[source]
objects: List[Sbase] | None[source]
units: Type[Units] | None[source]
functions: List[Function] | None[source]
compartments: List[Compartment] | None[source]
species: List[Species] | None[source]
parameters: List[Parameter] | None[source]
assignments: List[InitialAssignment] | None[source]
rules: List[AssignmentRule] | None[source]
rate_rules: List[RateRule] | None[source]
algebraic_rules: List[AlgebraicRule] | None[source]
reactions: List[Reaction] | None[source]
events: List[Event] | None[source]
constraints: List[Constraint] | None[source]
external_model_definitions: List[ExternalModelDefinition] | None[source]
model_definitions: List[ModelDefinition] | None[source]
submodels: List[Submodel] | None[source]
ports: List[Port] | None[source]
replaced_elements: List[ReplacedElement] | None[source]
deletions: List[Deletion] | None[source]
user_defined_constraints: List[UserDefinedConstraint] | None[source]
objectives: List[Objective] | None[source]
gene_products: List[GeneProduct] | None[source]
layouts: List | None[source]
class sbmlutils.factory.Model(sid, name=None, sboTerm=None, metaId=None, annotations=None, notes=None, keyValuePairs=None, packages=None, creators=None, model_units=None, units=None, objects=None, external_model_definitions=None, model_definitions=None, submodels=None, functions=None, compartments=None, species=None, parameters=None, assignments=None, rules=None, rate_rules=None, algebraic_rules=None, reactions=None, events=None, constraints=None, ports=None, replaced_elements=None, deletions=None, user_defined_constraints=None, objectives=None, gene_products=None, layouts=None)[source]

Bases: Sbase, sbmlutils.utils.FrozenClass, pydantic.BaseModel

Model.

Parameters:
  • sid (str) –

  • name (Optional[str]) –

  • sboTerm (Optional[str]) –

  • metaId (Optional[str]) –

  • annotations (OptionalAnnotationsType) –

  • notes (Optional[str]) –

  • keyValuePairs (Optional[List[KeyValuePair]]) –

  • packages (Optional[List[Package]]) –

  • creators (Optional[List[pymetadata.core.creator.Creator]]) –

  • model_units (Optional[ModelUnits]) –

  • units (Optional[Type[Units]]) –

  • objects (Optional[List[Sbase]]) –

  • external_model_definitions (Optional[List[ExternalModelDefinition]]) –

  • model_definitions (Optional[List[ModelDefinition]]) –

  • submodels (Optional[List[Submodel]]) –

  • functions (Optional[List[Function]]) –

  • compartments (Optional[List[Compartment]]) –

  • species (Optional[List[Species]]) –

  • parameters (Optional[List[Parameter]]) –

  • assignments (Optional[List[InitialAssignment]]) –

  • rules (Optional[List[AssignmentRule]]) –

  • rate_rules (Optional[List[RateRule]]) –

  • algebraic_rules (Optional[List[AlgebraicRule]]) –

  • reactions (Optional[List[Reaction]]) –

  • events (Optional[List[Event]]) –

  • constraints (Optional[List[Constraint]]) –

  • ports (Optional[List[Port]]) –

  • replaced_elements (Optional[List[ReplacedElement]]) –

  • deletions (Optional[List[Deletion]]) –

  • user_defined_constraints (Optional[List[UserDefinedConstraint]]) –

  • objectives (Optional[List[Objective]]) –

  • gene_products (Optional[List[GeneProduct]]) –

  • layouts (Optional[List]) –

class Config[source]

Pydantic configuration.

arbitrary_types_allowed = True[source]
sid: str[source]
name: str | None[source]
sboTerm: str | None[source]
metaId: str | None[source]
annotations: AnnotationsType[source]
notes: str | None[source]
keyValuePairs: List[KeyValuePair] | None[source]
port: Any | None[source]
packages: List[Package][source]
creators: List[pymetadata.core.creator.Creator][source]
model_units: ModelUnits | None[source]
units: Type[Units] | None[source]
functions: List[Function][source]
compartments: List[Compartment][source]
species: List[Species][source]
parameters: List[Parameter][source]
assignments: List[InitialAssignment][source]
rules: List[AssignmentRule][source]
rate_rules: List[RateRule][source]
algebraic_rules: List[AlgebraicRule][source]
reactions: List[Reaction][source]
events: List[Event][source]
constraints: List[Constraint][source]
external_model_definitions: List[ExternalModelDefinition][source]
model_definitions: List[ModelDefinition][source]
submodels: List[Submodel][source]
ports: List[Port][source]
replaced_elements: List[ReplacedElement][source]
deletions: List[Deletion][source]
user_defined_constraints: List[UserDefinedConstraint][source]
objectives: List[Objective][source]
gene_products: List[GeneProduct][source]
layouts: List | None[source]
_keys[source]
_supported_packages[source]
__str__()[source]

Get string.

Return type:

str

create_sbml(doc)[source]

Create Model.

To create the complete SBMLDocument with the model use:

doc = Document(model=model).create_sbml()

Parameters:

doc (libsbml.SBMLDocument) –

Return type:

libsbml.Model

get_sbml()[source]

Create SBML model.

Return type:

str

check_packages(packages)[source]

Check that all provided packages are supported.

Parameters:

packages (Optional[List[Package]]) –

Return type:

List[Package]

static merge_models(models)[source]

Merge information from multiple models.

Parameters:

models (Iterable[Model]) –

Return type:

Model

class sbmlutils.factory.Document(model, sid=None, name=None, sboTerm=None, metaId=None, annotations=None, notes=None, keyValuePairs=None, sbml_level=SBML_LEVEL, sbml_version=SBML_VERSION)[source]

Bases: Sbase

Document.

Parameters:
  • model (Model) –

  • sid (Optional[str]) –

  • name (Optional[str]) –

  • sboTerm (Optional[str]) –

  • metaId (Optional[str]) –

  • annotations (OptionalAnnotationsType) –

  • notes (Optional[str]) –

  • keyValuePairs (Optional[List[KeyValuePair]]) –

  • sbml_level (int) –

  • sbml_version (int) –

create_sbml()[source]

Create SBML model.

Return type:

libsbml.SBMLDocument

get_sbml()[source]

Return SBML string of the model.

Returns:

SBML string

Return type:

str

get_json()[source]

Get JSON representation.

Return type:

str

class sbmlutils.factory.FactoryResult[source]

Data structure for model creation.

model: Model[source]
sbml_path: pathlib.Path[source]
sbmlutils.factory.create_model(model, filepath, sbml_level=SBML_LEVEL, sbml_version=SBML_VERSION, validate=True, validation_options=None, show_sbml=False, annotations=None)[source]

Create SBML model from models.

This is the entry point for creating models. If multiple models are provided these are merged in the process of model creation. See merge_models for more details.

Additional model annotations can be provided via a file.

Parameters:
  • model (Union[Model, Iterable[Model]]) – Model or iterable of Model instances which are merged in single model

  • filepath (pathlib.Path) – Path to write the SBML model to

  • sbml_level (int) – set SBML level for model generation

  • sbml_version (int) – set SBML version for model generation

  • validate (bool) – boolean flag to validate the SBML file

  • validation_options (Optional[sbmlutils.validation.ValidationOptions]) – options for model validation

  • show_sbml (bool) – boolean flag to show SBML

  • annotations (Optional[pathlib.Path]) – Path to annotations file

Returns:

FactoryResult

Return type:

FactoryResult