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, EVENT_PREFIX and the position of the event among the events of the model for an event without an id, the id the engines give it and the messages name it by.

trigger str | None

the trigger, MathML of selections which sbmlsim.sbml_math.compile_math compiles, None without a trigger. A trigger which it does not compile, one with rateOf or delay, 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 MathML of every assignment.

priority str | None

the MathML of the priority, 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(),
    initial_concentration_values=dict(),
    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 keys of initial_assignment_dependencies, an entity after the ones it depends on.

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

entity whose initial value the initialization evaluates again -> the entities it depends on, through assignment rules: the math of an initial assignment, and for a species in a compartment of an assignment rule, whose initial value is converted with the size of the compartment at the initialization, the compartment (#344). Such a species is a key also without an initial assignment.

initial_concentration frozenset[str]

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

initial_concentration_values dict[str, float]

species without an initial assignment -> its initial concentration, which the initialization sets again when the size of its compartment of an assignment rule changed.

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.

selection_math

selection_math(math, concentrations, functions)

Get the math of a model as MathML of selections.

A species whose value is a concentration in the math of the model, i.e. a species without only substance units, is its concentration [S], every other identifier its id. The function definitions of the model are expanded, the units of the numbers removed, see sbmlsim.sbml_math.compile_math.

Parameters:

Name Type Description Default
math ASTNode | None

the math.

required
concentrations frozenset[str]

the species which are concentrations in the math.

required
functions ListOfFunctionDefinitions

the function definitions of the model.

required

Returns:

Type Description
str | None

The MathML, None without math.