sbmlsim.combine.sedml.tesedml
¶
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.
Module Contents¶
Classes¶
Code Factory generating executable code. |
|
Helper functions to work with sedml. |
Functions¶
|
Convert sedml file to python code. |
|
Run a SED-ML file or combine archive with results. |
|
All python code generated from given combine archive. |
|
Run all SED-ML simulations in given COMBINE archive. |
|
If each entry in the task consists of a single point |
|
If each entry in the task consists of a single point |
|
Adds endpoint markers wherever there is a discontinuity in the data. |
|
Test function run on inputStr. |
Attributes¶
- sbmlsim.combine.sedml.tesedml.KISAOS_CVODE = ['KISAO:0000019', 'KISAO:0000433', 'KISAO:0000407', 'KISAO:0000099', 'KISAO:0000035',...[source]¶
- sbmlsim.combine.sedml.tesedml.KISAOS_GILLESPIE = ['KISAO:0000241', 'KISAO:0000029', 'KISAO:0000319', 'KISAO:0000274', 'KISAO:0000333',...[source]¶
- sbmlsim.combine.sedml.tesedml.KISAOS_NLEQ = ['KISAO:0000099', 'KISAO:0000274', 'KISAO:0000282', 'KISAO:0000283', 'KISAO:0000355',...[source]¶
- sbmlsim.combine.sedml.tesedml.sedmlToPython(inputStr, workingDir=None)[source]¶
Convert sedml file to python code.
- Parameters
inputStr (path) – full path name to SedML model or SED-ML string
- Returns
generated python code
- sbmlsim.combine.sedml.tesedml.executeSEDML(inputStr, workingDir=None)[source]¶
Run a SED-ML file or combine archive with results.
If a workingDir is provided the files and results are written in the workingDir.
- Parameters
inputStr –
- Returns
- Return type
- sbmlsim.combine.sedml.tesedml.combineArchiveToPython(omexPath)[source]¶
All python code generated from given combine archive.
- Parameters
omexPath –
- Returns
dictionary of { sedml_location: pycode }
- sbmlsim.combine.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. report 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
- class sbmlsim.combine.sedml.tesedml.SEDMLCodeFactory(inputStr, workingDir=None, createOutputs=True, saveOutputs=False, outputDir=None, plottingEngine=None)[source]¶
Bases:
object
Code Factory generating executable code.
- sedmlString(self)[source]¶
Get the SEDML XML string of the current document.
- Returns
SED-ML XML
- Return type
str
- toPython(self, 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
- executePython(self)[source]¶
Executes python code.
The python code is created during the function call. See
createpython()
- Returns
returns dictionary of information with keys
- modelToPython(self, model)[source]¶
Python code for SedModel.
- Parameters
model (SedModel) – SedModel instance
- Returns
python str
- Return type
str
- 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
- dataDescriptionToPython(self, dataDescription)[source]¶
Python code for DataDescription.
- Parameters
dataDescription (DataDescription) – SedModel instance
- Returns
python str
- Return type
str
- static taskToPython(doc, task)[source]¶
Create python for arbitrary task (repeated or simple).
- Parameters
doc –
task –
- Returns
- Return type
- static createTaskTree(doc, rootTask)[source]¶
Creates the task tree. Required for resolution of order of all simulations.
- 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 repeatedTaskToPython(doc, node)[source]¶
Create python for RepeatedTask.
Must create - the ranges (Ranges) - apply all changes (SetValues)
- static getDataGeneratorsForTask(doc, task)[source]¶
Get the DataGenerators which reference the given task.
- Parameters
doc –
task –
- Returns
- Return 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 uniformRangeToPython(r)[source]¶
Create python lines for uniform range. :param r: :type r: :return: :rtype:
- static isSupportedAlgorithmForSimulationType(kisao, simType)[source]¶
Check Algorithm Kisao Id is supported for simulation.
- Returns
is supported
- Return type
bool
- static getIntegratorNameForKisaoID(kid)[source]¶
RoadRunner integrator name for algorithm KisaoID.
- Parameters
kid (str) – KisaoID
- Returns
RoadRunner integrator name.
- Return type
str
- static algorithmParameterToParameterKey(par)[source]¶
Resolve the mapping between parameter keys and roadrunner integrator keys.
- 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 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 _resolveXPath(xpath, modelId)[source]¶
Resolve the target from the xpath expression.
A single target in the model corresponding to the modelId is resolved. Currently, the model is not used for xpath resolution.
- Parameters
xpath (str) – xpath expression.
modelId (str) – id of model in which xpath should be resolved
- Returns
single target of xpath expression
- Return type
Target (namedtuple: id type)
- 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
- outputReportToPython(self, doc, output)[source]¶
OutputReport
- Parameters
doc (SedDocument) –
output (SedOutputReport) –
- Returns
list of python lines
- Return type
list(str)
- class sbmlsim.combine.sedml.tesedml.SEDMLTools[source]¶
Bases:
object
Helper functions to work with sedml.
- classmethod checkSEDMLDocument(cls, doc)[source]¶
Checks the SedDocument for errors. Raises IOError if error exists. :param doc: :type doc:
- classmethod readSEDMLDocument(cls, 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.
- sbmlsim.combine.sedml.tesedml.process_trace(trace)[source]¶
If each entry in the task consists of a single point (e.g. steady state scan), concatenate the points. Otherwise, plot as separate curves.
- sbmlsim.combine.sedml.tesedml.terminate_trace(trace)[source]¶
If each entry in the task consists of a single point (e.g. steady state scan), concatenate the points. Otherwise, plot as separate curves.