sbmlsim.simulation

Package for simulation.

Submodules

Package Contents

Classes

AbstractSim

AbstractSim.

Dimension

Define dimension for a 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()

Get dimension of the simulation.

Return type

List[sbmlsim.simulation.range.Dimension]

abstract normalize(uinfo)

Normalize simulation.

Parameters

uinfo (sbmlsim.units.UnitsInformation) –

Return type

None

abstract add_model_changes(changes)

Add model changes to model.

Parameters

changes (Dict) –

Return type

None

to_dict()

Convert to dictionary.

Return type

Dict[str, str]

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

Define dimension for a 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__()

Get representation.

Return type

str

__len__()

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[List[Timecourse], Timecourse]) –

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

  • reset (bool) –

  • time_offset (float) –

__repr__()

Get representation.

Return type

str

_time()

Calculate the time vector complete simulation.

Return type

numpy.ndarray

dimensions()

Get dimensions.

Return type

List[sbmlsim.simulation.Dimension]

add_model_changes(model_changes)

Add model changes to given simulation.

Parameters

model_changes (Dict) –

Return type

None

normalize(uinfo)

Normalize timecourse simulation.

Parameters

uinfo (sbmlsim.units.UnitsInformation) –

Return type

None

strip_units()

Strip units from simulation.

Return type

None

to_dict()

Convert to dictionary.

Return type

Dict[str, Any]

to_json(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__()

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__()

Get string representation.

Return type

str

to_dict()

Convert to dictionary.

Return type

Dict[str, Any]

add_change(sid, value)

Add change.

Parameters
  • sid (str) –

  • value (float) –

Return type

None

remove_change(sid)

Remove change for given id.

Parameters

sid (str) –

Return type

None

add_model_change(sid, change)

Add model change.

Parameters

sid (str) –

Return type

None

add_model_changes(model_changes)

Add model changes.

Parameters

model_changes (Dict[str, str]) –

Return type

None

remove_model_change(sid)

Remove model change for id.

Parameters

sid (str) –

Return type

None

normalize(uinfo)

Normalize values to model units for all changes.

Parameters

uinfo (sbmlsim.units.UnitsInformation) –

Return type

None

strip_units()

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__()

Get representation.

Return type

str

dimensions()

Get dimensions.

Return type

List[sbmlsim.simulation.Dimension]

get_dimension(key)

Get dimension by key.

Parameters

key (str) –

Return type

sbmlsim.simulation.Dimension

indices()

Get indices of all combinations.

add_model_changes(model_changes)

Add model changes to first timecourse.

Parameters

model_changes (Dict) –

Return type

None

normalize(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()

Flatten the scan to individual simulations.

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