libSBML C API
5.18.0
|
An Event_t object defines when the event can occur, the variables that are affected by the event, and how the variables are affected. The effect of the event can optionally be delayed after the occurrence of the condition which invokes it. An event delay is defined using an object of class Delay_t.
The object class Delay_t is derived from SBase_t and adds a single subelement called "math". This subelement is used to hold MathML content. The mathematical formula represented by "math" must evaluate to a numerical value. It is used as the length of time between when the event is triggered and when the event's assignments are actually executed. If no delay is present on a given Event_t, a time delay of zero is assumed.
The expression in "math" must be evaluated at the time the event is triggered. The expression must always evaluate to a nonnegative number (otherwise, a nonsensical situation could arise where an event is defined to execute before it is triggered!).
In SBML Level 2 versions before Version 4, the units of the numerical value computed by the Delay_t's "math" expression are required to be in units of time, or the model is considered to have a unit consistency error. In Level 2 Version 4 as well as SBML Level 3, this requirement is relaxed; these specifications only stipulate that the units of the numerical value computed by a Delay_t instance's "math" expression should match the model's units of time (meaning the definition of the time
units in the model). LibSBML respects these requirements, and depending on whether an earlier Version of SBML Level 2 is in use, libSBML may or may not flag unit inconsistencies as errors or merely warnings.
Note that units are not predefined or assumed for the contents of "math" in a Delay_t object; rather, they must be defined explicitly for each instance of a Delay_t object in a model. This is an important point to bear in mind when literal numbers are used in delay expressions. For example, the following Event_t instance would result in a warning logged by SBMLDocument_t::checkConsistency() about the fact that libSBML cannot verify the consistency of the units of the expression. The reason is that the formula inside the "math" element does not have any declared units, whereas what is expected in this context is units of time:
<model> ... <listOfEvents> <event useValuesFromTriggerTime="true"> ... <delay> <math xmlns="http://www.w3.org/1998/Math/MathML"> <cn> 1 </cn> </math> </delay> ... </event> </listOfEvents> ... </model>
The <cn> 1 </cn>
within the mathematical formula of the delay
above has no units declared. To make the expression have the needed units of time, literal numbers should be avoided in favor of defining Parameter_t objects for each quantity, and declaring units for the Parameter_t values. The following fragment of SBML illustrates this approach:
<model> ... <listOfParameters> <parameter id="transcriptionDelay" value="10" units="second"/> </listOfParameters> ... <listOfEvents> <event useValuesFromTriggerTime="true"> ... <delay> <math xmlns="http://www.w3.org/1998/Math/MathML"> <ci> transcriptionDelay </ci> </math> </delay> ... </event> </listOfEvents> ... </model>
In SBML Level 3, an alternative approach is available in the form of the units
attribute, which SBML Level 3 allows to appear on MathML cn
elements. The value of this attribute can be used to indicate the unit of measurement to be associated with the number in the content of a cn
element. The attribute is named units
but, because it appears inside MathML element (which is in the XML namespace for MathML and not the namespace for SBML), it must always be prefixed with an XML namespace prefix for an SBML Level 3 namespace. The following is an example of this approach:
<model timeUnits="second" ...> ... <listOfEvents> <event useValuesFromTriggerTime="true"> ... <delay> <math xmlns="http://www.w3.org/1998/Math/MathML" xmlns:sbml="http://www.sbml.org/sbml/level3/version1/core"> <cn sbml:units="second"> 10 </cn> </math> </delay> ... </event> </listOfEvents> ... </model>
In SBML Level 3 Version 2, the requirement that a Delay_t have a "math" subelement was relaxed, making it optional. In this case, the Delay_t remains undefined, and unless that information is provided in some other form (such as with an SBML Level 3 package), the Event_t behaves as if it had no Delay_t.
Public Member Functions | |
Delay_t * | Delay_clone (const Delay_t *d) |
Creates and returns a deep copy of the given Delay_t structure. More... | |
int | Delay_containsUndeclaredUnits (Delay_t *d) |
Predicate returning 1 (true) or 0 (false) depending on whether the math expression of this Delay_t contains parameters/numbers with undeclared units. More... | |
Delay_t * | Delay_create (unsigned int level, unsigned int version) |
Creates a new Delay_t structure using the given SBML level and version values. More... | |
Delay_t * | Delay_createWithNS (SBMLNamespaces_t *sbmlns) |
Creates a new Delay_t structure using the given SBMLNamespaces_t structure. More... | |
void | Delay_free (Delay_t *d) |
Frees the given Delay_t structure. More... | |
UnitDefinition_t * | Delay_getDerivedUnitDefinition (Delay_t *d) |
Calculates and returns a UnitDefinition_t that expresses the units returned by the math expression of this Delay_t. More... | |
const ASTNode_t * | Delay_getMath (const Delay_t *d) |
Get the mathematical formula for a Delay_t structure and return it as as an ASTNode_t structure. More... | |
const XMLNamespaces_t * | Delay_getNamespaces (Delay_t *d) |
Returns a list of XMLNamespaces_t associated with this Delay_t structure. More... | |
int | Delay_isSetMath (const Delay_t *d) |
Predicate to test whether the formula for the given Delay_t structure is set. More... | |
int | Delay_setMath (Delay_t *d, const ASTNode_t *math) |
Sets the delay expression of the given Delay_t instance to a copy of the given ASTNode_t structure. More... | |
int Delay_containsUndeclaredUnits | ( | Delay_t * | d | ) |
Predicate returning 1
(true) or 0
(false) depending on whether the math expression of this Delay_t contains parameters/numbers with undeclared units.
1
(true) if the math expression of this Delay_t includes parameters/numbers with undeclared units, 0
(false) otherwise.1
(true) indicates that the UnitDefinition_t returned by the getDerivedUnitDefinition function may not accurately represent the units of the expression.Delay_t * Delay_create | ( | unsigned int | level, |
unsigned int | version | ||
) |
Creates a new Delay_t structure using the given SBML level
and version
values.
level | an unsigned int, the SBML Level to assign to this Delay_t. |
version | an unsigned int, the SBML Version to assign to this Delay_t. |
Delay_t * Delay_createWithNS | ( | SBMLNamespaces_t * | sbmlns | ) |
Creates a new Delay_t structure using the given SBMLNamespaces_t structure.
sbmlns | SBMLNamespaces_t, a pointer to an SBMLNamespaces_t structure to assign to this Delay_t. |
void Delay_free | ( | Delay_t * | d | ) |
UnitDefinition_t * Delay_getDerivedUnitDefinition | ( | Delay_t * | d | ) |
Calculates and returns a UnitDefinition_t that expresses the units returned by the math expression of this Delay_t.
Note that the functionality that facilitates unit analysis depends on the model as a whole. Thus, in cases where the structure has not been added to a model or the model itself is incomplete, unit analysis is not possible and this method will return NULL
.
Get the mathematical formula for a Delay_t structure and return it as as an ASTNode_t structure.
d | the Delay_t structure to query. |
const XMLNamespaces_t * Delay_getNamespaces | ( | Delay_t * | d | ) |
Returns a list of XMLNamespaces_t associated with this Delay_t structure.
d | the Delay_t structure. |
int Delay_isSetMath | ( | const Delay_t * | d | ) |
Sets the delay expression of the given Delay_t instance to a copy of the given ASTNode_t structure.