tellurium.sedml package¶
Subpackages¶
Submodules¶
tellurium.sedml.mathml module¶
Helper functions for evaluation of mathml expressions. In this namespace all the possible names occuring in formula strings have to be defined.
- In build in python are
- *, /, +, - and, or, not
-
tellurium.sedml.mathml.
evaluableMathML
(astnode, variables={}, array=False)[source]¶ Create evaluable python string.
-
tellurium.sedml.mathml.
evaluateMathML
(astnode, variables={}, array=False)[source]¶ Evaluate MathML string with given set of variable and parameter values.
Parameters: - astnode (libsbml.ASTNode) – astnode of MathML string
- variables (dict) – dictionary of var : value
- parameters (dict) – dictionary of par : value
Returns: value of evaluated MathML
Return type: float
tellurium.sedml.tephrasedml module¶
tellurium.sedml.tesedml module¶
Tellurium SED-ML support.
This module implements SED-ML support for tellurium.
Overview SED-ML¶
- SED-ML is build of main classes
- the Model Class, the Simulation Class, the Task Class, the DataGenerator Class, and the Output Class.
- The Model Class
- The Model class is used to reference the models used in the simulation experiment. SED-ML itself is independent of the model encoding underlying the models. The only requirement is that the model needs to be referenced by using an unambiguous identifier which allows for finding it, for example using a MIRIAM URI. To specify the language in which the model is encoded, a set of predefined language URNs is provided. The SED-ML Change class allows the application of changes to the referenced models, including changes on the XML attributes, e.g. changing the value of an observable, computing the change of a value using mathematics, or general changes on any XML element of the model representation that is addressable by XPath expressions, e.g. substituting a piece of XML by an updated one.
TODO: DATA CLASS
- The Simulation Class
- The Simulation class defines the simulation settings and the steps taken during simulation. These include the particular type of simulation and the algorithm used for the execution of the simulation; preferably an unambiguous reference to such an algorithm should be given, using a controlled vocabulary, or ontologies. One example for an ontology of simulation algorithms is the Kinetic Simulation Algorithm Ontology KiSAO. Further information encodable in the Simulation class includes the step size, simulation duration, and other simulation-type dependent information.
- The Task Class
- SED-ML makes use of the notion of a Task class to combine a defined model (from the Model class) and a defined simulation setting (from the Simulation class). A task always holds one reference each. To refer to a specific model and to a specific simulation, the corresponding IDs are used.
- The DataGenerator Class
- The raw simulation result sometimes does not correspond to the desired output of the simulation, e.g. one might want to normalise a plot before output, or apply post-processing like mean-value calculation. The DataGenerator class allows for the encoding of such post-processings which need to be applied to the simulation result before output. To define data generators, any addressable variable or parameter of any defined model (from instances of the Model class) may be referenced, and new entities might be specified using MathML definitions.
- The Output Class
- The Output class defines the output of the simulation, in the sense that it specifies what shall be plotted in the output. To do so, an output type is defined, e.g. 2D-plot, 3D-plot or data table, and the according axes or columns are all assigned to one of the formerly specified instances of the DataGenerator class.
For information about SED-ML please refer to http://www.sed-ml.org/ and the SED-ML specification.
SED-ML in tellurium: Implementation¶
SED-ML support in tellurium is based on Combine Archives. The SED-ML files in the Archive can be executed and stored with results.
SED-ML in tellurium: Supported Features¶
Tellurium supports SED-ML L1V3 with SBML as model format.
SBML models are fully supported, whereas for CellML models only basic support is implemented (when additional support is requested it be implemented). CellML models are transformed to SBML models which results in different XPath expressions, so that targets, selections cannot be easily resolved in the CellMl-SBML.
Supported input for SED-ML are either SED-ML files (‘.sedml’ extension), SED-ML XML strings or combine archives (‘.sedx’|’.omex’ extension). Executable python code is generated from the SED-ML which allows the execution of the defined simulation experiment.
In the current implementation all SED-ML constructs with exception of XML transformation changes of the model
- Change.RemoveXML
- Change.AddXML
- Change.ChangeXML
are supported.
Notice¶
The main maintainer for SED-ML support is Matthias König. Please let changes to this file be reviewed and make sure that all SED-ML related tests are working.
-
class
tellurium.sedml.tesedml.
SEDMLCodeFactory
(inputStr, workingDir=None, createOutputs=True, saveOutputs=False, outputDir=None, plottingEngine=None)[source]¶ Bases:
object
Code Factory generating executable code.
-
TEMPLATE_DIR
= '/home/docs/checkouts/readthedocs.org/user_builds/tellurium/checkouts/param-est/tellurium/sedml/templates'¶
-
static
algorithmParameterToParameterKey
(par)[source]¶ Resolve the mapping between parameter keys and roadrunner integrator keys.
-
static
createTaskTree
(doc, rootTask)[source]¶ Creates the task tree. Required for resolution of order of all simulations.
-
dataDescriptionToPython
(dataDescription)[source]¶ Python code for DataDescription.
Parameters: dataDescription (DataDescription) – SedModel instance Returns: python str Return type: str
-
static
dataGeneratorToPython
(doc, generator)[source]¶ Create variable from the data generators and the simulation results and data sources.
The data of repeatedTasks is handled differently depending on if reset=True or reset=False. reset=True:
every repeat is a single curve, i.e. the data is a list of data- reset=False:
- all curves belong to a single simulation and are concatenated to one dataset
-
executePython
()[source]¶ Executes python code.
The python code is created during the function call. See
createpython()
Returns: returns dictionary of information with keys
-
static
getDataGeneratorsForTask
(doc, task)[source]¶ Get the DataGenerators which reference the given task.
Parameters: - doc –
- task –
Returns: Return type:
-
static
getIntegratorNameForKisaoID
(kid)[source]¶ RoadRunner integrator name for algorithm KisaoID.
Parameters: kid (str) – KisaoID Returns: RoadRunner integrator name. Return type: str
-
static
isSupportedAlgorithmForSimulationType
(kisao, simType)[source]¶ Check Algorithm Kisao Id is supported for simulation.
Returns: is supported Return type: bool
-
static
modelChangeToPython
(model, change)[source]¶ Creates the apply change python string for given model and change.
Currently only a very limited subset of model changes is supported. Namely changes of parameters and concentrations within a SedChangeAttribute.
Parameters: - model (SedModel) – given model
- change (SedChange) – model change
Returns: Return type: str
-
modelToPython
(model)[source]¶ Python code for SedModel.
Parameters: model (SedModel) – SedModel instance Returns: python str Return type: str
-
outputPlot2DToPython
(doc, output)[source]¶ OutputReport
If workingDir is provided the plot is saved in the workingDir. :param doc: :type doc: SedDocument :param output: :type output: SedOutputReport :return: list of python lines :rtype: list(str)
-
outputPlot3DToPython
(doc, output)[source]¶ OutputPlot3D
Parameters: - doc (SedDocument) –
- output (SedOutputPlot3D) –
Returns: list of python lines
Return type: list(str)
-
outputReportToPython
(doc, output)[source]¶ OutputReport
Parameters: - doc (SedDocument) –
- output (SedOutputReport) –
Returns: list of python lines
Return type: list(str)
-
static
repeatedTaskToPython
(doc, node)[source]¶ Create python for RepeatedTask.
Must create - the ranges (Ranges) - apply all changes (SetValues)
-
sedmlString
()[source]¶ Get the SEDML XML string of the current document.
Returns: SED-ML XML Return type: str
-
static
selectionFromVariable
(var, modelId)[source]¶ Resolves the selection for the given variable.
First checks if the variable is a symbol and returns the symbol. If no symbol is set the xpath of the target is resolved and used in the selection
Parameters: var (SedVariable) – variable to resolve Returns: a single selection Return type: Selection (namedtuple: id type)
-
static
selectionsForTask
(doc, task)[source]¶ Populate variable lists from the data generators for the given task.
These are the timeCourseSelections and steadyStateSelections in RoadRunner.
Search all data generators for variables which have to be part of the simulation.
-
static
simpleTaskToPython
(doc, node)[source]¶ Creates the simulation python code for a given taskNode.
The taskNodes are required to handle the relationships between RepeatedTasks, SubTasks and SimpleTasks (Task).
Parameters: - doc (SEDDocument) – sedml document
- node (TaskNode) – taskNode of the current task
Returns: Return type:
-
static
targetToPython
(xpath, value, modelId)[source]¶ Creates python line for given xpath target and value. :param xpath: :type xpath: :param value: :type value: :return: :rtype:
-
static
taskToPython
(doc, task)[source]¶ Create python for arbitrary task (repeated or simple).
Parameters: - doc –
- task –
Returns: Return type:
-
toPython
(python_template='tesedml_template.template')[source]¶ Create python code by rendering the python template. Uses the information in the SED-ML document to create python code
Renders the respective template.
Returns: returns the rendered template Return type: str
-
-
class
tellurium.sedml.tesedml.
SEDMLTools
[source]¶ Bases:
object
Helper functions to work with sedml.
-
INPUT_TYPE_FILE_COMBINE
= 'COMBINE_FILE'¶
-
INPUT_TYPE_FILE_SEDML
= 'SEDML_FILE'¶
-
INPUT_TYPE_STR
= 'SEDML_STRING'¶
-
classmethod
checkSEDMLDocument
(doc)[source]¶ Checks the SedDocument for errors. Raises IOError if error exists. :param doc: :type doc:
-
classmethod
readSEDMLDocument
(inputStr, workingDir)[source]¶ Parses SedMLDocument from given input.
Returns: dictionary of SedDocument, inputType and working directory. Return type: {doc, inputType, workingDir}
-
static
resolveModelChanges
(doc)[source]¶ Resolves the original source model and full change lists for models.
Going through the tree of model upwards until root is reached and collecting changes on the way (example models m* and changes c*) m1 (source) -> m2 (c1, c2) -> m3 (c3, c4) resolves to m1 (source) [] m2 (source) [c1,c2] m3 (source) [c1,c2,c3,c4] The order of changes is important (at least between nodes on different levels of hierarchies), because later changes of derived models could reverse earlier changes.
Uses recursive search strategy, which should be okay as long as the model tree hierarchy is not getting to big.
-
-
tellurium.sedml.tesedml.
combineArchiveToPython
(omexPath)[source]¶ All python code generated from given combine archive.
Parameters: omexPath – Returns: dictionary of { sedml_location: pycode }
-
tellurium.sedml.tesedml.
executeCombineArchive
(omexPath, workingDir=None, printPython=False, createOutputs=True, saveOutputs=False, outputDir=None, plottingEngine=None)[source]¶ Run all SED-ML simulations in given COMBINE archive.
If no workingDir is provided execution is performed in temporary directory which is cleaned afterwards. The executed code can be printed via the ‘printPython’ flag.
Parameters: - omexPath – OMEX Combine archive
- workingDir – directory to extract archive to
- printPython – boolean switch to print executed python code
- createOutputs – boolean flag if outputs should be created, i.e. reports and plots
- saveOutputs – flag if the outputs should be saved to file
- outputDir – directory where the outputs should be written
- plottingEngin – string of which plotting engine to use; uses set plotting engine otherwise
:return dictionary of sedmlFile:data generators