biosimulators_utils.sedml package#

Submodules#

biosimulators_utils.sedml.data_model module#

Data model for SED

Author:

Jonathan Karr <karr@mssm.edu>

Date:

2020-12-06

Copyright:

2020, Center for Reproducible Biomedical Modeling

License:

MIT

class biosimulators_utils.sedml.data_model.AbstractTask(id=None, name=None)[source]#

Bases: SedBase, SedIdGroupMixin

Base class for tasks

id[source]#

id

Type:

str

name[source]#

name

Type:

str

is_equal(other)[source]#

Determine if tasks are equal

Parameters:

other (AbstractTask) – another content item

Returns:

True, if two tasks are equal

Return type:

bool

class biosimulators_utils.sedml.data_model.AddElementModelChange(id=None, name=None, target=None, target_namespaces=None, new_elements=None)[source]#

Bases: ModelChange

An addition of an element to a model

id[source]#

id

Type:

str

name[source]#

name

Type:

str

target[source]#

path to the parent of the new element(s)

Type:

str

target_namespaces[source]#

map of prefixes of namespaces for the target to their URIs

Type:

dict

new_elements[source]#

new element(s)

Type:

str

is_equal(other)[source]#

Determine if model changes are equal

Parameters:

other (AddElementModelChange) – another content item

Returns:

True, if two model changes are equal

Return type:

bool

to_tuple()[source]#

Get a tuple representation

Returns:

tuple representation

Return type:

tuple of str

class biosimulators_utils.sedml.data_model.Algorithm(kisao_id=None, changes=None)[source]#

Bases: SedBase

A simulation algorithm

kisao_id[source]#

KiSAO id (e.g., KISAO_0000029)

Type:

str

changes[source]#

parameter changes

Type:

list of AlgorithmParameterChange

is_equal(other)[source]#

Determine if algorithms are equal

Parameters:

other (Algorithm) – another algorithm

Returns:

True, if two algorithms are equal

Return type:

bool

to_tuple()[source]#

Get a tuple representation

Returns:

tuple representation

Return type:

tuple of str

class biosimulators_utils.sedml.data_model.AlgorithmParameterChange(kisao_id=None, new_value=None)[source]#

Bases: SedBase

A changed parameter of an algorithm

kisao_id[source]#

KiSAO id (e.g., KISAO_0000029)

Type:

str

new_value[source]#

new value

Type:

str

is_equal(other)[source]#

Determine if parameter changes are equal

Parameters:

other (AlgorithmParameterChange) – another parameter change

Returns:

True, if two parameter changes are equal

Return type:

bool

to_tuple()[source]#

Get a tuple representation

Returns:

tuple representation

Return type:

tuple of str

class biosimulators_utils.sedml.data_model.AxisScale(value)[source]#

Bases: str, Enum

Scale of an axis

linear = 'linear'[source]#
log = 'log'[source]#
class biosimulators_utils.sedml.data_model.Color[source]#

Bases: str

6-character hexidecimal RGB color or 8-character hexidecimal RGBA color

class biosimulators_utils.sedml.data_model.ComputeModelChange(id=None, name=None, target=None, target_namespaces=None, variables=None, parameters=None, math=None)[source]#

Bases: ModelChange, Calculation

A replacement of an element of a model

id[source]#

id

Type:

str

name[source]#

name

Type:

str

target[source]#

path to the element to replace

Type:

str

target_namespaces[source]#

map of prefixes of namespaces for the target to their URIs

Type:

dict

variables[source]#

variables

Type:

list of Variable

parameters[source]#

parameters

Type:

list of Parameter

math[source]#

mathematical expression

Type:

str

is_equal(other)[source]#

Determine if model changes are equal

Parameters:

other (ComputeModelChange) – another content item

Returns:

True, if two model changes are equal

Return type:

bool

to_tuple()[source]#

Get a tuple representation

Returns:

tuple representation

Return type:

tuple of str

class biosimulators_utils.sedml.data_model.Curve(id=None, name=None, x_scale=None, y_scale=None, x_data_generator=None, y_data_generator=None, style: Style | None = None)[source]#

Bases: SedBase, SedIdGroupMixin

A curve in a 2D plot

id[source]#

id

Type:

str

name[source]#

name

Type:

str

x_scale[source]#

x axis scale

Type:

AxisScale

y_scale[source]#

y axis scale

Type:

AxisScale

x_data_generator[source]#

x data generator

Type:

DataGenerator

y_data_generator[source]#

y data generator

Type:

DataGenerator

style[source]#

graphical style

Type:

Style

is_equal(other)[source]#

Determine if curves are equal

Parameters:

other (Curve) – another curve

Returns:

True, if two curves are equal

Return type:

bool

to_tuple()[source]#

Get a tuple representation

Returns:

tuple representation

Return type:

tuple of str

class biosimulators_utils.sedml.data_model.DataGenerator(id=None, name=None, variables=None, parameters=None, math=None)[source]#

Bases: Calculation, SedIdGroupMixin

A data generator

id[source]#

id

Type:

str

name[source]#

name

Type:

str

variables[source]#

variables

Type:

list of Variable

parameters[source]#

parameters

Type:

list of Parameter

math[source]#

mathematical expression

Type:

str

is_equal(other)[source]#
Determine if data generators

are equal

Parameters:

other (DataGenerator) – another content item

Returns:

True, if two data generators are equal

Return type:

bool

to_tuple()[source]#

Get a tuple representation

Returns:

tuple representation

Return type:

tuple of str

class biosimulators_utils.sedml.data_model.DataSet(id=None, name=None, label=None, data_generator=None)[source]#

Bases: SedBase, SedIdGroupMixin

A data set in a report

id[source]#

id

Type:

str

name[source]#

name

Type:

str

label[source]#

label

Type:

str

data_generator[source]#

data generator

Type:

DataGenerator

is_equal(other)[source]#

Determine if data sets are equal

Parameters:

other (DataSet) – another content item

Returns:

True, if two data sets are equal

Return type:

bool

to_tuple()[source]#

Get a tuple representation

Returns:

tuple representation

Return type:

tuple of str

class biosimulators_utils.sedml.data_model.FillStyle(color: Color | None = None)[source]#

Bases: SedBase

Style of a marker

color[source]#

color

Type:

Color

is_equal(other)[source]#

Determine if fill styles are equal

Parameters:

other (FillStyle) – another fill style

Returns:

True, if two fill styles are equal

Return type:

bool

to_tuple()[source]#

Get a tuple representation

Returns:

tuple representation

Return type:

tuple of str

class biosimulators_utils.sedml.data_model.FunctionalRange(id=None, name=None, range=None, variables=None, parameters=None, math=None)[source]#

Bases: Range, Calculation

A functional range

id[source]#

id

Type:

str

name[source]#

name

Type:

str

range[source]#

range

Type:

Range

variables[source]#

variables

Type:

list of Variable

parameters[source]#

parameters

Type:

list of Parameter

math[source]#

mathematical expression

Type:

str

is_equal(other)[source]#

Determine if ranges are equal

Parameters:

other (FunctionalRange) – another content item

Returns:

True, if two ranges are equal

Return type:

bool

to_tuple()[source]#

Get a tuple representation

Returns:

tuple representation

Return type:

tuple of str

class biosimulators_utils.sedml.data_model.LineStyle(type: LineStyleType | None = None, color: Color | None = None, thickness: float | None = None)[source]#

Bases: SedBase

Style of a line

type[source]#

type

Type:

LineStyleType

color[source]#

color

Type:

Color

thickness[source]#

type

Type:

float

is_equal(other)[source]#

Determine if line styles are equal

Parameters:

other (FillStyle) – another line style

Returns:

True, if two line styles are equal

Return type:

bool

to_tuple()[source]#

Get a tuple representation

Returns:

tuple representation

Return type:

tuple of str

class biosimulators_utils.sedml.data_model.LineStyleType(value)[source]#

Bases: str, Enum

Style of a line of a curve

dash = 'dash'[source]#
dashDot = 'dashDot'[source]#
dashDotDot = 'dashDotDot'[source]#
dot = 'dot'[source]#
none = 'none'[source]#
solid = 'solid'[source]#
class biosimulators_utils.sedml.data_model.MarkerStyle(type: MarkerStyleType | None = None, size: float | None = None, fill_color: Color | None = None, line_color: Color | None = None, line_thickness: float | None = None)[source]#

Bases: SedBase

Style of a marker

type[source]#

type

Type:

MarkerStyleType

size[source]#

size

Type:

float

fill_color[source]#

fill color

Type:

Color

line_color[source]#

line color

Type:

Color

line_thickness[source]#

line thickness

Type:

float

is_equal(other)[source]#

Determine if marker styles are equal

Parameters:

other (FillStyle) – another marker style

Returns:

True, if two marker styles are equal

