amici.pysb_import
PySB Import
This module provides all necessary functionality to import a model specified
in the pysb.core.Model
format.
Functions
|
Constructs a list of monomer names contained in complex patterns. |
|
Wrapper to interface |
|
Creates an |
|
Generate AMICI C++ files for the provided model. |
|
Generate AMICI jax files for the provided model. |
|
Load a pysb model module and return the |
- amici.pysb_import.extract_monomers(complex_patterns)[source]
Constructs a list of monomer names contained in complex patterns. Multiplicity of names corresponds to the stoichiometry in the complex.
- Parameters:
complex_patterns (
pysb.core.ComplexPattern
|list
[pysb.core.ComplexPattern
]) – (list of) complex pattern(s)- Return type:
- Returns:
list of monomer names
- amici.pysb_import.has_fixed_parameter_ic(specie, pysb_model, ode_model)[source]
Wrapper to interface
de_export.DEModel.state_has_fixed_parameter_initial_condition()
from a pysb specie/model arguments- Parameters:
specie (
pysb.core.ComplexPattern
) – pysb speciespysb_model (
pysb.core.Model
) – pysb modelode_model (
amici.de_model.DEModel
) – ODE model
- Return type:
- Returns:
False
if the species does not have an initial condition at all. Otherwise the return value ofde_export.DEModel.state_has_fixed_parameter_initial_condition()
- amici.pysb_import.ode_model_from_pysb_importer(model, constant_parameters=None, observables=None, sigmas=None, noise_distributions=None, compute_conservation_laws=True, simplify=<function powsimp>, cache_simplify=False, verbose=False)[source]
Creates an
amici.DEModel
instance from apysb.Model
instance.- Parameters:
model (
pysb.core.Model
) – seeamici.pysb_import.pysb2amici()
constant_parameters (
list
[str
]) – seeamici.pysb_import.pysb2amici()
observables (
list
[str
]) – seeamici.pysb_import.pysb2amici()
sigmas (
dict
[str
,str
]) – dict with names of observable Expressions as keys and names of sigma Expressions as value sigmanoise_distributions (
dict
[str
,str
|collections.abc.Callable
] |None
) – seeamici.pysb_import.pysb2amici()
compute_conservation_laws (
bool
) – seeamici.pysb_import.pysb2amici()
simplify (
collections.abc.Callable
) – seeamici.DEModel._simplify
cache_simplify (
bool
) – seeamici.DEModel.__init__()
Note that there are possible issues with PySB models: https://github.com/AMICI-dev/AMICI/pull/1672verbose (
int
|bool
) – verbosity level for logging, True/False default tologging.DEBUG
/logging.ERROR
- Return type:
- Returns:
New DEModel instance according to pysbModel
- amici.pysb_import.pysb2amici(model, output_dir=None, observables=None, constant_parameters=None, sigmas=None, noise_distributions=None, verbose=False, assume_pow_positivity=False, compiler=None, compute_conservation_laws=True, compile=True, simplify=<function _default_simplify>, cache_simplify=False, generate_sensitivity_code=True, model_name=None)[source]
Generate AMICI C++ files for the provided model.
Warning
PySB models with Compartments
When importing a PySB model with
pysb.Compartment
s, BioNetGen scales reaction fluxes with the compartment size. Instead of using the respective symbols, the compartment size Parameter or Expression is evaluated when generating equations. This may lead to unexpected results if the compartment size parameter is changed for AMICI simulations.- Parameters:
model (
pysb.core.Model
) – pysb model,pysb.Model.name
will determine the name of the generated moduleoutput_dir (
str
|pathlib.Path
|None
) – seeamici.de_export.ODEExporter.set_paths()
observables (
list
[str
]) – list ofpysb.core.Expression
orpysb.core.Observable
names in the provided model that should be mapped to observablessigmas (
dict
[str
,str
]) – dict ofpysb.core.Expression
names that should be mapped to sigmasnoise_distributions (
dict
[str
,str
|collections.abc.Callable
] |None
) – dict with names of observable Expressions as keys and a noise type identifier, or a callable generating a custom noise formula string (seeamici.import_utils.noise_distribution_to_cost_function()
). If nothing is passed for some observable id, a normal model is assumed as default.constant_parameters (
list
[str
]) – list ofpysb.core.Parameter
names that should be mapped as fixed parametersverbose (
int
|bool
) – verbosity level for logging, True/False default tologging.DEBUG
/logging.ERROR
assume_pow_positivity (
bool
) – if set toTrue
, a special pow function is used to avoid problems with state variables that may become negative due to numerical errorscompiler (
str
) – Absolute path to the compiler executable to be used to build the Python extension, e.g./usr/bin/clang
.compute_conservation_laws (
bool
) – if set toTrue
, conservation laws are automatically computed and applied such that the state-jacobian of the ODE right-hand-side has full rank. This option should be set toTrue
when using the Newton algorithm to compute steadystatescompile (
bool
) – IfTrue
, build the python module for the generated model. If false, just generate the source code.simplify (
collections.abc.Callable
) – seeamici.DEModel._simplify
cache_simplify (
bool
) – seeamici.DEModel.__init__()
Note that there are possible issues with PySB models: https://github.com/AMICI-dev/AMICI/pull/1672generate_sensitivity_code (
bool
) – if set toFalse
, code for sensitivity computation will not be generatedmodel_name (
str
|None
) – Name for the generated model module. If None,pysb.Model.name
will be used.
- amici.pysb_import.pysb2jax(model, output_dir=None, observables=None, sigmas=None, noise_distributions=None, verbose=False, compute_conservation_laws=True, simplify=<function _default_simplify>, cache_simplify=False, model_name=None)[source]
Generate AMICI jax files for the provided model.
Warning
PySB models with Compartments
When importing a PySB model with
pysb.Compartment
s, BioNetGen scales reaction fluxes with the compartment size. Instead of using the respective symbols, the compartment size Parameter or Expression is evaluated when generating equations. This may lead to unexpected results if the compartment size parameter is changed for AMICI simulations.- Parameters:
model (
pysb.core.Model
) – pysb model,pysb.Model.name
will determine the name of the generated moduleoutput_dir (
str
|pathlib.Path
|None
) – seeamici.de_export.ODEExporter.set_paths()
observables (
list
[str
]) – list ofpysb.core.Expression
orpysb.core.Observable
names in the provided model that should be mapped to observablessigmas (
dict
[str
,str
]) – dict ofpysb.core.Expression
names that should be mapped to sigmasnoise_distributions (
dict
[str
,str
|collections.abc.Callable
] |None
) – dict with names of observable Expressions as keys and a noise type identifier, or a callable generating a custom noise formula string (seeamici.import_utils.noise_distribution_to_cost_function()
). If nothing is passed for some observable id, a normal model is assumed as default.verbose (
int
|bool
) – verbosity level for logging, True/False default tologging.DEBUG
/logging.ERROR
compute_conservation_laws (
bool
) – if set toTrue
, conservation laws are automatically computed and applied such that the state-jacobian of the ODE right-hand-side has full rank. This option should be set toTrue
when using the Newton algorithm to compute steadystatessimplify (
collections.abc.Callable
) – seeamici.DEModel._simplify
cache_simplify (
bool
) – seeamici.DEModel.__init__()
Note that there are possible issues with PySB models: https://github.com/AMICI-dev/AMICI/pull/1672model_name (
str
|None
) – Name for the generated model module. If None,pysb.Model.name
will be used.
- amici.pysb_import.pysb_model_from_path(pysb_model_file)[source]
Load a pysb model module and return the
pysb.Model
instance- Parameters:
pysb_model_file (
str
|pathlib.Path
) – Full or relative path to the PySB model module- Return type:
- Returns:
The pysb Model instance