Skip to content

fit.petab_v2.extension

The sbmlsim extension of a PEtab v2 problem.

PEtab v2 problems carry extensions, i.e., a block in the YAML of the problem which a tool reads if it knows it and ignores if it does not. The sbmlsim extension holds what the tables of PEtab do not express, see sbmlsim.fit.petab_v2.gaps: the units, the settings of the fit, what a fit does with a mapping and the structure of the timecourses.

The extension is required, because the settings it carries are the objective of the fit: a tool which does not know it has to reject the problem rather than fit the same data with another objective without saying so. A round trip through sbmlsim keeps the fit it started from, and to_petab(..., required_extension=False) writes a problem which other tools read and fit with the objective PEtab defines.

SbmlsimExtension

Bases: ExtensionConfig

What PEtab v2 does not express about an sbmlsim fit.

PEtab says that an extension which changes the mathematical interpretation of a problem must be required, and that a tool must reject a problem which requires an extension it does not know but may ignore one which is not required (PEtab v2, extensions). The settings this extension carries, i.e. the residual, the loss function and the weighting, are the objective sbmlsim optimizes, so a problem which is read without them is fitted with a different objective on the same data. It is therefore required, and a tool which does not know sbmlsim has to say so instead of fitting the problem differently without telling anyone.

to_petab(..., required_extension=False) writes it as not required, which is what a problem meant for other tools wants: they read the tables and optimize the objective PEtab defines.

Attributes:

Name Type Description
version str

version of the extension.

required bool

whether a tool needs the extension to interpret the problem, True because the settings it carries are the objective of the fit.

opid str | None

id of the optimization problem.

settings dict[str, Any]

the FitSettings of the fit as a dictionary.

parameters dict[str, dict[str, Any]]

unit, start value and, when set, the scale of every fit parameter which is no element of a network.

observables dict[str, dict[str, Any]]

the fit mapping behind every observable, keyed by the fit mapping (an observable measured in several experiments is one observable of several fit mappings): the observable, its kind, the weight of the curve, the units of the data, the experiment and the task it belongs to and the metadata of the curve.

experiments dict[str, dict[str, Any]]

the structure of the TimecourseSim behind every PEtab experiment, i.e. the timecourses with their steps and what is discarded, and the fit mapping collection it belongs to.

collections dict[str, dict[str, Any]]

the FitMappingCollection objects of the fit, i.e. the id of the collection, the simulation experiment class its mappings come from and what the fit does with them.

models dict[str, dict[str, Any]]

the settings of the integrator per model.

inputs dict[str, str]

the formula of an input of a network for the simulations without a formula of their own, in the math of PEtab, by the id of the input. The conditions of these experiments repeat it, see sbmlsim.fit.petab_v2.sciml_export.

gaps list[dict[str, Any]]

what this export lost, see sbmlsim.fit.petab_v2.gaps.

extension_of

extension_of(config)

Get the sbmlsim extension of a PEtab problem configuration.

Parameters:

Name Type Description Default
config Any

ProblemConfig of a PEtab v2 problem, None if the problem was not read from a YAML file.

required

Returns:

Type Description
SbmlsimExtension | None

The extension, or None if the problem does not carry one.

sciml_installed

sciml_installed()

Check whether the extra sciml is installed, i.e. petab_sciml.

known_extensions

known_extensions()

Get the extensions the reader interprets in this environment.

Returns:

Type Description
frozenset[str]

KNOWN_EXTENSIONS, and the extension of PEtab SciML when the extra

frozenset[str]

sciml is installed.

check_extensions

check_extensions(extensions, known=None)

Check the extensions of a problem against the ones the reader knows.

PEtab says that a tool must reject a problem which requires an extension it does not know and may ignore an extension which is not required (PEtab v2, extensions). A block without required is read as required, which is the safe reading of a block that does not say.

Parameters:

Name Type Description Default
extensions Mapping[str, Any] | None

the blocks of the problem by the id of the extension, as the dictionaries of the YAML or as the ExtensionConfig objects of a problem which was read, None for a problem without extensions.

required
known Collection[str] | None

ids of the extensions the reader interprets, known_extensions by default.

None

Returns:

Type Description
list[str]

The ids of the extensions which are to be ignored, i.e. the ones

list[str]

which are not known and not required, in the order of the problem.

list[str]

The reader logs them.

Raises:

Type Description
ImportError

if the problem requires the extension of PEtab SciML and the extra sciml is not installed. The message names the extra.

ValueError

if the problem requires an extension which is not known.