amici.petab_import_pysb
PySB-PEtab Import
Import a model in the PySB-adapted petab
(https://github.com/PEtab-dev/PEtab) format into AMICI.
Functions
|
Create SBML dummy model for to use PySB models with PEtab. |
|
Create AMICI model from PySB-PEtab problem |
Classes
|
Representation of a PySB-model-based PEtab problem |
- class amici.petab_import_pysb.PysbPetabProblem(pysb_model=None, *args, **kwargs)[source]
Representation of a PySB-model-based PEtab problem
This class extends
petab.Problem
with a PySB model. The model is augmented with the observation model based on the PEtab observable table. For now, a dummy SBML model is created which allows used the existing SBML-PEtab API.- Variables
pysb_model – PySB model instance from of this PEtab problem.
- __init__(pysb_model=None, *args, **kwargs)[source]
Constructor
- Parameters
pysb_model (
typing.Optional
[pysb.core.Model
]) – PySB model instance for this PEtab problemargs – See
petab.Problem.__init__()
kwargs – See
petab.Problem.__init__()
- create_parameter_df(*args, **kwargs)
Create a new PEtab parameter table
- static from_combine(filename)
Read PEtab COMBINE archive (http://co.mbine.org/documents/archive).
See also
petab.create_combine_archive()
.- Parameters
filename (
typing.Union
[pathlib.Path
,str
]) – Path to the PEtab-COMBINE archive- Return type
- Returns
A
petab.Problem
instance.
- static from_files(condition_file=None, measurement_file=None, parameter_file=None, visualization_files=None, observable_files=None, pysb_model_file=None, flatten=False)[source]
Factory method to load model and tables from files.
- Parameters
condition_file (
typing.Union
[str
,pathlib.Path
,typing.Iterable
[typing.Union
[str
,pathlib.Path
]],None
]) – PEtab condition tablemeasurement_file (
typing.Union
[str
,pathlib.Path
,typing.Iterable
[typing.Union
[str
,pathlib.Path
]],None
]) – PEtab measurement tableparameter_file (
typing.Union
[str
,pathlib.Path
,typing.Iterable
[typing.Union
[str
,pathlib.Path
]],None
]) – PEtab parameter tablevisualization_files (
typing.Union
[str
,pathlib.Path
,typing.Iterable
[typing.Union
[str
,pathlib.Path
]],None
]) – PEtab visualization tablesobservable_files (
typing.Union
[str
,pathlib.Path
,typing.Iterable
[typing.Union
[str
,pathlib.Path
]],None
]) – PEtab observables tablespysb_model_file (
typing.Union
[str
,pathlib.Path
,None
]) – PySB model fileflatten (
bool
) – Flatten the petab problem
- Return type
- Returns
Petab Problem
- static from_yaml(yaml_config, flatten=False)[source]
Factory method to load model and tables as specified by YAML file.
NOTE: The PySB model is currently expected in the YAML file under
sbml_files
.- Parameters
yaml_config (
typing.Union
[typing.Dict
,pathlib.Path
,str
]) – PEtab configuration as dictionary or YAML file nameflatten (
bool
) – Flatten the petab problem
- Return type
- Returns
Petab Problem
- get_lb(free=True, fixed=True, scaled=False)
Generic function to get lower parameter bounds.
- Parameters
- Return type
The lower parameter bounds.
- get_model_parameters()
- get_observable_ids()
Returns dictionary of observable ids.
- get_optimization_parameter_scales()
Return list of optimization parameter scaling strings.
- get_optimization_parameters()
Return list of optimization parameter IDs.
- get_optimization_to_simulation_parameter_mapping(**kwargs)
See
petab.parameter_mapping.get_optimization_to_simulation_parameter_mapping()
, to which all keyword arguments are forwarded.
- get_simulation_conditions_from_measurement_df()
See petab.get_simulation_conditions
- get_ub(free=True, fixed=True, scaled=False)
Generic function to get upper parameter bounds.
- Parameters
- Return type
The upper parameter bounds.
- get_x_ids(free=True, fixed=True)
Generic function to get parameter ids.
- get_x_nominal(free=True, fixed=True, scaled=False)
Generic function to get parameter nominal values.
- Parameters
- Return type
The parameter nominal values.
- property lb: List
Parameter table lower bounds.
- Return type
- property lb_scaled: List
Parameter table lower bounds with applied parameter scaling
- Return type
- sample_parameter_startpoints(n_starts=100)
Create starting points for optimization
- scale_parameters(x_dict)
Scale parameter values.
- Parameters
x_dict (
typing.Dict
[str
,float
]) – Keys are parameter IDs in the PEtab problem, values are unscaled parameter values.- Return type
The scaled parameter values.
- to_files(sbml_file=None, condition_file=None, measurement_file=None, parameter_file=None, visualization_file=None, observable_file=None, yaml_file=None, prefix_path=None, relative_paths=True, model_file=None)
Write PEtab tables to files for this problem
Writes PEtab files for those entities for which a destination was passed.
NOTE: If this instance was created from multiple measurement or visualization tables, they will be merged and written to a single file.
- Parameters
sbml_file (
typing.Union
[pathlib.Path
,str
,None
]) – SBML model destinationmodel_file (
typing.Union
[pathlib.Path
,str
,None
]) – Model destinationcondition_file (
typing.Union
[pathlib.Path
,str
,None
]) – Condition table destinationmeasurement_file (
typing.Union
[pathlib.Path
,str
,None
]) – Measurement table destinationparameter_file (
typing.Union
[pathlib.Path
,str
,None
]) – Parameter table destinationvisualization_file (
typing.Union
[pathlib.Path
,str
,None
]) – Visualization table destinationobservable_file (
typing.Union
[pathlib.Path
,str
,None
]) – Observables table destinationyaml_file (
typing.Union
[pathlib.Path
,str
,None
]) – YAML file destinationprefix_path (
typing.Union
[pathlib.Path
,str
,None
]) – Specify a prefix to all paths, to avoid specifying the prefix for all paths individually. NB: the prefix is added to paths beforerelative_paths
is handled.relative_paths (
bool
) – whether all paths in the YAML file should be relative to the location of the YAML file. IfFalse
, then paths are left unchanged.
- Raises
ValueError – If a destination was provided for a non-existing entity.
- Return type
- to_files_generic(prefix_path)
Save a PEtab problem to generic file names.
The PEtab problem YAML file is always created. PEtab data files are only created if the PEtab problem contains corresponding data (e.g. a PEtab visualization TSV file is only created if the PEtab problem has one).
- Parameters
prefix_path (
typing.Union
[str
,pathlib.Path
]) – Specify a prefix to all paths, to avoid specifying the prefix for all paths individually. NB: the prefix is added to paths beforerelative_paths
is handled downstream inpetab.yaml.create_problem_yaml()
.- Return type
- Returns
The path to the PEtab problem YAML file.
- property ub: List
Parameter table upper bounds
- Return type
- property ub_scaled: List
Parameter table upper bounds with applied parameter scaling
- Return type
- unscale_parameters(x_dict)
Unscale parameter values.
- Parameters
x_dict (
typing.Dict
[str
,float
]) – Keys are parameter IDs in the PEtab problem, values are scaled parameter values.- Return type
The unscaled parameter values.
- property x_nominal: List
Parameter table nominal values
- Return type
- property x_nominal_fixed: List
Parameter table nominal values, for fixed parameters.
- Return type
- property x_nominal_fixed_scaled: List
Parameter table nominal values with applied parameter scaling, for fixed parameters.
- Return type
- property x_nominal_free: List
Parameter table nominal values, for free parameters.
- Return type
- property x_nominal_free_scaled: List
Parameter table nominal values with applied parameter scaling, for free parameters.
- Return type
- property x_nominal_scaled: List
Parameter table nominal values with applied parameter scaling
- Return type
- amici.petab_import_pysb.create_dummy_sbml(pysb_model, observable_ids=None)[source]
Create SBML dummy model for to use PySB models with PEtab.
Model must at least contain PEtab problem parameter and noise parameters for observables.
- Parameters
pysb_model (
pysb.core.Model
) – PySB modelobservable_ids (
typing.Optional
[typing.Iterable
[str
]]) – Observable IDs
- Return type
petab.models.sbml_model.SbmlModel
- Returns
A dummy petab SBML model.
- amici.petab_import_pysb.import_model_pysb(petab_problem, model_output_dir=None, verbose=True, model_name=None, **kwargs)[source]
Create AMICI model from PySB-PEtab problem
- Parameters
petab_problem (
amici.petab_import_pysb.PysbPetabProblem
) – PySB PEtab problemmodel_output_dir (
typing.Union
[pathlib.Path
,str
,None
]) – 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.model_name (
typing.Optional
[str
]) – Name of the generated model modulekwargs – Additional keyword arguments to be passed to
amici.pysb_import.pysb2amici()
.
- Return type