Return type:

bool

to_tuple()[source]#

Get a tuple representation

Returns:

tuple representation

Return type:

tuple of str

class biosimulators_utils.sedml.data_model.MarkerStyleType(value)[source]#

Bases: str, Enum

Style of a marker of a curve

circle = 'circle'[source]#
diamond = 'diamond'[source]#
hDash = 'hDash'[source]#
none = 'none'[source]#
plus = 'plus'[source]#
square = 'square'[source]#
star = 'star'[source]#
triangleDown = 'triangleDown'[source]#
triangleLeft = 'triangleLeft'[source]#
triangleRight = 'triangleRight'[source]#
triangleUp = 'triangleUp'[source]#
vDash = 'vDash'[source]#
xCross = 'xCross'[source]#
class biosimulators_utils.sedml.data_model.Model(id=None, name=None, source=None, language=None, changes=None)[source]#

Bases: SedBase, SedIdGroupMixin

A model

id[source]#

id

Type:

str

name[source]#

name

Type:

str

source[source]#

path to the model file

Type:

str

language[source]#

URN of the format of the model

Type:

str

changes[source]#

model changes

Type:

list of ModelChange

has_structural_changes()[source]#

Check if there are structural model changes present.

  • Add element

  • Replace element

  • Remove element

Returns:

True, if structural model changes are present

Return type:

bool

is_equal(other)[source]#

Determine if models are equal

Parameters:

other (Model) – another content item

Returns:

True, if two models are equal

Return type:

bool

to_tuple()[source]#

Get a tuple representation

Returns:

tuple representation

Return type:

tuple of str

class biosimulators_utils.sedml.data_model.ModelAttributeChange(id=None, name=None, target=None, target_namespaces=None, new_value=None)[source]#

Bases: ModelChange

A change of an attribute of a model

id[source]#

id

Type:

str

name[source]#

name

Type:

str

target[source]#

path to the model element that should be changed

Type:

str

target_namespaces[source]#

map of prefixes of namespaces for the target to their URIs

Type:

dict

new_value[source]#

new value

Type:

str

is_equal(other)[source]#

Determine if model attribute changes are equal

Parameters:

other (ModelAttributeChange) – another content item

Returns:

True, if two model attribute changes are equal

Return type:

bool

to_tuple()[source]#

Get a tuple representation

Returns:

tuple representation

Return type:

tuple of str

class biosimulators_utils.sedml.data_model.ModelChange(id=None, name=None, target=None, target_namespaces=None)[source]#

Bases: SedBase, SedIdGroupMixin, TargetGroupMixin

A change to a model

id[source]#

id

Type:

str

name[source]#

name

Type:

str

target[source]#

path to the model element that should be changed

Type:

str

target_namespaces[source]#

map of prefixes of namespaces for the target to their URIs

Type:

dict

is_equal(other)[source]#

Determine if model changes are equal

Parameters:

other (ModelChange) – another content item

Returns:

True, if two model changes are equal

Return type:

bool

class biosimulators_utils.sedml.data_model.ModelLanguage(value)[source]#

Bases: str, Enum

Model language

BNGL = 'urn:sedml:language:bngl'[source]#
CellML = 'urn:sedml:language:cellml'[source]#
CopasiML = 'urn:sedml:language:copasiml'[source]#
GINML = 'urn:sedml:language:ginml'[source]#
HOC = 'urn:sedml:language:hoc'[source]#
Kappa = 'urn:sedml:language:kappa'[source]#
LEMS = 'urn:sedml:language:lems'[source]#
MASS = 'urn:sedml:language:mass'[source]#
MorpheusML = 'urn:sedml:language:morpheusml'[source]#
NMODL = 'urn:sedml:language:nmodl'[source]#
NeuroML = 'urn:sedml:language:neuroml'[source]#
RBA = 'urn:sedml:language:rba'[source]#
SBML = 'urn:sedml:language:sbml'[source]#
SLI = 'urn:sedml:language:sli'[source]#
Smoldyn = 'urn:sedml:language:smoldyn'[source]#
VCML = 'urn:sedml:language:vcml'[source]#
XPP = 'urn:sedml:language:xpp'[source]#
ZGINML = 'urn:sedml:language:zginml'[source]#
pharmML = 'urn:sedml:language:pharmml'[source]#
class biosimulators_utils.sedml.data_model.ModelLanguageEdamId(value)[source]#

Bases: str, Enum

Model language EDAM id

BNGL = 'format_3972'[source]#
CellML = 'format_3240'[source]#
CopasiML = 'format_9003'[source]#
GENESIS = 'format_9056'[source]#
GINML = 'format_9009'[source]#
HOC = 'format_9005'[source]#
Kappa = 'format_9006'[source]#
LEMS = 'format_9004'[source]#
MASS = 'format_9011'[source]#
MorpheusML = 'format_9002'[source]#
NCS = 'format_9057'[source]#
NMODL = 'format_9052'[source]#
NeuroML = 'format_3971'[source]#
RBA = 'format_9012'[source]#
SBML = 'format_2585'[source]#
SLI = 'format_9054'[source]#
Smoldyn = 'format_9001'[source]#
VCML = 'format_9000'[source]#
XPP = 'format_9010'[source]#
ZGINML = 'format_9008'[source]#
pharmML = 'format_9007'[source]#
class biosimulators_utils.sedml.data_model.ModelLanguagePattern(value)[source]#

Bases: str, Enum

Model language

BNGL = '^urn:sedml:language:bngl(\\.|$)'[source]#
CellML = '^urn:sedml:language:cellml(\\.\\d+_\\d+)?$'[source]#
CopasiML = '^urn:sedml:language:copasiml(\\.|$)'[source]#
GENESIS = '^urn:sedml:language:genesis(\\.|$)'[source]#
GINML = '^urn:sedml:language:ginml(\\.|$)'[source]#
HOC = '^urn:sedml:language:hoc(\\.|$)'[source]#
Kappa = '^urn:sedml:language:kappa(\\.|$)'[source]#
LEMS = '^urn:sedml:language:lems(\\.|$)'[source]#
MASS = '^urn:sedml:language:mass(\\.|$)'[source]#
MorpheusML = '^urn:sedml:language:morpheusml(\\.|$)'[source]#
NCS = '^urn:sedml:language:ncs(\\.|$)'[source]#
NMODL = '^urn:sedml:language:nmodl(\\.|$)'[source]#
NeuroML = '^urn:sedml:language:neuroml(\\.version-\\d+_\\d+_\\d+\\.level\\-\\d+)?$'[source]#
RBA = '^urn:sedml:language:rba(\\.|$)'[source]#
SBML = '^urn:sedml:language:sbml(\\.level\\-\\d+\\.version\\-\\d+)?$'[source]#
SLI = '^urn:sedml:language:sli(\\.|$)'[source]#
Smoldyn = '^urn:sedml:language:smoldyn(\\.|$)'[source]#
VCML = '^urn:sedml:language:vcml(\\.|$)'[source]#
XPP = '^urn:sedml:language:xpp(\\.|$)'[source]#
ZGINML = '^urn:sedml:language:zginml(\\.|$)'[source]#
pharmML = '^urn:sedml:language:pharmml(\\.|$)'[source]#
class biosimulators_utils.sedml.data_model.OneStepSimulation(id=None, name=None, algorithm=None, step=None)[source]#

Bases: Simulation

A single simulation step

id[source]#

id

Type:

str

name[source]#

name

Type:

str

algorithm[source]#

algorithm

Type:

Algorithm

step[source]#

step

Type:

float

is_equal(other)[source]#

Determine if simulations are equal

Parameters:

other (OneStepSimulation) – another content item

Returns:

True, if two simulations are equal

Return type:

bool

to_tuple()[source]#

Get a tuple representation

Returns:

tuple representation

Return type:

tuple of str

class biosimulators_utils.sedml.data_model.Output(id=None, name=None)[source]#

Bases: SedBase, SedIdGroupMixin

An output

id[source]#

id

Type:

str

name[source]#

name

Type:

str

is_equal(other)[source]#

Determine if outputs are equal

Parameters:

other (Output) – another content item

Returns:

True, if two outputs are equal

Return type:

bool

class biosimulators_utils.sedml.data_model.Parameter(id=None, name=None, value=None)[source]#

Bases: SedBase, SedIdGroupMixin

A parameter involved in a data generator

id[source]#

id

Type:

str

name[source]#

name

Type:

str

value[source]#

value

Type:

float

is_equal(other)[source]#

Determine if data generator parameters are equal

Parameters:

other (Parameter) – another content item

Returns:

True, if two data generator parameters are equal

Return type:

bool

to_tuple()[source]#

Get a tuple representation

Returns:

tuple representation

Return type:

tuple of str

class biosimulators_utils.sedml.data_model.Plot(id=None, name=None)[source]#

