sbmlsim.experiment
¶
Package for simulation experiments.
Submodules¶
Package Contents¶
Classes¶
Generic simulation experiment. |
|
Result of a simulation experiment. |
|
Class for running simulation experiments. |
|
Report for an experiment. |
- class sbmlsim.experiment.SimulationExperiment(sid=None, base_path=None, data_path=None, ureg=None, **kwargs)[source]¶
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.experiment.ExperimentResult[source]¶
Result of a simulation experiment.
- experiment: SimulationExperiment¶
- output_path: pathlib.Path¶
- to_dict()¶
Conversion to dictionary.
Used in serialization and required for reports.
- Return type:
Dict
- class sbmlsim.experiment.ExperimentRunner(experiment_classes, base_path, data_path, simulator=None, ureg=None, **kwargs)[source]¶
Bases:
object
Class for running simulation experiments.
- Parameters:
experiment_classes (Union[Type[sbmlsim.experiment.SimulationExperiment], List[Type[sbmlsim.experiment.SimulationExperiment]]]) –
base_path (pathlib.Path) –
data_path (pathlib.Path) –
simulator (Union[sbmlsim.simulator.SimulatorSerialRR, sbmlsim.simulator.rr_simulator_ray.SimulatorRayRR]) –
ureg (sbmlsim.units.UnitRegistry) –
- set_simulator(simulator)¶
Set simulator on the runner and experiments.
- Parameters:
simulator (sbmlsim.simulator.SimulatorSerialRR) –
- Return type:
None
- initialize(experiment_classes, **kwargs)¶
Initialize ExperimentRunner.
Initialization is required in addition to construction to allow serialization of information for parallelization.
- Parameters:
experiment_classes (Union[List[Type[sbmlsim.experiment.SimulationExperiment]], Tuple[Type[sbmlsim.experiment.SimulationExperiment]], Set[Type[sbmlsim.experiment.SimulationExperiment]]]) –
- run_experiments(output_path, show_figures=False, save_results=False, figure_formats=None, reduced_selections=True)¶
Run the experiments.
- Parameters:
output_path (pathlib.Path) –
show_figures (bool) –
save_results (bool) –
figure_formats (List[str]) –
reduced_selections (bool) –
- Return type:
- class sbmlsim.experiment.ExperimentReport(results, metadata=None, template_path=TEMPLATE_PATH)[source]¶
Report for an experiment.
- Parameters:
results (ReportResults) –
metadata (Dict) –
- create_report(output_path, filename=None, report_type=ReportType.HTML, f_filter_context=None, **kwargs)¶
Create report of SimulationExperiments.
Processes ExperimentResults to generate overall report.
All relative paths only can be resolved in the report if the paths are below the report or at the same level in the file hierarchy.
- Parameters:
output_path (pathlib.Path) –
filename (Optional[str]) –
report_type (ReportType) –
f_filter_context (Optional[Dict]) –
- Return type:
pathlib.Path