sbmlsim.combine.sedml.parser

SED-ML support for sbmlsim.

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.

Module Contents

Classes

SBMLModelTargetType

Supported target types in SBML models.

SBMLModelTarget

Target in an SBML model.

SEDMLSerializer

Serialize SimulationExperiment to SED-ML.

SEDMLParser

Parse SED-ML to sbmlsim.SimulationExperiment.

Attributes

logger

sbmlsim.combine.sedml.parser.logger[source]
class sbmlsim.combine.sedml.parser.SBMLModelTargetType[source]

Bases: enum.Enum

Supported target types in SBML models.

PARAMETER = 0[source]
COMPARTMENT = 1[source]
SPECIES = 2[source]
SPECIES_AMOUNT = 3[source]
SPECIES_CONCENTRATION = 4[source]
TIME = 5[source]
class sbmlsim.combine.sedml.parser.SBMLModelTarget(selection, target_type)[source]

Target in an SBML model.

Parameters:
property sedml_symbol: str | None[source]

Get symbol for model target.

Return type:

Optional[str]

property sedml_target: str | None[source]

Get xpath target.

Return type:

Optional[str]

static sbmlsim_model_targets(r)[source]

Model targets which are supported by sbmlsim.

Parameters:

r (sbmlsim.model.rr_model.roadrunner.ExecutableModel) –

Return type:

Dict[str, SBMLModelTarget]

class sbmlsim.combine.sedml.parser.SEDMLSerializer(exp_class, working_dir, sedml_filename, omex_path=None, data_path=None)[source]

Serialize SimulationExperiment to SED-ML.

Creates the SED-ML and the COMBINE archive containing all models and data for the simulation experiment.

Parameters:
_selection_lookup_table()[source]

Lookup table for sbmlsim model selections.

Return type:

Dict[str, Dict[str, SBMLModelTarget]]

datagenerator_id_from_data(data)[source]

Get the data generator id from data.

Parameters:

data (sbmlsim.data.Data) –

Return type:

str

serialize_datasets()[source]

Serialize sbmlsim.DataSets to libsedml.DataDescription.

Write experiment datasets in SedDocument.

serialize_models()[source]

Serialize models.

Write experiment models in SedDocument.

serialize_simulations()[source]

Serialize simulations.

Write experiment simulations in SedDocument.

serialize_tasks()[source]

Serialize tasks.

Write experiment tasks in SedDocument.

serialize_data()[source]

Serialize data generators.

Write experiment data in SedDocument.

serialize_figures()[source]

Serialize sbmlsim.Figures to libsedml.SedFigures.

Write experiment figures in SedDocument.

serialize_axis(axis, sed_axis)[source]

Serialize sbmlsim.Axis to libsedml.SEDAxis.

Parameters:
Return type:

None

serialize_style(style, sed_style)[source]

Serialize sbmlsim.Style to libsedml.Style.

Parameters:
Return type:

None

class sbmlsim.combine.sedml.parser.SEDMLParser(sed_doc, exec_dir, working_dir, name=None)[source]

Parse SED-ML to sbmlsim.SimulationExperiment.

Parameters:
  • sed_doc (libsedml.SedDocument) –

  • exec_dir (pathlib.Path) –

  • working_dir (pathlib.Path) –

  • name (Optional[str]) –

_wrap_plot_in_figure(sed_plot)[source]

Create sbmlsim.Plot from libsedml.Plot and wraps in sbmlsim.Figure.

Parameters:

sed_plot (Union[libsedml.SedPlot2D, libsedml.SedPlot3D]) –

Return type:

sbmlsim.plot.Figure

_create_experiment_class()[source]

Create SimulationExperiment class from information.

See sbmlsim.experiment.Experiment for the expected functions.

Return type:

Type[sbmlsim.experiment.SimulationExperiment]

print_info()[source]

Print information.

Return type:

None

static parse_xpath_target(xpath)[source]

Resolve targets in xpath expression.

Uses a heuristics to figure out the targets.

Parameters:

xpath (str) –

Return type:

str

parse_model(sed_model, source, sed_changes)[source]