Bases: Output

A 2D plot

id[source]#

id

Type:

str

name[source]#

name

Type:

str

class biosimulators_utils.sedml.data_model.Plot2D(id=None, name=None, curves=None)[source]#

Bases: Plot

A 2D plot

id[source]#

id

Type:

str

name[source]#

name

Type:

str

curves[source]#

curves

Type:

list of Curve

is_equal(other)[source]#

Determine if plots are equal

Parameters:

other (Plot2D) – another plot

Returns:

True, if two plots are equal

Return type:

bool

to_tuple()[source]#

Get a tuple representation

Returns:

tuple representation

Return type:

tuple of str

class biosimulators_utils.sedml.data_model.Plot3D(id=None, name=None, surfaces=None)[source]#

Bases: Plot

A 3D plot

id[source]#

id

Type:

str

name[source]#

name

Type:

str

surfaces[source]#

surfaces

Type:

list of Surface

is_equal(other)[source]#

Determine if plots are equal

Parameters:

other (Plot3D) – another plot

Returns:

True, if two plots are equal

Return type:

bool

to_tuple()[source]#

Get a tuple representation

Returns:

tuple representation

Return type:

tuple of str

class biosimulators_utils.sedml.data_model.Range(id=None, name=None)[source]#

Bases: SedBase, SedIdGroupMixin

A range

id[source]#

id

Type:

str

name[source]#

name

Type:

str, optional

is_equal(other)[source]#

Determine if ranges are equal

Parameters:

other (Range) – another content item

Returns:

True, if two ranges are equal

Return type:

bool

class biosimulators_utils.sedml.data_model.RemoveElementModelChange(id=None, name=None, target=None, target_namespaces=None)[source]#

Bases: ModelChange

A removal of an element from a model

id[source]#

id

Type:

str

name[source]#

name

Type:

str

target[source]#

path to the element to remove

Type:

str

to_tuple()[source]#

Get a tuple representation

Returns:

tuple representation

Return type:

tuple of str

class biosimulators_utils.sedml.data_model.RepeatedTask(id=None, name=None, range=None, reset_model_for_each_iteration=None, changes=None, sub_tasks=None, ranges=None)[source]#

Bases: AbstractTask

A repeated task

id[source]#

id

Type:

str

name[source]#

name

Type:

str

range[source]#

range of the iterations of the repeated task

Type:

Range

reset_model_for_each_iteration[source]#

whether to reset the model for each iteration of the repeated task

Type:

bool

changes[source]#

set value model changes

Type:

list of SetValueComputeModelChange

sub_tasks[source]#

sub-tasks

Type:

list of SubTask

ranges[source]#

ranges

Type:

list of Range

is_equal(other)[source]#

Determine if repeated tasks are equal

Parameters:

other (RepeatedTask) – another content item

Returns:

True, if two repeated tasks are equal

Return type:

bool

to_tuple()[source]#

Get a tuple representation

Returns:

tuple representation

Return type:

tuple of str

class biosimulators_utils.sedml.data_model.ReplaceElementModelChange(id=None, name=None, target=None, target_namespaces=None, new_elements=None)[source]#

Bases: ModelChange

A replacement of an element of a model

id[source]#

id

Type:

str

name[source]#

name

Type:

str

target[source]#

path to the element to replace

Type:

str

target_namespaces[source]#

map of prefixes of namespaces for the target to their URIs

Type:

dict

new_elements[source]#

new element(s)

Type:

str

is_equal(other)[source]#

Determine if model changes are equal

Parameters:

other (ReplaceElementModelChange) – another content item

Returns:

True, if two model changes are equal

Return type:

bool

to_tuple()[source]#

Get a tuple representation

Returns:

tuple representation

Return type:

tuple of str

class biosimulators_utils.sedml.data_model.Report(id=None, name=None, data_sets=None)[source]#

Bases: Output

A report

id[source]#

id

Type:

str

name[source]#

name

Type:

str

data_sets[source]#

data sets

Type:

list of DataSet

is_equal(other)[source]#

Determine if reports are equal

Parameters:

other (Report) – another content item

Returns:

True, if two reports are equal

Return type:

bool

to_tuple()[source]#

Get a tuple representation

Returns:

tuple representation

Return type:

tuple of str

class biosimulators_utils.sedml.data_model.SedBase[source]#

Bases: ABC

Base class for SED classes

is_equal(other)[source]#

Determine if simulations are equal

Parameters:

other (SedBase) – another content item

Returns:

True, if two simulations are equal

Return type:

bool

abstract to_tuple()[source]#

Get a tuple representation

Returns:

tuple representation

Return type:

tuple of str

class biosimulators_utils.sedml.data_model.SedDocument(level=1, version=3, models=None, simulations=None, tasks=None, data_generators=None, outputs=None, styles=None, metadata=None)[source]#

Bases: SedBase

A SED-ML document

level[source]#

level

Type:

int

version[source]#

version

Type:

int

models[source]#

models

Type:

list of Model

simulations[source]#

simulations

Type:

list of Simulation

tasks[source]#

tasks

Type:

list of AbstractTask

data_generators[source]#

data generators

Type:

list of DataGenerator

outputs[source]#

outputs

Type:

list of Output

metadata[source]#

metadata

Type:

Metadata

is_equal(other)[source]#

Determine if SED-ML documents are equal

Parameters:

other (SedDocument) – another SED-ML document

Returns:

True, if two SED-ML documents are equal

Return type:

bool

to_tuple()[source]#

Get a tuple representation

Returns:

tuple representation

Return type:

tuple of str

class biosimulators_utils.sedml.data_model.SedIdGroupMixin(id=None, name=None)[source]#

Bases: ABC

Object with an id and optional name

id[source]#

id

Type:

str

name[source]#

name

Type:

str

is_equal(other)[source]#

Determine if simulations are equal

Parameters:

other (SedIdGroupMixin) – another content item

Returns:

True, if two simulations are equal

Return type:

bool

class biosimulators_utils.sedml.data_model.SetValueComputeModelChange(id=None, name=None, target=None, target_namespaces=None, variables=None, parameters=None, math=None, model=None, range=None, symbol=None)[source]#

Bases: ComputeModelChange, Calculation

A change that sets the value of an attribute of a model within an iteration of a repeated task

id[source]#

id

Type:

str

name[source]#

name

Type:

str

target[source]#

path to the element to replace

Type:

str

target_namespaces[source]#

map of prefixes of namespaces for the target to their URIs

Type:

dict

variables[source]#

variables

Type:

list of Variable

parameters[source]#

parameters

Type:

list of Parameter

math[source]#

mathematical expression

Type:

str

model[source]#

model

Type:

Model

range[source]#

range

Type:

Range

symbol[source]#

symbol

Type:

str

is_equal(other)[source]#

Determine if model changes are equal

Parameters:

other (SetValueComputeModelChange) – another content item

Returns:

True, if two model changes are equal

Return type:

bool

to_tuple()[source]#

Get a tuple representation

Returns:

tuple representation

Return type:

tuple of str

class biosimulators_utils.sedml.data_model.Simulation(id=None, name=None, algorithm=None)[source]#

Bases: SedBase, SedIdGroupMixin

A simulation

id[source]#

id

Type:

str

name[source]#

name

Type:

str

algorithm[source]#

algorithm

Type:

Algorithm

is_equal(other)[source]#

Determine if simulations are equal

Parameters:

other (Simulation) – another content item

Returns:

True, if two simulations are equal

Return type:

bool

class biosimulators_utils.sedml.data_model.SteadyStateSimulation(id=None, name=None, algorithm=None)[source]#

Bases: Simulation

A steady-state simulation

id[source]#

id

Type:

str

name[source]#

name

Type:

str

algorithm[source]#

algorithm

Type:

Algorithm

to_tuple()[source]#

Get a tuple representation

Returns:

tuple representation

Return type:

tuple of str

class biosimulators_utils.sedml.data_model.Style(id: str | None = None, name: str | None = None, base: Style | None = None, line: LineStyle | None = None, marker: MarkerStyle | None = None, fill: FillStyle | None = None)[source]#

Bases: SedBase, SedIdGroupMixin

A graphical style

id[source]#

id

Type:

str

name[source]#

name

Type:

str

base[source]#

base style

Type:

Style

line[source]#

line style

Type:

LineStyle

marker[source]#

marker style

Type:

MarkerStyle

fill[source]#

fill style

Type:

FillStyle

is_equal(other)[source]#

Determine if styles are equal

Parameters:

other (Style) – another style

Returns:

True, if two styles are equal

Return type:

bool

to_tuple()[source]#

Get a tuple representation

Returns:

tuple representation

Return type:

tuple of str

class biosimulators_utils.sedml.data_model.SubTask(task=None, order=None)[source]#

Bases: SedBase

