amici.petab_import

PEtab Import

Import a model in the petab (https://github.com/PEtab-dev/PEtab) format into AMICI.

Functions Summary

constant_species_to_parameters(sbml_model)

Convert constant species in the SBML model to constant parameters.

get_fixed_parameters(sbml_model[, …])

Determine, set and return fixed model parameters.

get_observation_model(observable_df)

Get observables, sigmas, and noise distributions from PEtab observation table in a format suitable for amici.sbml_import.SbmlImporter.sbml2amici().

import_model(sbml_model[, condition_table, …])

Create AMICI model from PEtab problem

import_model_sbml(sbml_model[, …])

Create AMICI model from PEtab problem

import_petab_problem(petab_problem[, …])

Import model from petab problem.

main()

Command line interface to import a model in the PEtab (https://github.com/PEtab-dev/PEtab/) format into AMICI.

parse_cli_args()

Parse command line arguments

petab_noise_distributions_to_amici(observable_df)

Map from the petab to the amici format of noise distribution identifiers.

petab_scale_to_amici_scale(scale_str)

Convert PEtab parameter scaling string to AMICI scaling integer

show_model_info(sbml_model)

Log some model quantities

species_to_parameters(species_ids, sbml_model)

Turn a SBML species into parameters and replace species references inside the model instance.

Functions

amici.petab_import.constant_species_to_parameters(sbml_model)[source]

Convert constant species in the SBML model to constant parameters.

This can be used e.g. for setting up models with condition-specific constant species for PEtab, since there it is not possible to specify constant species in the condition table.

Parameters

sbml_model (libsbml.Model) – SBML Model

Return type

typing.List[str]

Returns

List of IDs of SBML species that have been turned into constants

amici.petab_import.get_fixed_parameters(sbml_model, condition_df=None, const_species_to_parameters=False)[source]

Determine, set and return fixed model parameters.

Parameters specified in condition_df are turned into constants. Only global SBML parameters are considered. Local parameters are ignored.

Parameters
  • condition_df (typing.Optional[pandas.core.frame.DataFrame]) – PEtab condition table. If provided, the respective parameters will be turned into AMICI constant parameters.

  • sbml_model (libsbml.Model) – libsbml.Model instance

  • const_species_to_parameters (bool) – If True, species which are marked constant within the SBML model will be turned into constant parameters within the given sbml_model.

Return type

typing.List[str]

Returns

List of IDs of parameters which are to be considered constant.

amici.petab_import.get_observation_model(observable_df)[source]

Get observables, sigmas, and noise distributions from PEtab observation table in a format suitable for amici.sbml_import.SbmlImporter.sbml2amici().

Parameters

observable_df (pandas.core.frame.DataFrame) – PEtab observables table

Return type

typing.Tuple[typing.Dict[str, typing.Dict[str, str]], typing.Dict[str, str], typing.Dict[str, typing.Union[str, float]]]

Returns

Tuple of dicts with observables, noise distributions, and sigmas.

amici.petab_import.import_model(sbml_model, condition_table=None, observable_table=None, measurement_table=None, model_name=None, model_output_dir=None, verbose=True, allow_reinit_fixpar_initcond=True, **kwargs)

Create AMICI model from PEtab problem

Parameters
  • sbml_model (typing.Union[str, libsbml.Model]) – PEtab SBML model or SBML file name.

  • condition_table (typing.Union[str, pandas.core.frame.DataFrame, None]) – PEtab condition table. If provided, parameters from there will be turned into AMICI constant parameters (i.e. parameters w.r.t. which no sensitivities will be computed).

  • observable_table (typing.Union[str, pandas.core.frame.DataFrame, None]) – PEtab observable table.

  • measurement_table (typing.Union[str, pandas.core.frame.DataFrame, None]) – PEtab measurement table.

  • model_name (typing.Optional[str]) – Name of the generated model. If model file name was provided, this defaults to the file name without extension, otherwise the SBML model ID will be used.

  • model_output_dir (typing.Optional[str]) – Directory to write the model code to. Will be created if doesn’t exist. Defaults to current directory.

  • verbose (typing.Union[bool, int, None]) – Print/log extra information.

  • allow_reinit_fixpar_initcond (bool) – See amici.ode_export.ODEExporter. Must be enabled if initial states are to be reset after preequilibration.

  • kwargs – Additional keyword arguments to be passed to amici.sbml_import.SbmlImporter.sbml2amici().

Return type

None

amici.petab_import.import_model_sbml(sbml_model, condition_table=None, observable_table=None, measurement_table=None, model_name=None, model_output_dir=None, verbose=True, allow_reinit_fixpar_initcond=True, **kwargs)[source]

Create AMICI model from PEtab problem

Parameters
  • sbml_model (typing.Union[str, libsbml.Model]) – PEtab SBML model or SBML file name.

  • condition_table (typing.Union[str, pandas.core.frame.DataFrame, None]) – PEtab condition table. If provided, parameters from there will be turned into AMICI constant parameters (i.e. parameters w.r.t. which no sensitivities will be computed).

  • observable_table (typing.Union[str, pandas.core.frame.DataFrame, None]) – PEtab observable table.

  • measurement_table (typing.Union[str, pandas.core.frame.DataFrame, None]) – PEtab measurement table.

  • model_name (typing.Optional[str]) – Name of the generated model. If model file name was provided, this defaults to the file name without extension, otherwise the SBML model ID will be used.

  • model_output_dir (typing.Optional[str]) – Directory to write the model code to. Will be created if doesn’t exist. Defaults to current directory.

  • verbose (typing.Union[bool, int, None]) – Print/log extra information.

  • allow_reinit_fixpar_initcond (bool) – See amici.ode_export.ODEExporter. Must be enabled if initial states are to be reset after preequilibration.

  • kwargs – Additional keyword arguments to be passed to amici.sbml_import.SbmlImporter.sbml2amici().

Return type

None

amici.petab_import.import_petab_problem(petab_problem, model_output_dir=None, model_name=None, force_compile=False, **kwargs)[source]

Import model from petab problem.

Parameters
  • petab_problem (petab.problem.Problem) – A petab problem containing all relevant information on the model.

  • model_output_dir (typing.Optional[str]) – Directory to write the model code to. Will be created if doesn’t exist. Defaults to current directory.

  • model_name (typing.Optional[str]) – Name of the generated model. If model file name was provided, this defaults to the file name without extension, otherwise the SBML model ID will be used.

  • force_compile (bool) – Whether to compile the model even if the target folder is not empty, or the model exists already.

  • kwargs – Additional keyword arguments to be passed to amici.sbml_import.SbmlImporter.sbml2amici().

Return type

amici.amici.Model

Returns

The imported model.

amici.petab_import.main()[source]

Command line interface to import a model in the PEtab (https://github.com/PEtab-dev/PEtab/) format into AMICI.

amici.petab_import.parse_cli_args()[source]

Parse command line arguments

Returns

Parsed CLI arguments from argparse.

amici.petab_import.petab_noise_distributions_to_amici(observable_df)[source]

Map from the petab to the amici format of noise distribution identifiers.

Parameters

observable_df (pandas.core.frame.DataFrame) – PEtab observable table

Return type

typing.Dict

Returns

Dictionary of observable_id => AMICI noise-distributions

amici.petab_import.petab_scale_to_amici_scale(scale_str)[source]

Convert PEtab parameter scaling string to AMICI scaling integer

Return type

int

amici.petab_import.show_model_info(sbml_model)[source]

Log some model quantities

amici.petab_import.species_to_parameters(species_ids, sbml_model)[source]

Turn a SBML species into parameters and replace species references inside the model instance.

Parameters
  • species_ids (typing.List[str]) – List of SBML species ID to convert to parameters with the same ID as the replaced species.

  • sbml_model (libsbml.Model) – SBML model to modify

Return type

typing.List[str]

Returns

List of IDs of species which have been converted to parameters