fit.petab_v2.export¶
Write an sbmlsim optimization problem as a PEtab v2 problem.
The export walks an initialized OptimizationProblem, i.e., a problem whose
fit mappings are resolved, and builds the tables of PEtab v2 from it:
- every model of the fit is a model of the problem, written as the model the
problem was defined with when the fit simulates a derived one (compiled
networks, formula observables, see
sbmlsim.model.provenance), - the fit mappings which share a model and a simulation are one experiment, its
periods are the timecourses of the
TimecourseSimand their changes are the conditions, - every fit mapping is one observable, named after the mapping; mappings which observe one thing in several experiments are one observable, its reference data are the measurements of that observable,
- every fit parameter is a parameter which is estimated.
What the tables do not hold goes into the sbmlsim extension of the problem,
see sbmlsim.fit.petab_v2.extension, and what is lost is reported by
sbmlsim.fit.petab_v2.gaps.
PetabExporter
¶
Write an optimization problem as a PEtab v2 problem.
A problem with hybridizations is written with its networks as PEtab
SciML, see sbmlsim.fit.petab_v2.sciml_export, which needs the extra
sciml.
Initialize the export of a problem.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
OptimizationProblem
|
problem to export, it is initialized if it is not. |
required |
settings
|
FitSettings | None
|
settings of the fit, required if the problem is not initialized. |
None
|
kinds
|
set[MappingKind] | None
|
kinds of fit mappings to write, everything the problem resolved by default, i.e. the training data, the validation data and the outliers, so that a round trip keeps the fit. The data the model does not describe is not part of the problem. Which of them a fit uses is in the extension: a tool which reads the problem without it would fit everything it finds. |
None
|
required_extension
|
bool
|
mark the |
True
|
parameter_set
|
ParameterSet | None
|
values of the parameters of the fit to write, e.g.
the result of a fit, which must have every parameter of the
problem. They are the nominal values of the parameter table,
the start values of the |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
if the problem is not initialized and no settings are given, or if the parameter set has a value for an element of a network which is no parameter of the fit. |
KeyError
|
if the parameter set lacks a parameter of the problem. |
check
¶
Check that the problem can be written.
Raises:
| Type | Description |
|---|---|
ValueError
|
for a gap which has no representation in PEtab v2, i.e.
a structural model change, an observable which is a python
function or a mapping over something else than time; or for a
selector without its own id, see |
to_problem
¶
Build the PEtab v2 problem.
Returns:
| Type | Description |
|---|---|
Problem
|
The problem with its models, conditions, experiments, observables, |
Problem
|
measurements and parameters, and the |
Raises:
| Type | Description |
|---|---|
ValueError
|
if the problem uses features PEtab v2 cannot express. |
petab_id
¶
Get a PEtab identifier from the parts of an sbmlsim key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parts
|
str
|
parts of the identifier, joined with |
()
|
Returns:
| Type | Description |
|---|---|
str
|
An identifier of letters, digits and underscores which does not start |
str
|
with a digit. |
period_condition_id
¶
Get the id of the condition of a period of an experiment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
experiment_id
|
str
|
id of the experiment. |
required |
k
|
int
|
index of the period, i.e. of the timecourse of the simulation. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The id, e.g. |
str
|
networks are keyed by for the first period. |
to_petab
¶
to_petab(
problem,
output_dir,
settings=None,
kinds=None,
required_extension=True,
parameter_set=None,
)
Write an optimization problem as a PEtab v2 problem.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
OptimizationProblem
|
problem to write, it is initialized if it is not. |
required |
output_dir
|
Path
|
directory the problem is written to, created if it does not exist. |
required |
settings
|
FitSettings | None
|
settings of the fit, required if the problem is not initialized. |
None
|
kinds
|
set[MappingKind] | None
|
kinds of fit mappings to write, everything the problem resolved by default, i.e. the training data, the validation data and the outliers. |
None
|
required_extension
|
bool
|
mark the |
True
|
parameter_set
|
ParameterSet | None
|
values of the parameters of the fit to write, e.g. the
result of a fit: the exported problem starts from them, see
|
None
|
Returns:
| Type | Description |
|---|---|
Path
|
Path of the YAML file of the problem. |
Raises:
| Type | Description |
|---|---|
ValueError
|
if the problem uses features PEtab v2 cannot express, or if the parameter set has a value for an element of a network which is no parameter of the fit. |
KeyError
|
if the parameter set lacks a parameter of the problem. |