A subtask of a repeated task

task[source]#

task

Type:

AbstractTask

order[source]#

order in which the subtask should be executed

Type:

int

is_equal(other)[source]#

Determine if repeated tasks are equal

Parameters:

other (SubTask) – another content item

Returns:

True, if two repeated tasks are equal

Return type:

bool

to_tuple()[source]#

Get a tuple representation

Returns:

tuple representation

Return type:

tuple of str

class biosimulators_utils.sedml.data_model.Surface(id=None, name=None, x_scale=None, y_scale=None, z_scale=None, x_data_generator=None, y_data_generator=None, z_data_generator=None, style: Style | None = None)[source]#

Bases: SedBase, SedIdGroupMixin

A surface in a 3D plot

id[source]#

id

Type:

str

name[source]#

name

Type:

str

x_scale[source]#

x axis scale

Type:

AxisScale

y_scale[source]#

y axis scale

Type:

AxisScale

z_scale[source]#

z axis scale

Type:

AxisScale

x_data_generator[source]#

x data generator

Type:

DataGenerator

y_data_generator[source]#

y data generator

Type:

DataGenerator

z_data_generator[source]#

z data generator

Type:

DataGenerator

style[source]#

graphical style

Type:

Style

is_equal(other)[source]#

Determine if surfaces are equal

Parameters:

other (Surface) – another surface

Returns:

True, if two surfaces are equal

Return type:

bool

to_tuple()[source]#

Get a tuple representation

Returns:

tuple representation

Return type:

tuple of str

class biosimulators_utils.sedml.data_model.Symbol(value)[source]#

Bases: str, Enum

Variable sumbol

time = 'urn:sedml:symbol:time'[source]#
class biosimulators_utils.sedml.data_model.TargetGroupMixin(target=None, target_namespaces=None)[source]#

Bases: ABC

Object with an id and optional name

target[source]#

id

Type:

str

target_namespaces[source]#

map of prefixes of namespaces for the target to their URIs

Type:

dict

is_equal(other)[source]#

Determine if simulations are equal

Parameters:

other (TargetGroupMixin) – another content item

Returns:

True, if two simulations are equal

Return type:

bool

class biosimulators_utils.sedml.data_model.Task(id=None, name=None, model=None, simulation=None)[source]#

Bases: AbstractTask

A task

id[source]#

id

Type:

str

name[source]#

name

Type:

str

model[source]#

model

Type:

Model

simulation[source]#

simulation

Type:

Simulation

is_equal(other)[source]#

Determine if tasks are equal

Parameters:

other (Task) – another content item

Returns:

True, if two tasks are equal

Return type:

bool

to_tuple()[source]#

Get a tuple representation

Returns:

tuple representation

Return type:

tuple of str

class biosimulators_utils.sedml.data_model.UniformRange(id=None, name=None, start=None, end=None, number_of_steps=None, number_of_points=None, type=None)[source]#

Bases: Range

A uniform range

id[source]#

id

Type:

str

name[source]#

name

Type:

str

start[source]#

start value

Type:

float

end[source]#

end value

Type:

float

number_of_steps[source]#

number of steps

Type:

int

type[source]#

type

Type:

UniformRangeType

is_equal(other)[source]#

Determine if ranges are equal

Parameters:

other (UniformRange) – another content item

Returns:

True, if two ranges are equal

Return type:

bool

property number_of_points[source]#
to_tuple()[source]#

Get a tuple representation

Returns:

tuple representation

Return type:

tuple of str

class biosimulators_utils.sedml.data_model.UniformTimeCourseSimulation(id=None, name=None, algorithm=None, initial_time=None, output_start_time=None, output_end_time=None, number_of_steps=None, number_of_points=None)[source]#

Bases: Simulation

A uniform time course simulation

id[source]#

id

Type:

str

name[source]#

name

Type:

str

algorithm[source]#

algorithm

Type:

Algorithm

initial_time[source]#

initial time

Type:

float

output_start_time[source]#

output start time

Type:

float

output_end_time[source]#

output end time

Type:

float

number_of_steps[source]#

number of time steps

Type:

int

is_equal(other)[source]#

Determine if simulations are equal

Parameters:

other (UniformTimeCourseSimulation) – another content item

Returns:

True, if two simulations are equal

Return type:

bool

property number_of_points[source]#
to_tuple()[source]#

Get a tuple representation

Returns:

tuple representation

Return type:

tuple of str

class biosimulators_utils.sedml.data_model.Variable(id=None, name=None, target=None, target_namespaces=None, symbol=None, task=None, model=None)[source]#

Bases: SedBase, SedIdGroupMixin

A model variable

id[source]#

id

Type:

str

name[source]#

name

Type:

str

target[source]#

target

Type:

str

target_namespaces[source]#

map of prefixes of namespaces for the target to their URIs

Type:

dict

symbol[source]#

symbol

Type:

str

task[source]#

task

Type:

AbstractTask

model[source]#

model

Type:

Model

is_equal(other)[source]#

Determine if data generator variables are equal

Parameters:

other (Variable) – another content item

Returns:

True, if two data generator variables are equal

Return type:

bool

to_tuple()[source]#

Get a tuple representation

Returns:

tuple representation

Return type:

tuple of str

class biosimulators_utils.sedml.data_model.VectorRange(id=None, name=None, values=None)[source]#

Bases: Range

A vector range

id[source]#

id

Type:

str

name[source]#

name

Type:

str

values[source]#

values

Type:

list of float

is_equal(other)[source]#

Determine if ranges are equal

Parameters:

other (VectorRange) – another content item

Returns:

True, if two ranges are equal

Return type:

bool

to_tuple()[source]#

Get a tuple representation

Returns:

tuple representation

Return type:

tuple of str

biosimulators_utils.sedml.exceptions module#

Exceptions for SED-ML

Author:

Jonathan Karr <karr@mssm.edu>

Date:

2021-01-12

Copyright:

2021, Center for Reproducible Biomedical Modeling

License:

MIT

exception biosimulators_utils.sedml.exceptions.SedmlExecutionError[source]#

Bases: BioSimulatorsException

Error that a SED document could not be executed

exception biosimulators_utils.sedml.exceptions.UnsupportedModelLanguageError[source]#

Bases: BioSimulatorsException, NotImplementedError

Error that a SED document could not be executed

biosimulators_utils.sedml.exec module#

Utilities for executing tasks in SED documents

Author:

Jonathan Karr <karr@mssm.edu>

Date:

2020-12-06

Copyright:

2020, Center for Reproducible Biomedical Modeling

License:

MIT

biosimulators_utils.sedml.exec.exec_plot_2d(plot, variable_results, base_out_path, rel_out_path, formats, task, log)[source]#

Execute a 2D plot, generating the curves which are available

Parameters:
  • plot (Plot2D) – plot

  • variable_results (VariableResults) – result of each data generator

  • base_out_path (str) – base path to store the plot. Complete path is {base_out_path}/{rel_out_path}/{plot.id}.csv

  • rel_out_path (str, optional) – path relative to base_out_path to store the plot

  • formats (list of VizFormat, optional) – plot format (e.g., pdf)

  • task (Task) – task

  • log (ReportLog, optional) – log of plot

Returns:

  • Status: status

  • Exception: exception for failure

  • bool: whether task contributes a variable to the plot

Return type:

tuple

biosimulators_utils.sedml.exec.exec_plot_3d(plot, variable_results, base_out_path, rel_out_path, formats, task, log)[source]#

Execute a 3D plot, generating the surfaces which are available

Parameters:
  • plot (Plot3D) – plot

  • variable_results (VariableResults) – result of each data generator

  • base_out_path (str) – base path to store the plot. Complete path is {base_out_path}/{rel_out_path}/{plot.id}.pdf

  • rel_out_path (str, optional) – path relative to base_out_path to store the plot

  • formats (list of VizFormat, optional) – plot format (e.g., pdf)

  • task (Task) – task

  • log (ReportLog, optional) – log of plot

Returns:

  • Status: status

  • Exception: exception for failure

  • bool: whether task contributes a variable to the plot

Return type:

tuple

biosimulators_utils.sedml.exec.exec_repeated_task(task, task_executer, task_vars, doc, apply_xml_model_changes=False, model_etrees=None, pretty_print_modified_xml_models=False, config=None, preprocessed_task=None, get_value_executer=None, set_value_executer=None, reset_executer=None)[source]#

Execute a repeated SED task

