Skip to content

Kinetics

Reaction kinetics shared by the biology packages.

They cover compartments, molecular species, saturating reactions, and repression.

CompartmentElement(label, *, x=0.0, size=None, space=None)

Bases: NonnegativeElement

Compartment, the amount x of units in one named state, as a count or a fraction.

The label of the element names the compartment, such as 'S', 'I', or 'plasma'. A compartment has no laws of its own, and the reactions and flows of epidemics, pharmacokinetics, and populations move its units.

Parameters:

Name Type Description Default
label str

The label of the compartment, unique among the components of its system.

required
x Annotated[object, closed_open(0, oo)]

The initial amount, a nonnegative count or fraction.

0.0
size int | None

The number of members, or None for one.

None
space BaseSpace | None

The space with one member per site, such as a lattice of classes, or None for none.

None

Examples:

>>> from skcomplex.core.systems import System
>>> from skcomplex.systems.biology.common.kinetics import CompartmentElement
>>> system = System(elements=[CompartmentElement('S', x=990), CompartmentElement('I', x=10)]).prepare()
>>> system.parameters_
('S.x', 'I.x')
Source code in src/skcomplex/systems/biology/common/kinetics/_compartment.py
42
43
44
45
46
47
48
49
50
def __init__(
    self,
    label: str,
    *,
    x: Annotated[object, RealSet.closed_open(0, oo)] = 0.0,
    size: int | None = None,
    space: BaseSpace | None = None,
) -> None:
    super().__init__(label, x=x, size=size, space=space)

MichaelisMentenInteraction(label, *, target=None, reactants=None, products=None, substrate='x', vmax=1.0, km=1.0, modifiers=None, mode='rate')

Bases: ReactionInteraction

Reaction at the Michaelis-Menten propensity vmax S / (km + S).

The propensity is multiplied by every modifier to its coefficient.

The substrate S is a state of the target, or a function of the namespace that returns an amount that is no state of its own, such as the phosphorylated form A_T - A of a protein whose total is conserved. The modifiers are the enzymes that catalyse the reaction, which scale the propensity but do not change, so vmax is a catalytic rate when the reaction has modifiers and a maximal rate when it has none. The maximal rate and the Michaelis constant are functions of the namespace, which reads the parameters of the target, or numbers.

Parameters:

Name Type Description Default
label str

The label of the reaction, unique among the components of its system.

required
target str | None

The path of the element, group, or field whose states the species named by a state alone are.

None
reactants Stoichiometry | None

The coefficients of the reactants, or None for a source.

None
products Stoichiometry | None

The coefficients of the products, or None for a sink.

None
substrate str | Callable[[SimpleNamespace], object]

The name of the state of the target that saturates the propensity, or a function of the namespace that returns the amount that does.

'x'
vmax Callable[[SimpleNamespace], object] | float

A function of the namespace that returns the maximal or catalytic rate, or a number.

1.0
km Callable[[SimpleNamespace], object] | float

A function of the namespace that returns the Michaelis constant, or a number.

1.0
modifiers Stoichiometry | None

The coefficients of the modifiers, the enzymes that scale the propensity, or None.

None
mode str

The form of the laws, 'rate', 'jump', or 'langevin'.

'rate'

Raises:

Type Description
ValidationError

The substrate is neither a name nor a function, a rate is neither a function nor a number, or the reaction cannot take its species or mode.

Examples:

>>> from skcomplex.systems.biology.common.kinetics import CompartmentElement
>>> from skcomplex.core.systems import System
>>> from skcomplex.systems.biology.common.kinetics import MichaelisMentenInteraction
>>> uptake = MichaelisMentenInteraction(
...     'uptake', target='cell', reactants={'x': 1}, substrate='x', vmax=1.0, km=100.0
... )
>>> system = System(elements=[CompartmentElement('cell', x=500.0)], interactions=[uptake])
>>> trajectory = system.prepare().simulate(until=10.0, dt=1.0)
>>> round(float(trajectory.get_values('cell.x')[-1]), 3)
491.679
Source code in src/skcomplex/systems/biology/common/kinetics/_michaelis_menten.py
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
def __init__(
    self,
    label: str,
    *,
    target: str | None = None,
    reactants: Stoichiometry | None = None,
    products: Stoichiometry | None = None,
    substrate: str | Callable[[SimpleNamespace], object] = 'x',
    vmax: Callable[[SimpleNamespace], object] | float = 1.0,
    km: Callable[[SimpleNamespace], object] | float = 1.0,
    modifiers: Stoichiometry | None = None,
    mode: str = 'rate',
) -> None:
    super().__init__(label, target=target, reactants=reactants, products=products, modifiers=modifiers, mode=mode)
    self.substrate = substrate
    self.vmax = vmax
    self.km = km

