sbmlsim.combine.sedml.parser
¶
This modules parses SED-ML based simulation experiments in the sbmlsim SimulationExperiment format and executes them.
Overview SED-ML¶
SED-ML is build of the main classes - DataDescription - Model - Simulation - Task - DataGenerator - Output
DataDescription¶
The DataDescription allows to reference external data, and contains a description on how to access the data, in what format it is, and what subset of data to extract.
Model¶
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.
Simulation¶
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.
Task¶
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.
DataGenerator¶
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.
Output¶
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 sbmlsim: Supported Features¶
sbmlsim supports SED-ML L1V4 with SBML as model format. SBML models are fully supported
Supported input for SED-ML are either SED-ML files (‘.sedml’ extension), SED-ML XML strings or combine archives (‘.sedx’|’.omex’ extension).
In the current implementation all SED-ML constructs with exception of XML transformation changes of the model, i.e., - Change.RemoveXML - Change.AddXML - Change.ChangeXML are supported.
Module Contents¶
Classes¶
Parsing SED-ML in internal format. |
Attributes¶
def experiment_from_omex(omex_path: Path): |
- sbmlsim.combine.sedml.parser.logger[source]¶
- def experiment_from_omex(omex_path: Path):
“””Create SimulationExperiments from all SED-ML files.””” tmp_dir = tempfile.mkdtemp() try:
omex.extractCombineArchive(omex_path, directory=tmp_dir, method=”zip”) locations = omex.getLocationsByFormat(omex_path, “sed-ml”) sedml_files = [os.path.join(tmp_dir, loc) for loc in locations]
- for k, sedml_file in enumerate(sedml_files):
pystr = sedmlToPython(sedml_file) factory = SEDMLCodeFactory(inputStr, workingDir=workingDir) factory.to pycode[locations[k]] = pystr
- finally:
shutil.rmtree(tmp_dir)
return pycode
- class sbmlsim.combine.sedml.parser.SEDMLParser(sed_doc, working_dir)[source]¶
Bases:
object
Parsing SED-ML in internal format.
- Parameters
sed_doc (libsedml.SedDocument) –
working_dir (pathlib.Path) –
- static parse_xpath_target(xpath)[source]¶
Resolve targets in xpath expression.
Uses a heuristics to figure out the targets. # FIXME: SED-ML amount/species targets
- Parameters
xpath (str) –
- Return type
str
- parse_model(self, sed_model, source, sed_changes)[source]¶
Convert SedModel to AbstractModel.
- Parameters
sed_changes (List[libsedml.SedChange]) –
source (str) –
sed_model (libsedml.SedModel) –
- Returns
- Return type
- resolve_model_changes(self)[source]¶
Resolves the original model sources and full change lists.
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 deep.
- parse_change(self, sed_change)[source]¶
Parses the change.
Currently only a limited subset of model changes is supported. Namely changes of parameters and concentrations within a SedChangeAttribute.
- Parameters
sed_change (libsedml.SedChange) –
- Return type
Dict
- parse_simulation(self, sed_sim)[source]¶
Parse simulation information.
- Parameters
sed_sim (libsedml.SedSimulation) –
- Return type
- parse_task(self, sed_task)[source]¶
Parse arbitrary task (repeated or simple, or simple repeated).
- Parameters
sed_task (libsedml.SedAbstractTask) –
- Return type
- _parse_simple_task(self, task_node)[source]¶
Parse simple task
- Parameters
task_node (sbmlsim.combine.sedml.task.TaskNode) –
- Return type
- _parse_simple_repeated_task(self, node)[source]¶
- Parameters
node (sbmlsim.combine.sedml.task.TaskNode) –
- parse_figure(self, sed_output)[source]¶
Parse simulation information.
- Parameters
sed_output (libsedml.SedOutput) –
- Return type
- data_from_datagenerator(self, sed_dg_ref)[source]¶
This must all be evaluated with actual data
- Parameters
sed_dg_ref (Optional[str]) –
- Return type
Optional[sbmlsim.data.Data]
- _parse_repeated_task(self, node)[source]¶
- Parameters
node (sbmlsim.combine.sedml.task.TaskNode) –
- data_generators_for_task(self, sed_task)[source]¶
Get the DataGenerators which reference the given task.
- Parameters
sed_task (libsedml.SedTask) –
- Return type
List[libsedml.SedDataGenerator]
- selections_for_task(self, sed_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.
- Parameters
sed_task (libsedml.SedTask) –