Parameters:
  • task (RepeatedTask) – task

  • task_executer (types.FunctionType) –

    function to execute each task in the SED-ML file. The function must implement the following interface:

    def exec_task(task, variables, preprocessed_task=None, log=None, config=None, **simulator_config):
        ''' Execute a simulation and return its results
    
        Args:
           task (:obj:`Task`): task
           variables (:obj:`list` of :obj:`Variable`): variables that should be recorded
           preprocessed_task (:obj:`object`, optional): preprocessed information about the task, including possible
                model changes and variables. This can be used to avoid repeatedly executing the same initialization
                for repeated calls to this method.
           log (:obj:`TaskLog`, optional): log for the task
           config (:obj:`Config`, optional): BioSimulators common configuration
           **simulator_config (:obj:`dict`, optional): optional simulator-specific configuration
    
        Returns:
           :obj:`VariableResults`: results of variables
        '''
        pass
    

  • task_vars (list of Variable) – variables that task must record

  • doc (SedDocument or str) – SED document or a path to SED-ML file which defines a SED document

  • apply_xml_model_changes (bool, optional) – if True, apply any model changes specified in the SED-ML file before calling task_executer.

  • model_etrees (dict of str to etree._Element) –

  • pretty_print_modified_xml_models (bool, optional) – if True, pretty print modified XML models

  • config (Config, optional) – BioSimulators common configuration

Returns:

results of the variables

Return type:

VariableResults

biosimulators_utils.sedml.exec.exec_report(report, variable_results, base_out_path, rel_out_path, formats, task, log=None, type=<class 'biosimulators_utils.sedml.data_model.Report'>)[source]#

Execute a report, generating the data sets which are available

Parameters:
  • report (Report) – report

  • variable_results (VariableResults) – result of each data generator

  • base_out_path (str) –

    path to store the outputs

    • CSV: directory in which to save outputs to files {base_out_path}/{rel_out_path}/{report.id}.csv

    • HDF5: directory in which to save a single HDF5 file ({base_out_path}/reports.h5), with reports at keys {rel_out_path}/{report.id} within the HDF5 file

  • rel_out_path (str, optional) – path relative to base_out_path to store the outputs

  • formats (list of ReportFormat, optional) – report format (e.g., csv or h5)

  • task (Task) – task

  • log (ReportLog, optional) – log of report

  • type (types.Type) – type of output (e.g., subclass of Output such as Report, Plot2D)

Returns:

  • DataSetResults: report

  • Status: status

  • Exception: exception for failure

  • bool: whether task contribute a variable to the report

Return type:

tuple

biosimulators_utils.sedml.exec.exec_sed_doc(task_executer, doc, working_dir, base_out_path, rel_out_path=None, apply_xml_model_changes=False, log=None, indent=0, pretty_print_modified_xml_models=False, log_level=StandardOutputErrorCapturerLevel.c, config=None, get_value_executer=None, set_value_executer=None, preprocessed_task_executer=None, reset_executer=None)[source]#

Execute the tasks specified in a SED document and generate the specified outputs

Parameters:
  • task_executer (types.FunctionType) –

    function to execute each task in the SED-ML file. The function must implement the following interface:

    def exec_task(task, variables, preprocessed_task=None, log=None, config=None, **simulator_config):
        ''' Execute a simulation and return its results
    
        Args:
            task (:obj:`Task`): task
            variables (:obj:`list` of :obj:`Variable`): variables that should be recorded
            preprocessed_task (:obj:`object`, optional): preprocessed information about the task, including possible
                model changes and variables. This can be used to avoid repeatedly executing the same initialization
                for repeated calls to this method.
            log (:obj:`TaskLog`, optional): log for the task
            config (:obj:`Config`, optional): BioSimulators common configuration
            **simulator_config (:obj:`dict`, optional): optional simulator-specific configuration
    
        Returns:
           :obj:`VariableResults`: results of variables
        '''
        pass
    

  • doc (SedDocument or str) – SED document or a path to SED-ML file which defines a SED document

  • working_dir (str) – working directory of the SED document (path relative to which models are located)

  • base_out_path (str) –

    path to store the outputs

    • CSV: directory in which to save outputs to files {base_out_path}/{rel_out_path}/{report.id}.csv

    • HDF5: directory in which to save a single HDF5 file ({base_out_path}/reports.h5), with reports at keys {rel_out_path}/{report.id} within the HDF5 file

  • rel_out_path (str, optional) – path relative to base_out_path to store the outputs

  • apply_xml_model_changes (bool, optional) – if True, apply any model changes specified in the SED-ML file before calling task_executer.

  • log (SedDocumentLog, optional) – log of the document

  • indent (int, optional) – degree to indent status messages

  • pretty_print_modified_xml_models (bool, optional) – if True, pretty print modified XML models

  • log_level (StandardOutputErrorCapturerLevel, optional) – level at which to log output

  • config (Config) – configuration

Returns:

  • ReportResults: results of each report

  • SedDocumentLog: log of the document

Return type:

tuple

biosimulators_utils.sedml.exec.exec_task(task, task_executer, task_vars, doc, log=None, config=None, preprocessed_task=None)[source]#

Execute a basic SED task

Parameters:
  • task (Task) – task

  • task_executer (types.FunctionType) –

    function to execute each task in the SED-ML file. The function must implement the following interface:

    def exec_task(task, variables, preprocessed_task=None, log=None, config=None, **simulator_config):
        ''' Execute a simulation and return its results
    
        Args:
            task (:obj:`Task`): task
            variables (:obj:`list` of :obj:`Variable`): variables that should be recorded
            preprocessed_task (:obj:`object`, optional): preprocessed information about the task, including possible
                model changes and variables. This can be used to avoid repeatedly executing the same initialization
                for repeated calls to this method.
            log (:obj:`TaskLog`, optional): log for the task
            config (:obj:`Config`, optional): BioSimulators common configuration
            **simulator_config (:obj:`dict`, optional): optional simulator-specific configuration
    
        Returns:
            :obj:`tuple`:
    
                * :obj:`VariableResults`: results of variables
                * :obj:`TaskLog`: log
        '''
        pass
    

  • task_vars (list of Variable) – variables that task must record

  • doc (SedDocument or str) – SED document or a path to SED-ML file which defines a SED document

  • log (TaskLog, optional) – log

  • config (Config, optional) – BioSimulators common configuration

Returns:

results of the variables

Return type:

VariableResults

biosimulators_utils.sedml.exec.get_report_for_plot2d(plot)[source]#

Get a report for a 2D plot with a dataset for each data generator of the curves

Parameters:

plot (Plot2D) – plot

Returns:

report with a dataset for each data generator of the curves

Return type:

Report

biosimulators_utils.sedml.exec.get_report_for_plot3d(plot)[source]#

Get a report for a 3D plot with a dataset for each data generator of the surfaces

Parameters:

plot (Plot3D) – plot

Returns:

report with a dataset for each data generator of the surfaces

Return type:

Report

biosimulators_utils.sedml.io module#

Utilities for reading and writing SED documents to SED-ML files

Author:

Jonathan Karr <karr@mssm.edu>

Date:

2020-12-06

Copyright:

2020, Center for Reproducible Biomedical Modeling

License:

MIT

class biosimulators_utils.sedml.io.SedmlSimulationReader[source]#

Bases: object

SED-ML reader

errors[source]#

errors

Type:

nested list of str

warnings[source]#

warnings

Type:

nested list of str

run(filename, validate_semantics=True, validate_models_with_languages=True, validate_targets_with_model_sources=True, config=None)[source]#

Base class for reading a SED document

Parameters:
  • filename (str) – path to SED-ML document

  • validate_semantics (bool, optional) – if True, check that SED-ML is semantically valid

  • validate_models_with_languages (bool, optional) – if True, validate models

  • validate_targets_with_model_sources (bool, optional) – if True, validate targets against their models

  • config (Config, optional) – whether to fail on missing includes

Returns:

SED document

Return type:

data_model.SedDocument

Raises:

ValueError – if any of the following conditions are met * The SED document contains changes other than instances of SedChangeAttribute * The models or simulations don’t have unique ids * A model or simulation references cannot be resolved

class biosimulators_utils.sedml.io.SedmlSimulationWriter[source]#

Bases: object

SED-ML writer

_num_meta_id[source]#

number of assigned meta ids

Type:

int

_doc_sed[source]#

SED document

Type:

libsedml.SedDocument

_obj_to_sed_obj_map[source]#

map from data model objects to their corresponding libSED-ML objects

Type:

object => object

run(doc, filename, validate_semantics=True, validate_models_with_languages=True, validate_targets_with_model_sources=True, config=None)[source]#

Save a SED document to an SED-ML XML file

Parameters:
  • doc (data_model.SedDocument) – SED document

  • filename (str) – Path to save simulation experiment in SED-ML format

  • validate_semantics (bool, optional) – if True, check that SED-ML is semantically valid

  • validate_models_with_languages (bool, optional) – if True, validate models

  • validate_targets_with_model_sources (bool, optional) – if True, validate targets against their models

  • config (Config, optional) – whether to fail on missing includes

Raises:

NotImplementedError – document uses an supported type of task or output

