sbmlsim.simulation

Package for simulation.

Submodules

Package Contents

Classes

AbstractSim

AbstractSim.

Dimension

Define dimension for a simulation or scan.

TimecourseSim

Timecourse simulation consisting of multiple concatenated timecourses.

Timecourse

Simulation definition.

ScanSim

A scan simulation over another AbstractSim.

class sbmlsim.simulation.AbstractSim[source]

Bases: abc.ABC

AbstractSim.

Base class of simulations.

abstract dimensions(self)

Get dimension of the simulation.

Return type

List[Dimension]

abstract normalize(self, uinfo)

Normalize simulation.

Parameters

uinfo (sbmlsim.units.UnitsInformation) –

Return type

None

abstract add_model_changes(self, changes)

Add model changes to model.

Parameters

changes (Dict) –

Return type

None

to_dict(self)

Convert to dictionary.

Return type

Dict[str, str]

class sbmlsim.simulation.Dimension(dimension, index=None, changes=None)[source]

Bases: object

Define dimension for a simulation or scan.

The dimension defines how the dimension is called, the index is the corresponding index of the dimension.

Parameters
  • dimension (str) –

  • index (numpy.ndarray) –

  • changes (Dict) –

__repr__(self)

Get representation.

Return type

str

__len__(self)

Get length.

Return type

int

static indices_from_dimensions(dimensions)

Get indices of all combinations of dimensions.

Parameters

dimensions (List[Dimension]) –

class sbmlsim.simulation.TimecourseSim(timecourses, selections=None, reset=True, time_offset=0.0)[source]

Bases: sbmlsim.simulation.AbstractSim

Timecourse simulation consisting of multiple concatenated timecourses.

In case of a single timecourse, only the single timecourse is executed.

Parameters
  • timecourses (Union[Timecourse, List[Timecourse]]) –

  • selections (Optional[List[str]]) –

  • reset (bool) –

  • time_offset (float) –

__repr__(self)

Get representation.

Return type

str

_time(self)

Calculate the time vector complete simulation.

Return type

numpy.ndarray

dimensions(self)

Get dimensions.

Return type

List[sbmlsim.simulation.Dimension]

add_model_changes(self, model_changes)

Add model changes to given simulation.

Parameters

model_changes (Dict) –

Return type

None

normalize(self, uinfo)

Normalize timecourse simulation.

Parameters

uinfo (sbmlsim.units.UnitsInformation) –

Return type

None

strip_units(self)

Strip units from simulation.

Return type

None

to_dict(self)

Convert to dictionary.

Return type

Dict[str, Any]

to_json(self, path=None)

Convert definition to JSON.

Parameters

path (pathlib.Path) –

Return type

str

static from_json(json_info)

Load from JSON.

Parameters

json_info (Union[str, pathlib.Path]) –

Return type

TimecourseSim

__str__(self)

Get string representation.

Return type

str

class sbmlsim.simulation.Timecourse(start, end, steps, changes=None, model_changes=None, model_manipulations=None, discard=False)[source]

Bases: sbmlsim.serialization.ObjectJSONEncoder

Simulation definition.

Definition of all information necessary to run a single timecourse simulation.

A single simulation consists of multiple changes which are applied, all simulations are performed and collected.

Changesets and selections are deep copied for persistence.

Parameters
  • start (float) –

  • end (float) –

  • steps (int) –

  • changes (Dict[str, pint.Quantity]) –

  • model_changes (Dict[str, pint.Quantity]) –

  • model_manipulations (dict) –

  • discard (bool) –

__repr__(self)

Get string representation.

Return type

str

to_dict(self)

Convert to dictionary.

Return type

Dict[str, Any]

add_change(self, sid, value)

Add change.

Parameters
  • sid (str) –

  • value (float) –

Return type

None

remove_change(self, sid)

Remove change for given id.

Parameters

sid (str) –

Return type

None

add_model_change(self, sid, change)

Add model change.

Parameters

sid (str) –

Return type

None

add_model_changes(self, model_changes)

Add model changes.

Parameters

model_changes (Dict[str, str]) –

Return type

None

remove_model_change(self, sid)

Remove model change for id.

Parameters

sid (str) –

Return type

None

normalize(self, uinfo)

Normalize values to model units for all changes.

Parameters

uinfo (sbmlsim.units.UnitsInformation) –

Return type

None

strip_units(self)

Strip units from changes for parallel simulation.

All changes must be normalized before stripping !.

Return type

None

class sbmlsim.simulation.ScanSim(simulation, dimensions=None, mapping=None)[source]

Bases: sbmlsim.simulation.AbstractSim

A scan simulation over another AbstractSim.

FIXME: probably not necessary to make this a simulation.

Parameters
__repr__(self)

Get representation.

Return type

str

dimensions(self)

Get dimensions.

Return type

List[sbmlsim.simulation.Dimension]

get_dimension(self, key)

Get dimension by key.

Parameters

key (str) –

Return type

sbmlsim.simulation.Dimension

indices(self)

Get indices of all combinations.

add_model_changes(self, model_changes)

Add model changes to first timecourse.

Parameters

model_changes (Dict) –

Return type

None

normalize(self, uinfo)

Normalize units in scan.

Requires normalization of timecourse simulation as well as all dimensions in the scan.

Parameters

uinfo (sbmlsim.units.UnitsInformation) –

to_simulations(self)

Flatten the scan to individual simulations.

Here the changes are appended. Scan should be normalized before calling this function. Necessary to track the results.