Skip to content

model.symbols

The symbols of a model which a simulation can change.

A target of a change is named like a selection of roadrunner: S is the amount of a species, [S] its concentration, a parameter or a compartment is its id. ModelSymbols reads what the targets of a model are from its SBML once and answers what kind a target is, which the compile step and the executor need: a compartment change keeps the concentration of the species in it, a parameter with an initial assignment cannot be set before the initialization without deriving the model, and the target of an assignment rule cannot be set at all.

EventSymbols dataclass

EventSymbols(
    eid,
    trigger,
    delayed,
    assignments,
    priority=None,
    use_values_from_trigger_time=True,
    persistent=True,
)

An event of a model in the selections of roadrunner.

The executor fires an event whose trigger a change of a simulation makes true, which roadrunner does not, see sbmlsim.simulator.executor.

Attributes:

Name Type Description
eid str

id of the event.

trigger str | None

the trigger, a formula of selections, see sbmlsim.simulator.formula, None without a trigger. A trigger which is no formula the simulator evaluates, e.g. one with a function definition, is reported by the executor and a change does not fire its event.

delayed bool

whether the event has a delay.

assignments tuple[tuple[str, str], ...]

the selection and the formula of every assignment.

priority str | None

the priority formula, or None without a priority.

use_values_from_trigger_time bool

evaluate assignments when triggered.

persistent bool

keep the event when its trigger becomes false.

TargetKind

Bases: StrEnum

The kind of a target of a change.

ModelSymbols dataclass

ModelSymbols(
    parameters,
    compartments,
    species,
    species_compartment,
    only_substance,
    initial_assignments,
    assignment_rules,
    rate_rules,
    initial_assignment_order=(),
    initial_assignment_dependencies=None,
    initial_concentration=frozenset(),
    events=(),
    time_dependent=False,
)

The entities of a model a simulation refers to.

Attributes:

Name Type Description
parameters frozenset[str]

ids of the global parameters.

compartments frozenset[str]

ids of the compartments.

species frozenset[str]

ids of the species.

species_compartment dict[str, str]

species -> its compartment.

only_substance frozenset[str]

species with hasOnlySubstanceUnits=true.

initial_assignments frozenset[str]

entities with an initial assignment.

assignment_rules frozenset[str]

entities which are the variable of an assignment rule.

rate_rules frozenset[str]

entities which are the variable of a rate rule.

initial_assignment_order tuple[str, ...]

the entities with an initial assignment, an assignment after the ones it reads.

initial_assignment_dependencies dict[str, frozenset[str]] | None

entity with an initial assignment -> the entities its math reads, through assignment rules.

initial_concentration frozenset[str]

species whose initial value is a concentration, which a change of their compartment before the initialization keeps.

events tuple[EventSymbols, ...]

the symbols of the events.

time_dependent bool

whether a math of the model reads the csymbol time or delay, or an event has a delay, see sbmlsim.simulator.executor. roadrunner keeps a pending event at a time of its clock, so an event with a delay needs the absolute time.

from_sbml classmethod

from_sbml(sbml)

Read the symbols of a model.

Parameters:

Name Type Description Default
sbml str | Path

path of the SBML file or the SBML itself.

required

Returns:

Type Description
ModelSymbols

The symbols of the model.

entity staticmethod

entity(target)

Get the entity of a target, the species of a concentration [S].

kind

kind(target)

Get the kind of a target.

Parameters:

Name Type Description Default
target str

S for the amount of a species, [S] for its concentration, or the id of a parameter or a compartment.

required

Returns:

Type Description
TargetKind

The kind of the target.

Raises:

Type Description
ValueError

if the model has no such entity, if a concentration is not one of a species, or if the entity is the variable of an assignment rule, which a change cannot set.