sbmlsim.examples.experiments.midazolam.experiments
¶
Submodules¶
Package Contents¶
Classes¶
Generic simulation experiment. |
|
Abstract base class to store a model in sbmlsim. |
|
Timecourse simulation consisting of multiple concatenated timecourses. |
|
Helpers for calculating model sensitivity. |
|
Tasks combine models with simulations. |
|
Base class for all GlucoseSimulationExperiments. |
Functions¶
Filter for excluding parameter ids in sensitivity. |
Attributes¶
- class sbmlsim.examples.experiments.midazolam.experiments.SimulationExperiment(sid=None, base_path=None, data_path=None, ureg=None, **kwargs)¶
Generic simulation experiment.
Consists of models, datasets, simulations, tasks, results, processing, figures
- Parameters:
sid (str) –
base_path (pathlib.Path) –
data_path (pathlib.Path) –
ureg (sbmlsim.units.UnitRegistry) –
- property results: Dict[str, sbmlsim.xresult.XResult]¶
Access simulation results.
Results are mapped on tasks based on the task_ids. E.g. to get the results for the task with id ‘task_glciv’ use ```
simexp.results[“task_glciv”] self.results[“task_glciv”]
- Return type:
Dict[str, sbmlsim.xresult.XResult]
- initialize()¶
Initialize SimulationExperiment.
Initialization must be separated from object construction due to the parallel execution of the problem later on. Certain objects cannot be serialized and must be initialized. :return:
- Return type:
None
- __str__()¶
Get string representation.
- Return type:
str
- models()¶
Define model definitions.
The child classes fill out the information.
- Return type:
Dict[str, Union[sbmlsim.model.AbstractModel, pathlib.Path]]
- datasets()¶
Define dataset definitions (experimental data).
The child classes fill out the information.
- Return type:
Dict[str, sbmlsim.data.DataSet]
- simulations()¶
Define simulation definitions.
The child classes fill out the information.
- Return type:
Dict[str, sbmlsim.simulation.AbstractSim]
- tasks()¶
Define task definitions.
The child classes fill out the information.
- Return type:
Dict[str, sbmlsim.task.Task]
- data()¶
Define DataGenerators including functions.
This determines the selection in the model.
All data which is accessed in a simulation result must be defined in a data generator. The data generators are important for defining the selections of a simulation experiment.
- Return type:
Dict[str, sbmlsim.data.Data]
- figures()¶
Figure definition.
Selections accessed in figures and analyses must be registered beforehand via datagenerators.
Most figures do not require access to concrete data, but only abstract data concepts.
- Return type:
Dict[str, sbmlsim.plot.Figure]
- figures_mpl()¶
Matplotlib figure definition.
Selections accessed in figures and analyses must be registered beforehand via datagenerators.
Most figures do not require access to concrete data, but only abstract data concepts.
- Return type:
Dict[str, sbmlsim.plot.serialization_matplotlib.FigureMPL]
- fit_mappings()¶
Define fit mappings.
Mapping reference data on observables. Used for the optimization of parameters. The child classes fill out the information.
- Return type:
Dict[str, sbmlsim.fit.FitMapping]
- reports()¶
Define reports.
Reports are defined by a hashmap label:Data. Reports can be serialized in multiple manners.
- Return type:
Dict[str, Dict[str, str]]
- add_data(d)¶
Add data to the tracked data.
- Parameters:
d (sbmlsim.data.Data) –
- Return type:
None
- add_selections_data(selections, task_ids=None)¶
Add selections to given tasks.
The data for the selections will be part of the results.
Selections are necessary to access data from simulations. Here these selections are added to the tasks. If no tasks are given, the selections are added to all tasks.
- Parameters:
reset – drop and reset all selections.
selections (Iterable[str]) –
task_ids (Iterable[str]) –
- Return type:
None
- _check_keys()¶
Check keys in information dictionaries.
- _check_types()¶
Check for correctness of types.
- run(simulator, output_path=None, show_figures=True, save_results=False, figure_formats=None, reduced_selections=True)¶
Execute given experiment and store results.
- Parameters:
output_path (pathlib.Path) –
show_figures (bool) –
save_results (bool) –
figure_formats (List[str]) –
reduced_selections (bool) –
- Return type:
- _run_tasks(simulator, reduced_selections=True)¶
Run simulations and scans.
This should not be called directly, but the results of the simulations should be requested by the results property. This allows to hash executed simulations.
- Parameters:
reduced_selections (bool) –
- evaluate_fit_mappings()¶
Evaluate fit mappings.
- to_json(path=None, indent=2)¶
Convert experiment to JSON for exchange.
- Parameters:
path (pathlib.Path) – path for file, if None JSON str is returned
indent (int) –
- Returns:
- to_dict()¶
Convert to dictionary.
This is the basis for the JSON serialization.
- classmethod from_json(json_info)¶
Load experiment from json path or str.
- Parameters:
json_info (Union[pathlib.Path, str]) –
- Return type:
- save_datasets(results_path)¶
Save datasets.
- Parameters:
results_path (pathlib.Path) –
- Return type:
None
- save_results(results_path)¶
Save results (mean timecourse).
- Parameters:
results_path (pathlib.Path) –
- Returns:
- Return type:
None
- create_mpl_figures()¶
Create matplotlib figures.
- Return type:
Dict[str, Union[sbmlsim.plot.serialization_matplotlib.FigureMPL, sbmlsim.plot.Figure]]
- show_mpl_figures(mpl_figures)¶
Show matplotlib figures.
- Parameters:
mpl_figures (Dict[str, sbmlsim.plot.serialization_matplotlib.FigureMPL]) –
- Return type:
None
- save_mpl_figures(results_path, mpl_figures, figure_formats=None)¶
Save matplotlib figures.
- Parameters:
results_path (pathlib.Path) –
mpl_figures (Dict[str, sbmlsim.plot.serialization_matplotlib.FigureMPL]) –
figure_formats (List[str]) –
- Return type:
Dict[str, List[pathlib.Path]]
- classmethod close_mpl_figures(mpl_figures)¶
Close matplotlib figures.
- Parameters:
mpl_figures (Dict[str, sbmlsim.plot.serialization_matplotlib.FigureMPL]) –
- class sbmlsim.examples.experiments.midazolam.experiments.AbstractModel(source, sid=None, name=None, language=None, language_type=LanguageType.SBML, base_path=None, changes=None, selections=None)¶
Bases:
object
Abstract base class to store a model in sbmlsim.
Depending on the model language different subclasses are implemented.
- Parameters:
source (Union[str, pathlib.Path]) –
sid (Optional[str]) –
name (Optional[str]) –
language (Optional[str]) –
language_type (LanguageType) –
base_path (Optional[pathlib.Path]) –
changes (Dict) –
selections (List[str]) –
- __repr__()¶
Get string representation.
- Return type:
str
- normalize(uinfo)¶
Normalize values to model units for all changes.
- Parameters:
uinfo (sbmlsim.units.UnitsInformation) –
- to_dict()¶
Convert to dictionary.
- class sbmlsim.examples.experiments.midazolam.experiments.TimecourseSim(timecourses, selections=None, reset=True, time_offset=0.0)¶
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:
- 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:
- __str__()¶
Get string representation.
- Return type:
str
- class sbmlsim.examples.experiments.midazolam.experiments.ModelSensitivity[source]¶
Bases:
object
Helpers for calculating model sensitivity.
- static difference_sensitivity_scan(model, simulation, difference=0.1, stype=SensitivityType.PARAMETER_SENSITIVITY, exclude_filter=None, exclude_zero=True, zero_eps=1e-08)¶
Create a parameter sensitivity scan for given TimecourseSimulation.
- Parameters:
model (sbmlsim.model.rr_model.roadrunner.RoadRunner) – model for execution (needed to select parameters)
simulation (sbmlsim.simulation.TimecourseSim) – timecourse simulation to scan
difference (float) – change in parameters, i.e. every parameter (which is not excluded) is changed to ‘(1.0 - difference) * value’ and ‘(1.0 + difference) * value’
stype (SensitivityType) – which sensitivity (parameters or species)
exclude_filter – filter function which defines which parameters should be excluded from scan
exclude_zero (bool) – parameters with a value of abs(value)<zero_eps are excluded from scan
zero_eps (float) – epsilon for zero values
- Returns:
- Return type:
- static distribution_sensitivity_scan(model, simulation, cv=0.1, size=10, distribution=DistributionType.NORMAL_DISTRIBUTION, stype=SensitivityType.PARAMETER_SENSITIVITY, exclude_filter=None, exclude_zero=True, zero_eps=1e-08)¶
Get sensitivity scan based on distributions for values.
- Parameters:
model (sbmlsim.model.rr_model.roadrunner.RoadRunner) –
simulation (sbmlsim.simulation.TimecourseSim) –
cv (float) –
size (int) –
distribution (DistributionType) –
stype (SensitivityType) –
exclude_zero (bool) –
zero_eps (float) –
- Return type:
- static create_sampling_dimension(model, changes=None, cv=0.1, size=10, distribution=DistributionType.NORMAL_DISTRIBUTION, stype=SensitivityType.PARAMETER_SENSITIVITY, exclude_filter=None, exclude_zero=True, zero_eps=1e-08)¶
Create list of dimensions for sampling parameter values.
Only parameters relevant for “GU_”, “LI_” and “KI_” models are sampled.
cv: coeffient of variation (sigma/mean) -> sigma = cv*mean
- Parameters:
model (sbmlsim.model.rr_model.roadrunner.RoadRunner) –
changes (Dict) –
cv (float) –
size (int) –
distribution (DistributionType) –
stype (SensitivityType) –
exclude_zero (bool) –
zero_eps (float) –
- Return type:
- static create_difference_dimension(model, changes=None, difference=0.1, stype=SensitivityType.PARAMETER_SENSITIVITY, exclude_filter=None, exclude_zero=True, zero_eps=1e-08)¶
Create list of dimensions for sampling parameter values.
Only parameters relevant for “GU_”, “LI_” and “KI_” models are sampled.
cv: coeffient of variation (sigma/mean) -> sigma = cv*mean
- Parameters:
model (sbmlsim.model.rr_model.roadrunner.RoadRunner) –
changes (Dict) –
difference (float) –
stype (SensitivityType) –
exclude_zero (bool) –
zero_eps (float) –
- Return type:
- static reference_dict(model, changes=None, stype=SensitivityType.PARAMETER_SENSITIVITY, exclude_filter=None, exclude_zero=True, zero_eps=1e-08)¶
Get key:value dict for sensitivity analysis.
Values are based on the reference state of the model with the applied changes. Values in current model state are used.
- Parameters:
model (sbmlsim.model.rr_model.roadrunner.RoadRunner) –
exclude_filter – filter function to exclude parameters, excludes parameter id if the filter function is True
exclude_zero (bool) – exclude parameters which are zero
changes (Dict) –
stype (SensitivityType) –
zero_eps (float) –
- Returns:
- Return type:
Dict
- static apply_change_to_dict(ref_dict, change=0.1)¶
Apply relative change to reference dictionary.
- Parameters:
ref_dict – {key: value} dictionary to change
change (float) – relative change to apply.
- Returns:
- class sbmlsim.examples.experiments.midazolam.experiments.Task(model, simulation, sid=None, name=None)¶
Tasks combine models with simulations.
This allows to execute the same simulation with different model variants.
- Parameters:
model (str) –
simulation (str) –
sid (str) –
name (str) –
- __repr__()¶
Get representation.
- Return type:
str
- to_dict()¶
Convert to dictionary.
- Return type:
Dict[str, str]
- class sbmlsim.examples.experiments.midazolam.experiments.MidazolamSimulationExperiment(sid=None, base_path=None, data_path=None, ureg=None, **kwargs)[source]¶
Bases:
sbmlsim.experiment.SimulationExperiment
Base class for all GlucoseSimulationExperiments.
- Parameters:
sid (str) –
base_path (pathlib.Path) –
data_path (pathlib.Path) –
ureg (sbmlsim.units.UnitRegistry) –
- models()[source]¶
Define model definitions.
The child classes fill out the information.
- Return type:
Dict[str, sbmlsim.model.AbstractModel]
- tasks()[source]¶
Define task definitions.
The child classes fill out the information.
- Return type:
Dict[str, sbmlsim.task.Task]
- simulations(simulations=None)[source]¶
Define simulation definitions.
The child classes fill out the information.
- Return type:
Dict[str, sbmlsim.simulation.TimecourseSim]