PEtab

pyPESTO support for the PEtab data format.

class pypesto.petab.PetabImporter(petab_problem: petab.Problem, output_folder: str = None, model_name: str = None)

Bases: pypesto.objective.amici_objective.AmiciObjectBuilder

MODEL_BASE_DIR = 'amici_models'
__abstractmethods__ = frozenset()
__class__

alias of abc.ABCMeta

__delattr__

Implement delattr(self, name).

__dict__ = mappingproxy({'__module__': 'pypesto.petab.importer', 'MODEL_BASE_DIR': 'amici_models', '__init__': <function PetabImporter.__init__>, 'from_yaml': <staticmethod object>, 'create_model': <function PetabImporter.create_model>, '_create_model': <function PetabImporter._create_model>, '_must_compile': <function PetabImporter._must_compile>, 'compile_model': <function PetabImporter.compile_model>, 'create_solver': <function PetabImporter.create_solver>, 'create_edatas': <function PetabImporter.create_edatas>, 'create_objective': <function PetabImporter.create_objective>, 'create_problem': <function PetabImporter.create_problem>, 'rdatas_to_measurement_df': <function PetabImporter.rdatas_to_measurement_df>, 'rdatas_to_simulation_df': <function PetabImporter.rdatas_to_simulation_df>, '__doc__': None, '__abstractmethods__': frozenset(), '_abc_registry': <_weakrefset.WeakSet object>, '_abc_cache': <_weakrefset.WeakSet object>, '_abc_negative_cache': <_weakrefset.WeakSet object>, '_abc_negative_cache_version': 48})
__dir__() → list

default dir() implementation

__eq__

Return self==value.

__format__()

default object formatter

__ge__

Return self>=value.

__getattribute__

Return getattr(self, name).

__gt__

Return self>value.

__hash__

Return hash(self).

__init__(petab_problem: petab.Problem, output_folder: str = None, model_name: str = None)
petab_problem:
Managing access to the model and data.
output_folder:
Folder to contain the amici model. Defaults to ‘./amici_models/{model_name}’.
model_name:
Name of the model, which will in particular be the name of the compiled model python module.
__init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__le__

Return self<=value.

__lt__

Return self<value.

__module__ = 'pypesto.petab.importer'
__ne__

Return self!=value.

__new__()

Create and return a new object. See help(type) for accurate signature.

__reduce__()

helper for pickle

__reduce_ex__()

helper for pickle

__repr__

Return repr(self).

__setattr__

Implement setattr(self, name, value).

__sizeof__() → int

size of object in memory, in bytes

__str__

Return str(self).

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

__weakref__

list of weak references to the object (if defined)

compile_model(**kwargs)

Compile the model. If the output folder exists already, it is first deleted.

Parameters:kwargs (Extra arguments passed to amici.SbmlImporter.sbml2amici.) –
create_edatas(model: amici.Model = None, simulation_conditions=None) → List[amici.ExpData]

Create list of amici.ExpData objects.

create_model(force_compile: bool = False, **kwargs) → amici.Model

Import amici model. If necessary or force_compile is True, compile first.

Parameters:
  • force_compile

    If False, the model is compiled only if the output folder does not exist yet. If True, the output folder is deleted and the model (re-)compiled in either case.

    Warning

    If force_compile, then an existing folder of that name will be deleted.

  • kwargs (Extra arguments passed to amici.SbmlImporter.sbml2amici) –
create_objective(model: amici.Model = None, solver: amici.Solver = None, edatas: Sequence[amici.ExpData] = None, force_compile: bool = False, **kwargs) → pypesto.objective.amici_objective.AmiciObjective

Create a pypesto.AmiciObjective.

Parameters:
  • model – The AMICI model.
  • solver – The AMICI solver.
  • edatas – The experimental data in AMICI format.
  • force_compile – Whether to force-compile the model if not passed.
  • **kwargs – Additional arguments passed on to the objective.
Returns:

A pypesto.AmiciObjective for the model and the data.

Return type:

objective

create_problem(objective: pypesto.objective.amici_objective.AmiciObjective = None, **kwargs) → pypesto.problem.Problem

Create a pypesto.Problem.

Parameters:
  • objective – Objective as created by create_objective.
  • **kwargs – Additional key word arguments passed on to the objective, if not provided.
Returns:

A pypesto.Problem for the objective.

Return type:

problem

create_solver(model: amici.Model = None) → amici.Solver

Return model solver.

static from_yaml(yaml_config: Union[dict, str], output_folder: str = None, model_name: str = None) → pypesto.petab.importer.PetabImporter

Simplified constructor using a petab yaml file.

rdatas_to_measurement_df(rdatas: Sequence[amici.ReturnData], model: amici.Model = None) → pandas.core.frame.DataFrame

Create a measurement dataframe in the petab format from the passed rdatas and own information.

Parameters:
  • rdatas – A list of rdatas as produced by pypesto.AmiciObjective.__call__(x, return_dict=True)[‘rdatas’].
  • model – The amici model.
Returns:

A dataframe built from the rdatas in the format as in self.petab_problem.measurement_df.

Return type:

measurement_df

rdatas_to_simulation_df(rdatas: Sequence[amici.ReturnData], model: amici.Model = None) → pandas.core.frame.DataFrame

Same as rdatas_to_measurement_df, execpt a petab simulation dataframe is created, i.e. the measurement column label is adjusted.