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,
initial_value=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, MathML of selections which
|
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 |
use_values_from_trigger_time |
bool
|
evaluate assignments when triggered. |
persistent |
bool
|
keep the event when its trigger becomes false. |
initial_value |
bool
|
the value of the trigger before the time 0, an event whose trigger is false then and true at the start fires at the start. |
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 |
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 |
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 |
from_sbml
classmethod
¶
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
¶
Get the entity of a target, the species of a concentration [S].
kind
¶
Get the kind of a target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
|
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. |
read_document
¶
Read the document of SBML text, once for the reads of a model.
The load of a model reads its SBML for its level, the package comp, its
symbols, its units, its name and its selections, and the key of a run of
experiments reads it for comp again: every read of a large model took
a tenth of a second (0.11 s for the HCTZ model of pkdb_models), half the
load of a model in the engine core. The document of the SBML read last
is kept, so these reads parse the text once; the text is compared, not
its path, so a file which changed is read again. One document is kept,
so the memory of the documents of the process stays that of one model
(about twenty times its text).
The document is shared: a caller reads it and never changes it, e.g. a
conversion of its level or the parameters added to a model work on a
document of their own (libsbml.readSBMLFromString). A caller keeps the
document while it uses an element of it, e.g. the model, since libsbml
frees the elements with their document.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sbml
|
str
|
the SBML. |
required |
Returns:
| Type | Description |
|---|---|
SBMLDocument
|
The document of the SBML, with the errors libsbml reported reading it. |
selection_math
¶
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, |