Convert SedModel to AbstractModel.

Parameters:
  • sed_changes (List[libsedml.SedChange]) –

  • sed_model (libsedml.SedModel) –

  • source (str) –

Return type:

sbmlsim.model.model.AbstractModel

:param source:s :param sed_model: :return:

resolve_model_changes()[source]

Resolve 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(sed_change)[source]

Parse the libsedml.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_algorithm_parameter(sed_alg_par)[source]

Parse algorithm parameter information.

Parameters:

sed_alg_par (libsedml.SedAlgorithmParameter) –

Return type:

sbmlsim.simulation.algorithm.AlgorithmParameter

parse_simulation(sed_sim)[source]

Parse simulation information.

Parameters:

sed_sim (libsedml.SedSimulation) –

Return type:

sbmlsim.simulation.TimecourseSim

parse_task(sed_task)[source]

Parse arbitrary task (repeated or simple, or simple repeated).

Parameters:

sed_task (libsedml.SedAbstractTask) –

Return type:

sbmlsim.task.Task

_parse_simple_task(task_node)[source]

Parse simple task.

Parameters:

task_node (sbmlsim.combine.sedml.task.TaskNode) –

Return type:

sbmlsim.task.Task

abstract _parse_repeated_task(node)[source]

Parse repeated task.

Will be translated into a multi-dimensional scan.

Parameters:

node (sbmlsim.combine.sedml.task.TaskNode) –

parse_figure(sed_figure)[source]

Parse figure information.

Parameters:

sed_figure (libsedml.SedFigure) –

Return type:

sbmlsim.plot.Figure

parse_plot2d(sed_plot2d)[source]

Parse the libsedml.Plot2D into a sbmlsim.Plot.

Parameters:

sed_plot2d (libsedml.SedPlot2D) –

Return type:

sbmlsim.plot.Plot

abstract parse_plot3d(sed_plot3d)[source]

Parse Plot3D.

Parameters:

sed_plot3d (libsedml.SedPlot3D) –

Return type:

sbmlsim.plot.Plot

parse_report(sed_report)[source]

Parse Report.

Return dictionary of label:

dataGenerator.id mapping.

Parameters:

sed_report (libsedml.SedReport) –

Return type:

Dict[str, str]

parse_axis(sed_axis)[source]

Parse axes information.

Parameters:

sed_axis (libsedml.SedAxis) –

Return type:

Optional[sbmlsim.plot.Axis]

parse_abstract_curve(sed_acurve)[source]

Parse abstract curve.

Parameters:

sed_acurve (libsedml.SedAbstractCurve) –

Return type:

Union[sbmlsim.plot.plotting.ShadedArea, sbmlsim.plot.Curve]

parse_style(sed_style)[source]

Parse SED-ML style.

Parameters:

sed_style (Union[str, libsedml.SedStyle]) –

Return type:

Optional[sbmlsim.plot.plotting.Style]

parse_line(sed_line)[source]

Parse line information.

Parameters:

sed_line (libsedml.SedLine) –

Return type:

Optional[sbmlsim.plot.plotting.Line]

parse_marker(sed_marker)[source]

Parse the line information.

Parameters:

sed_marker (libsedml.SedMarker) –

Return type:

Optional[sbmlsim.plot.plotting.Marker]

parse_fill(sed_fill)[source]

Parse fill information.

Parameters:

sed_fill (libsedml.SedFill) –

Return type:

Optional[sbmlsim.plot.plotting.Fill]

data_from_datagenerator(sed_dg_ref)[source]

Evaluate DataGenerator with actual data.

Uses results of SimulationExperiment for evaluation.

Parameters:

sed_dg_ref (Optional[str]) –

Return type:

Optional[sbmlsim.data.Data]

data_generators_for_task(sed_task)[source]

Get DataGenerators which reference the given task.

Parameters:

sed_task (libsedml.SedTask) –

Return type:

List[libsedml.SedDataGenerator]

static get_ordered_subtasks(sed_task)[source]

Ordered list of subtasks for task.

Parameters:

sed_task (libsedml.SedTask) –

Return type:

List[libsedml.SedTask]