RepressionInteraction(label, *, reactants=None, products=None, modifiers=None, alpha=1.0, alpha0=0.0, K=1.0, n=1.0, mode='rate')

Bases: ReactionInteraction

Synthesis of a product at the rate alpha0 + alpha (1 - hill(y, K, n)).

The synthesis is repressed by a modifier y.

The product, such as the mRNA of a gene, gains units at the leaky rate alpha0 plus the rate alpha lowered by the decreasing Hill function 1 / (1 + (y / K)^n) of the one modifier, the repressor. The repressor enters the rate and does not change. In the mode 'jump' every synthesis is a random event that adds one unit.

Parameters:

Name Type Description Default
label str

The label of the repression.

required
reactants Stoichiometry | None

The coefficients of the reactants, or None for a synthesis from a source.

None
products Stoichiometry | None

The coefficient of the synthesized state, such as {('gene', 'm'): 1}.

None
modifiers Stoichiometry | None

The coefficient of the repressor state, such as {('repressor', 'p'): 1}.

None
alpha Annotated[float, closed_open(0, oo)]

The synthesis rate without repressor.

1.0
alpha0 Annotated[float, closed_open(0, oo)]

The leaky synthesis rate at saturating repressor.

0.0
K Annotated[float, open(0, oo)]

The repressor amount at half repression.

1.0
n Annotated[float, open(0, oo)]

The Hill coefficient of the repression.

1.0
mode str

The form of the laws, 'rate', 'jump', or 'langevin'.

'rate'

Raises:

Type Description
ValidationError

The mode is unknown, the reaction has neither reactants nor products, or an entry is not a pair of a path and a state name with a positive coefficient.

Examples:

>>> from skcomplex.core.systems import System
>>> from skcomplex.systems.biology.systems_biology import RepressionInteraction, SpeciesElement
>>> repression = RepressionInteraction(
...     'repression', products={('mRNA', 'x'): 1}, modifiers={('repressor', 'x'): 1}, alpha=2.0, K=1.0
... )
>>> species = [SpeciesElement('mRNA'), SpeciesElement('repressor', x=1.0)]
>>> trajectory = System(elements=species, interactions=[repression]).prepare().simulate(until=1.0, dt=0.1)
>>> round(float(trajectory.get_values('mRNA.x')[-1]), 3)
1.0
Source code in src/skcomplex/systems/biology/common/kinetics/_repression.py
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
def __init__(
    self,
    label: str,
    *,
    reactants: Stoichiometry | None = None,
    products: Stoichiometry | None = None,
    modifiers: Stoichiometry | None = None,
    alpha: Annotated[float, RealSet.closed_open(0, oo)] = 1.0,
    alpha0: Annotated[float, RealSet.closed_open(0, oo)] = 0.0,
    K: Annotated[float, RealSet.open(0, oo)] = 1.0,
    n: Annotated[float, RealSet.open(0, oo)] = 1.0,
    mode: str = 'rate',
) -> None:
    super().__init__(label, reactants=reactants, products=products, modifiers=modifiers, mode=mode)
    self.alpha = alpha
    self.alpha0 = alpha0
    self.K = K
    self.n = n

SpeciesElement(label, *, x=0.0, size=None, space=None)

Bases: NonnegativeElement

Molecular species with a nonnegative concentration x.

It is an mRNA, an enzyme, a messenger, or a metabolite.

A species has no laws of its own, and reactions synthesize, convert, and degrade it.

Parameters:

Name Type Description Default
label str

The label of the species.

required
x Annotated[object, closed_open(0, oo)]

The initial concentration.

0.0
size int | None

The number of members, or None for one.

None
space BaseSpace | None

The space with one member per site, such as a lattice of classes, or None for none.

None

Examples:

>>> from skcomplex.systems.biology.systems_biology import SpeciesElement
>>> SpeciesElement('camp', x=2.0).x
2.0
Source code in src/skcomplex/systems/biology/common/kinetics/_species.py
41
42
43
44
45
46
47
48
49
def __init__(
    self,
    label: str,
    *,
    x: Annotated[object, RealSet.closed_open(0, oo)] = 0.0,
    size: int | None = None,
    space: BaseSpace | None = None,
) -> None:
    super().__init__(label, x=x, size=size, space=space)