biosimulators_utils.sedml.math module#

Data model for SED

Author:

Jonathan Karr <karr@mssm.edu>

Date:

2020-12-06

Copyright:

2020, Center for Reproducible Biomedical Modeling

License:

MIT

biosimulators_utils.sedml.math.compile_math(math)[source]#

Compile a mathematical expression

Parameters:

math (str) – mathematical expression

Returns:

compiled expression

Return type:

_ast.Expression

biosimulators_utils.sedml.math.eval_math(math, compiled_math, workspace)[source]#

Compile a mathematical expression

Parameters:
  • math (str) – mathematical expression

  • compiled_math (_ast.Expression) – compiled expression

  • workspace (dict) – values to use for the symbols in the expression

Returns:

result of the expression

Return type:

object

Raises:

ValueError – if the expression could not be evaluated

biosimulators_utils.sedml.math.log(*args)[source]#

Evaluate a logarithm

Parameters:

*args (list of float) – value optional proceeded by a base; otherwise the logarithm is calculated in base 10

Returns:

float

biosimulators_utils.sedml.math.piecewise(*args)[source]#

Evaluate a MathML piecewise function

Parameters:

*args (list of float) – pairs of value and conditions followed by a default value

Returns:

float

biosimulators_utils.sedml.model_utils module#

Utilities for working with models referenced by SED documents

Author:

Jonathan Karr <karr@mssm.edu>

Date:

2021-04-05

Copyright:

2021, Center for Reproducible Biomedical Modeling

License:

MIT

biosimulators_utils.sedml.model_utils.build_combine_archive_for_model(model_filename, model_language, simulation_type, archive_filename, extra_contents=None, config=None, **model_language_options)[source]#

Build A COMBINE/OMEX archive with a SED-ML file for a model

Parameters:
  • model_filename (str) – path to model file

  • model_language (ModelLanguage) – model language

  • simulation_type (type) – subclass of Simulation

  • archive_filename (str) – path to save COMBINE/OMEX archive

  • extra_contents (dict of str -> CombineArchiveContent, optional) – dictionary that maps the local paths of additional files to include in the COMBINE/OMEX archive to their intended locations within the COMBINE/OMEX archive

  • config (Config, optional) – whether to fail on missing includes

  • **model_language_options – additional options to pass to the methods for individual model formats

biosimulators_utils.sedml.model_utils.get_parameters_variables_outputs_for_simulation(model_filename, model_language, simulation_type, algorithm_kisao_id=None, change_level=<class 'biosimulators_utils.sedml.data_model.SedDocument'>, native_ids=False, native_data_types=False, model_language_options=None)[source]#

Get the possible observables for a simulation of a model

This method supports the following formats

  • SBML

  • SBML-fbc

  • SBML-qual

Parameters:
  • model_filename (str) – path to model file

  • model_language (str) – model language (e.g., urn:sedml:language:sbml)

  • simulation_type (types.Type) – subclass of Simulation

  • algorithm_kisao_id (str, optional) – KiSAO id of the algorithm for simulating the model (e.g., KISAO_0000019 for CVODE)

  • change_level (types.Type, optional) – level at which model changes will be made (SedDocument or Task)

  • native_ids (bool, optional) – whether to return the raw id and name of each model component rather than the suggested name for the variable of an associated SED-ML data generator

  • native_data_types (bool, optional) – whether to return new_values in their native data types

  • model_language_options (dict, optional) – additional options to pass to the methods for individual model formats. Dictionary that maps model languages (ModelLanguage) to dictionaries of optional keyword arguments for each language

Returns:

possible attributes of a model that can be changed and their default values list of Simulation: simulation of the model list of Variable: possible observables for a simulation of the model list of Plot: possible plots of the results of a simulation of the model

Return type:

list of ModelAttributeChange

Raises:

UnsupportedModelLanguageError – if model_language is not a supported language

biosimulators_utils.sedml.utils module#

Utilities for working with SED documents

Author:

Jonathan Karr <karr@mssm.edu>

Date:

2020-12-06

Copyright:

2020, Center for Reproducible Biomedical Modeling

License:

MIT

biosimulators_utils.sedml.utils.add_namespaces_to_xml_node(node, namespace_prefixes, namespaces)[source]#

Add namespaces to an XML node

Parameters:
  • node (libsedml.XMLNode) – XML node

  • namespace_prefixes (set of str) – namespace prefixes used in the node which aren’t defined in the node

  • namespaces (libsedml.XMLNamespaces) – namespaces for the parent document

biosimulators_utils.sedml.utils.append_all_nested_children_to_doc(doc)[source]#

Append all nested children to a SED document

Parameters:

doc (SedDocument) – SED document

biosimulators_utils.sedml.utils.apply_changes_to_xml_model(model, model_etree, sed_doc=None, working_dir=None, variable_values=None, range_values=None, validate_unique_xml_targets=True, set_value_executer=None, preprocessed_task_sub_executer=None)[source]#

Modify an XML-encoded model according to a model change

Parameters:
  • model (Model) – model

  • model_etree (etree._ElementTree) – element tree for model

  • sed_doc (SedDocument, optional) – parent SED document; used to resolve sources defined by reference to other models; required for compute changes

  • working_dir (str, optional) – working directory of the SED document (path relative to which models are located); required for compute changes

  • variable_values (dict, optional) – dictionary which contains the value of each variable of each compute model change

  • range_values (dict, optional) – dictionary which contains the value of each range of each set value compute model change

  • validate_unique_xml_targets (bool, optional) – whether to validate the XML targets match uniue objects

biosimulators_utils.sedml.utils.calc_compute_model_change_new_value(change, variable_values=None, range_values=None)[source]#

Calculate the new value of a compute model change

Parameters:
  • change (ComputeModelChange) – change

  • variable_values (dict, optional) – dictionary which contains the value of each variable of each compute model change

  • range_values (dict, optional) – dictionary which contains the value of each range of each set value compute model change

Returns:

new value

Return type:

float

biosimulators_utils.sedml.utils.calc_data_generator_results(data_generator, variable_results)[source]#

Calculate the results of a data generator from the results of its variables

Parameters:
  • data_generator (DataGenerator) – data generator

  • variable_results (VariableResults) – results for the variables of the data generator

Returns:

result of data generator

Return type:

numpy.ndarray

biosimulators_utils.sedml.utils.calc_data_generators_results(data_generators, variable_results, output, task, make_shapes_consistent=True)[source]#

Calculator the values of a list of data generators

Parameters:
  • data_generators (list of DataGenerator) – SED task

  • variable_results (VariableResults) – results of the SED variables involved in the data generators

  • output (Output) – SED output

  • task (Task) – SED task

  • make_shapes_consistent (bool, optional) – where to make the shapes of the data generators consistent (e.g., for concatenation into a table for a report)

Returns:

  • DataGeneratorResults: values of the data generators

  • dict of str to Status: dictionary that maps the id of each data generator to its status

  • Exception: exception for failures

  • bool: where the task contributes to any of the data generators

Return type:

tuple

biosimulators_utils.sedml.utils.convert_xml_node_to_string(node)[source]#

Generate a string representation of an XML node

Parameters:

node (libsedml.XMLNode) – XML node

Returns:

string representation of the node

Return type:

str

biosimulators_utils.sedml.utils.does_model_language_use_xpath_variable_targets(language)[source]#

Determine if the model language uses XPaths to target variables of data generators

Parameters:

language (str) – language

Returns:

True, if the model language is encoded in XML

Return type:

bool

biosimulators_utils.sedml.utils.get_data_generators_for_output(output)[source]#

Get the data generators involved in an output

Parameters:

output (Output) – report or plot

Returns:

data generators involved in the output

Return type:

set of DataGenerator

biosimulators_utils.sedml.utils.get_first_last_models_executed_by_task(task)[source]#

Get the models executed by a task in the order they are executed

Parameters:

task (Task) – task

Returns:

models

Return type:

tuple of Model

biosimulators_utils.sedml.utils.get_model_changes_for_task(task)[source]#

Get the changes to models for a task

Parameters:

task (Task) – task

Returns:

changes to the model

Return type:

list of ModelChange

biosimulators_utils.sedml.utils.get_models_referenced_by_model_change(change)[source]#

Get the models referenced from a model change

Parameters:

change (ModelChange) – model change

Returns:

models

Return type:

set of Model

biosimulators_utils.sedml.utils.get_models_referenced_by_range(range)[source]#

Get the models referenced by a range

Parameters:

range (Range) – range

Returns:

models

Return type:

set of Model

biosimulators_utils.sedml.utils.get_models_referenced_by_task(task)[source]#

Get the models referenced from a task

Parameters:

task (Task) – task

Returns:

models

Return type:

set of Model

biosimulators_utils.sedml.utils.get_namespaces_for_sed_object(obj)[source]#

