sbmlutils.reaction_equation

Module for parsing reaction equation strings.

Various string formats are allowed which are subsequently brought into an internal standard format.

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 =>’,

In addition, variable stoichiometries can be used, by providing sids as stoichiometries. Examples of valid equations with variable stoichiometries are:

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

Module Contents

Classes

EquationPart

EquationPart.

ReactionEquation

Representation of stoichiometric equations with modifiers.

Attributes

REVERSIBILITY_PATTERN

IRREVERSIBILITY_PATTERN

MODIFIER_PATTERN

REVERSIBILITY_SEPARATOR

IRREVERSIBILITY_SEPARATOR

examples

class sbmlutils.reaction_equation.EquationPart[source]

EquationPart.

# FIXME: this must be a SpeciesReference, but circular imports!

An equation consists of parts which define species with their respective stoichiometries. The stoichiometries could be constant or vary over time.

The sid may be target of an InitialAssignment, EventAssignment or Rule.

Two main cases exists: 1. stoichiometry=float, constant=True

The EquationPart has a constant stoichiometry and does not change in the simulation. It could be set via an InitialAssignment if an sid is provided.

  1. stoichiometry=None, constant=False, sid=str

species: str[source]
stoichiometry: float | None[source]
sid: str | None[source]
constant: bool = True[source]
metaId: str | None[source]
sboTerm: str | None[source]
name: str | None[source]
annotations: List | None[source]
notes: str | None[source]
keyValuePairs: List[Any] | None[source]
sbmlutils.reaction_equation.REVERSIBILITY_PATTERN: Final = '<[-=]>'[source]
sbmlutils.reaction_equation.IRREVERSIBILITY_PATTERN: Final = '[-=]>'[source]
sbmlutils.reaction_equation.MODIFIER_PATTERN: Final = '\\[.*\\]'[source]
sbmlutils.reaction_equation.REVERSIBILITY_SEPARATOR: Final = '<=>'[source]
sbmlutils.reaction_equation.IRREVERSIBILITY_SEPARATOR: Final = '=>'[source]
class sbmlutils.reaction_equation.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

sbmlutils.reaction_equation.examples = ['1.0 S1 + 2 S2 => 2.0 P1 + 2 P2 [M1, M2]', 'c__gal1p => c__gal + c__phos', 'e__h2oM <->...[source]