Get the namespace prefixes and URIs defined for a SED object

Parameters:

obj (libsedml.SedBase) – SED object

Returns:

dictionary that maps the prefixes of namespaces to their URIs

Return type:

dict

biosimulators_utils.sedml.utils.get_range_len(range)[source]#

Get the length of a range

Parameters:

range (Range) – range

Returns:

length of the range

Return type:

int

Raises:

NotImplementedError – if range isn’t an instance of UniformRange, VectorRange, or FunctionalRange.

biosimulators_utils.sedml.utils.get_task_results_shape(task)[source]#

Get the shape of the results of a task

Parameters:

task (Task) – task

Returns:

shape of the results of a task

Return type:

tuple of int

biosimulators_utils.sedml.utils.get_value_of_variable_model_xml_targets(variable, model_etrees)[source]#

Get the value of a variable of a model

Parameters:
  • variable (Variable) – variable

  • model_etrees (dict of str to etree._Element) – dictionary that maps the ids of models to paths to files which contain their XML definitions

Returns:

value

Return type:

float

biosimulators_utils.sedml.utils.get_values_of_variable_model_xml_targets_of_model_change(change, sed_doc, model_etrees, working_dir)[source]#

Get the values of the model variables of a compute model change

Parameters:
  • change (ComputeModelChange) – compute model change

  • sed_doc (SedDocument) – SED document

  • model_etrees (dict of str to etree._Element) – map from the ids of models to element trees of their sources

  • working_dir (str) – working directory of the SED document (path relative to which models are located)

Returns:

dictionary which contains the value of each variable of each

compute model change

Return type:

dict

biosimulators_utils.sedml.utils.get_variables_for_data_generators(data_generators)[source]#

Get the variables involved in a collection of generators

Parameters:

data_generators (list of DataGenerator) – data generators

Returns:

variables involved in the data generators

Return type:

set of Variable

biosimulators_utils.sedml.utils.get_variables_for_task(doc, task)[source]#

Get the variables that a task must record

Parameters:
  • doc (SedDocument) – SED document

  • task (Task) – task

Returns:

variables that task must record

Return type:

list of Variable

biosimulators_utils.sedml.utils.get_xml_node_namespace_tag_target(etree, target_namespaces=None)[source]#

Get the namespace, tag, and target of an XML node

Parameters:
  • etree (etree._Element) – element tree

  • target_namespaces (dict, optional) – dictionary that maps the prefixes of namespaces to their URIs

Returns:

  • str: namespace URI

  • str: namespace prefix

  • str: tag

  • str: target for use with SED target XPaths

  • dict: dictionary that maps the prefixes of namespaces to their URIs

Return type:

tuple

biosimulators_utils.sedml.utils.is_model_language_encoded_in_xml(language)[source]#

Determine if the model language is encoded in XML

Parameters:

language (str) – language

Returns:

True, if the model language is encoded in XML

Return type:

bool

biosimulators_utils.sedml.utils.remove_algorithm_parameter_changes(sed_doc)[source]#

Remove algorithm parameter changes from a SED document

Parameters:

sed_doc (SedDocument) – SED document

biosimulators_utils.sedml.utils.remove_model_changes(sed_doc)[source]#

Remove model changes from a SED document

Parameters:

sed_doc (SedDocument) – SED document

biosimulators_utils.sedml.utils.remove_plots(sed_doc)[source]#

Remove plots from a SED document

Parameters:

sed_doc (SedDocument) – SED document

biosimulators_utils.sedml.utils.replace_complex_data_generators_with_generators_for_individual_variables(sed_doc)[source]#

Remove model changes from a SED document

Parameters:

sed_doc (SedDocument) – SED document

biosimulators_utils.sedml.utils.resolve_model(model, sed_doc, working_dir)[source]#

Resolve the source of a model

Parameters:
  • model (Model) –

    model whose source is one of the following

    • A path to a file

    • A URL

    • A MIRIAM URN for an entry in the BioModelsl database (e.g., urn:miriam:biomodels.db:BIOMD0000000012)

    • A reference to another model, using the id of the other model (e.g., #other-model-id). In this case, the model also inherits changes from the parent model.

  • sed_doc (SedDocument) – parent SED document; used to resolve sources defined by reference to other models

  • working_dir (str) – working directory of the SED document (path relative to which models are located)

Returns:

temporary path to the source of the modified model, if the model needed to be resolved from

Return type:

str

biosimulators_utils.sedml.utils.resolve_model_and_apply_xml_changes(orig_model, sed_doc, working_dir, apply_xml_model_changes=True, save_to_file=True, pretty_print_modified_xml_models=False, set_value_executer=None, preprocessed_task_sub_executer=None)[source]#

Resolve the source of a model and, optionally, apply XML changes to the model.

Parameters:
  • model (Model) –

    model whose source is one of the following

    • A path to a file

    • A URL

    • A MIRIAM URN for an entry in the BioModelsl database (e.g., urn:miriam:biomodels.db:BIOMD0000000012)

    • A reference to another model, using the id of the other model (e.g., #other-model-id). In this case, the model also inherits changes from the parent model.

  • sed_doc (SedDocument) – parent SED document; used to resolve sources defined by reference to other models

  • working_dir (str) – working directory of the SED document (path relative to which models are located)

  • apply_xml_model_changes (bool, optional) – if True, apply any model changes specified in the SED-ML file before calling task_executer.

  • save_to_file (bool) – whether to save the resolved/modified model to a file

  • pretty_print_modified_xml_models (bool, optional) – if True, pretty print modified XML models

Returns:

  • Model: modified model

  • str: temporary path to the source of the modified model, if the model needed to be resolved from a remote source of modified

  • etree._Element: element tree for the resolved/modified model

Return type:

tuple

biosimulators_utils.sedml.utils.resolve_range(range, model_etrees=None)[source]#

Resolve the values of a range

Parameters:
  • range (Range) – range

  • model_etrees (dict of str to etree._Element) – map from the ids of models to element trees of their sources; required to resolve variables of functional ranges

Returns:

values of the range

Return type:

list of float

Raises:

NotImplementedError – if range isn’t an instance of UniformRange, VectorRange, or FunctionalRange.

biosimulators_utils.sedml.validation module#

Methods for validating SED objects

Author:

Jonathan Karr <karr@mssm.edu>

Date:

2020-12-09

Copyright:

2020, Center for Reproducible Biomedical Modeling

License:

MIT

biosimulators_utils.sedml.validation.validate_algorithm(algorithm)[source]#

Validate an algorithm

Parameters:

algorithm (Algorithm) – algorithm

Returns:

  • nested list of str: nested list of errors (e.g., required ids missing or ids not unique)

  • nested list of str: nested list of errors (e.g., required ids missing or ids not unique)

Return type:

tuple

biosimulators_utils.sedml.validation.validate_calculation(calculation)[source]#

Validate that all of the symbols needed for a calculation are defined

Parameters:

expression (Calculation) –

Returns:

  • nested list of str: nested list of errors (e.g., required ids missing or ids not unique)

  • nested list of str: nested list of warmings (e.g., required ids missing or ids not unique)

Return type:

tuple

biosimulators_utils.sedml.validation.validate_data_generator(data_generator, model_etrees=None, validate_targets_with_model_sources=True)[source]#

Validate a data generator

  • Parameters have ids

  • Variables have ids

  • Variables have target OR symbol

  • Variables don’t have model references

  • Have math

  • Math is valid

Parameters:
  • data_generator (DataGenerator) – data generator

  • model_etrees (dict, optional) – dictionary that maps models to XML element trees of their sources

  • validate_targets_with_model_sources (bool, optional) – whether to validate the targets of the variables of the data generator

Returns:

  • nested list of str: nested list of errors (e.g., required ids missing or ids not unique)

  • nested list of str: nested list of warnings (e.g., required ids missing or ids not unique)

Return type:

tuple

biosimulators_utils.sedml.validation.validate_data_generator_variables(variables, model_etrees=None, validate_targets_with_model_sources=True)[source]#

Check variables have a symbol or target

Parameters:
  • variables (list of Variable) – variables

  • model_etrees (dict, optional) – dictionary that maps models to XML element trees of their sources

  • validate_targets_with_model_sources (bool, optional) – whether to validate the targets of the variables of the data generator

Returns:

nested list of errors (e.g., required ids missing or ids not unique)

Return type:

nested list of str

biosimulators_utils.sedml.validation.validate_doc(doc, working_dir, validate_semantics=True, validate_models_with_languages=True, validate_targets_with_model_sources=True, config=None)[source]#

Validate a SED document

Parameters:
  • doc (SedDocument) – SED document

  • working_dir (str) – working directory (e.g., for referencing model files)

  • validate_semantics (bool, optional) – if True, check that SED-ML is semantically valid

  • validate_models_with_languages (bool, optional) – if True, validate models

  • validate_targets_with_model_sources (bool, optional) – if True, validate targets against their models

  • config (Config, optional) – whether to fail on missing includes

Returns:

  • nested list of str: nested list of errors (e.g., required ids missing or ids not unique)

  • nested list of str: nested list of errors (e.g., required ids missing or ids not unique)

Return type:

tuple

biosimulators_utils.sedml.validation.validate_model(model, model_ids, working_dir, validate_models_with_languages=True, config=None, check_in_model_source=True, model_etree=None)[source]#

Check a model

Parameters:
  • model (Model) – model

  • model_ids (list of str) – ids of models

  • working_dir (str) – working directory (e.g., for referencing model files)

  • validate_models_with_languages (bool, optional) – if True, validate models

  • config (Config, optional) – whether to fail on missing includes

Returns:

  • nested list of str: nested list of errors (e.g., required ids missing or ids not unique)

  • nested list of str: nested list of warnings (e.g., required ids missing or ids not unique)

Return type:

tuple

biosimulators_utils.sedml.validation.validate_model_change_types(changes, types=(<class 'biosimulators_utils.sedml.data_model.ModelChange'>, ))[source]#

Check that model changes are valid

Parameters:
  • changes (list of ModelChange) – model changes

  • types (type or tuple of type, optional) – valid type(s) of model changes

Returns:

nested list of errors (e.g., required ids missing or ids not unique)

Return type:

nested list of str

biosimulators_utils.sedml.validation.validate_model_changes(model, check_in_model_source=True, model_etree=None)[source]#

Check that model changes are semantically valid

  • Check that the variables of compute model changes are valid

Parameters:

model (Model) – model

Returns:

nested list of errors (e.g., required ids missing or ids not unique)

Return type:

nested list of str

biosimulators_utils.sedml.validation.validate_model_language(language, valid_languages)[source]#

Check that model is encoded in a specific language

Parameters:
  • language (str) – model language

  • valid_language (ModelLanguage or list of ModelLanguage) – valid language(s)

Returns:

nested list of errors (e.g., required ids missing or ids not unique)

Return type:

nested list of str

biosimulators_utils.sedml.validation.validate_model_source(model, model_ids, working_dir, validate_models_with_languages=True, config=None)[source]#

Check the source of a model

Parameters:
  • model (Model) – model

  • model_ids (list of str) – ids of models

  • working_dir (str) – working directory (e.g., for referencing model files)

  • validate_models_with_languages (bool, optional) – if True, validate models

  • config (Config, optional) – whether to fail on missing includes

Returns:

  • nested list of str: nested list of errors (e.g., required ids missing or ids not unique)

  • nested list of str: nested list of warnings (e.g., required ids missing or ids not unique)

Return type:

tuple

biosimulators_utils.sedml.validation.validate_model_with_language(source, language, name=None, config=None)[source]#

Check that a model is valid

Parameters:
  • source (str) – path to model

  • language (ModelLanguage) – language

  • name (str, optional) – name of model for use in error messages

  • config (Config, optional) – whether to fail on missing includes

Returns:

  • nested list of str: nested list of errors (e.g., required ids missing or ids not unique)

  • nested list of str: nested list of errors (e.g., required ids missing or ids not unique)

  • object: model object

Return type:

tuple

biosimulators_utils.sedml.validation.validate_output(output)[source]#

Validate an output

  • Reports * Data sets have ids and labels * Data sets reference data generators

  • Plots

    • Curves and surfaces have ids

    • x, y, z attributes reference data generators

Parameters:

output (Output) – output

Returns:

  • nested list of str: nested list of errors (e.g., required ids missing or ids not unique)

  • nested list of str: nested list of warnings (e.g., required ids missing or ids not unique)

Return type:

tuple

biosimulators_utils.sedml.validation.validate_reference(obj, obj_label, attr_name, attr_label)[source]#
biosimulators_utils.sedml.validation.validate_repeated_task_has_one_model(task)[source]#

Validate a that a repeated task involves a single model

Parameters:

task (RepeatedTask) – repeated task

Returns:

  • nested list of str: nested list of errors (e.g., required ids missing or ids not unique)

  • nested list of str: nested list of warnings (e.g., required ids missing or ids not unique)

Return type:

tuple

biosimulators_utils.sedml.validation.validate_simulation(simulation)[source]#

Check that simulation is a valid simulation

Parameters:

simulation (Simulation) – simulation

Returns:

  • nested list of str: nested list of errors (e.g., required ids missing or ids not unique)

  • nested list of str: nested list of errors (e.g., required ids missing or ids not unique)

Return type:

tuple

biosimulators_utils.sedml.validation.validate_simulation_type(simulation, types)[source]#

Check that simulation is a time course simulation

Parameters:
  • simulation (Simulation) – simulation

  • types (type) – valid simulation types

Returns:

nested list of errors (e.g., required ids missing or ids not unique)

Return type:

nested list of str

biosimulators_utils.sedml.validation.validate_target(target, namespaces, context, language, model_id, model_etree=None, doc=None, check_in_model_source=False, warn_xpaths_not_validated=True, model_change=False)[source]#

Validate that a target is a valid XPath and that the namespaces needed to resolve a target are defined

Parameters:
  • target (str) – XPath to a model element or attribute

  • namespaces (dict) – dictionary that maps prefixes of namespaces to their URIs

  • context (type) –

  • language (str) – model language

  • model_id (str) – model id

  • model_etree (etree.Element, optional) – XML element tree for model source

  • doc (SedDocument, optional) – SED document

  • check_in_model_source (bool, optional) – whether to check that the target exists in the source

  • warn_xpaths_not_validated (bool, optional) – whether to warn that XPaths cannot be validated

  • model_changes (bool, optional) – whether the model has changes that could validate or invalidate XPaths.

Returns:

nested list of errors (e.g., required ids missing or ids not unique)

Return type:

nested list of str

biosimulators_utils.sedml.validation.validate_target_xpaths(targets, model_etree, attr='id')[source]#

Validate that the target of each model change or variable matches one object in an XML-encoded model and, optionally, return the value of one of its attributes

Parameters:
  • targets (list of TargetGroupMixin) – model changes or variables

  • model_source (lxml.etree._ElementTree) – element tree for the XML model document

  • attr (str, optional) – attribute to get values of

Returns:

dictionary that maps each XPath to the

value of the attribute of the object in the XML file that matches the XPath

Return type:

dict of str to str

biosimulators_utils.sedml.validation.validate_task(task)[source]#

Validate a simulation task

Parameters:

task (Task) – task

Returns:

nested list of errors (e.g., required ids missing or ids not unique)

Return type:

nested list of str

biosimulators_utils.sedml.validation.validate_uniform_range(range)[source]#

Validate a uniform range

Parameters:

range (data_model.UniformRange) – range

Returns:

nested list of errors (e.g., required ids missing or ids not unique)

Return type:

nested list of str

biosimulators_utils.sedml.warnings module#

Warnings for misuse of SED-ML

Author:

Jonathan Karr <karr@mssm.edu>

Date:

2020-12-06

Copyright:

2020, Center for Reproducible Biomedical Modeling

License:

MIT

exception biosimulators_utils.sedml.warnings.IllogicalSedmlWarning[source]#

Bases: BioSimulatorsWarning

Warning that a SED document is illogical, such as when a report or plot contains no datasets, curves, or surfaces.

exception biosimulators_utils.sedml.warnings.InconsistentVariableShapesWarning[source]#

Bases: BioSimulatorsWarning

Warning that the variables of a data generator have different shapes.

exception biosimulators_utils.sedml.warnings.NoCurvesWarning[source]#

Bases: IllogicalSedmlWarning

Warning that a 2D plot does not contain any curves

exception biosimulators_utils.sedml.warnings.NoDataSetsWarning[source]#

Bases: IllogicalSedmlWarning

Warning that a report does not contain any data sets

exception biosimulators_utils.sedml.warnings.NoOutputsWarning[source]#

Bases: IllogicalSedmlWarning

Warning that a SED document does not have any outputs

exception biosimulators_utils.sedml.warnings.NoSurfacesWarning[source]#

Bases: IllogicalSedmlWarning

Warning that a 3D plot does not contain any surfaces

exception biosimulators_utils.sedml.warnings.NoTasksWarning[source]#

Bases: IllogicalSedmlWarning

Warning that a SED document does not have any tasks

exception biosimulators_utils.sedml.warnings.SedmlFeatureNotSupportedWarning[source]#

Bases: BioSimulatorsWarning

Warning that a feature of a SED document was skipped because it requires a SED feature that is not yet supported. The warning is only used when skipping a portion of a document doesn’t affect the semantic meaning of the unskipped portions of the document (e.g., skipping generating a plot doesn’t adversely affect reports).