7.1.2.2. pta.concentrations_prior

Definition of the prior distribution of metabolite concentrations.

7.1.2.2.1. Module Contents

class pta.concentrations_prior.ConcentrationsPrior(metabolite_distributions: Dict[Tuple[str, str], Any] = None, compartment_distributions: Dict[str, Any] = None, default_distribution: Any = default_log_conc)[source]

Manages prior distributions of concentrations for specific metabolites or compartments. This class provides a distribution for the concentration of any metabolite using (depending on the availability) (1) the distribution for the metabolite itself, (2) the default distribution of the compartment or (3) a default distribution.

Internally, metabolites are stored and accessed MetaNetX compound IDs or, when the compound is not recognized, by metabolite name.

Parameters:
  • metabolite_distributions (Dict[Tuple[str, str], Any], optional) – Mapping from metabolites to their prior. Metabolites are specified as a tuple of metabolite ID and compartment ID.

  • compartment_distributions (Dict[str, Any], optional) – Mapping from compartment IDs to the prior of the concentration for the compartment. This prior is used for compounds for which no explicit prior is given.

  • default_distribution (Any, optional) – Prior distribution to use for metabolites and compartments for which no prior is specified.

property metabolite_distributions: Dict[Tuple[Any, str], Any][source]

Gets the prior concentrations for specific metabolites. If the distributions are modified through this property, update_identifiers() should be called to make sure that compounds are identified correctly across different namespaces.

property compartment_distributions: Dict[str, Any][source]

Gets the prior concentrations for specific compartments.

property default_distribution[source]

Gets the default prior for concentrations.

static load(prior_file: Union[pathlib.Path, str]) ConcentrationsPrior[source]

Loads the concentration priors from a .csv file.

Parameters:

prior_file (Union[Path, str]) – Path to the file containing the parameter values or name of a builtin priors set (any file present in data/concentration_priors/, e.g. ‘ecoli_M9_ac’).

Returns:

The loaded ConcentrationPrior object.

Return type:

ConcentrationsPrior

save(prior_file: Union[pathlib.Path, str])[source]

Saves the concentration priors to a .csv file.

Parameters:

prior_file (Union[Path, str]) – Path to the destination file.

add(other: ConcentrationsPrior, overwrite_metabolite_priors: bool = True, overwrite_compartment_priors: bool = True, overwrite_default_prior: bool = True)[source]

Adds the distributions from another prior to this object.

Parameters:
  • other (ConcentrationsPrior) – The concentrations prior from which the distributions have to be copied.

  • overwrite_metabolite_priors (bool, optional) – Specifies whether, in case of duplicates, metabolite distributions in this object should be overwritten or not.

  • overwrite_compartment_priors (bool, optional) – Specifies whether, in case of duplicates, compartment distributions in this object should be overwritten or not.

  • overwrite_default_prior (bool, optional) – Specifies whether the default distribution in this object should be overwritten or not.

get(metabolite: str, compartment: str) Any[source]

Gets the distribution for the concentration of a given compound. This uses (depending on the availability) (1) the distribution for the compound itself, (2) the default distribution of the compartment or (3) a default distribution.

Parameters:
  • metabolite (str) – Identifier (in any namespace supported by eQuilibrator) of the compound.

  • compartment (str) – Identifier of the compartment.

Returns:

Distribution of the concentration of the specified compound.

Return type:

Any

update_identifiers()[source]

Updates the internal representation of the compound identifiers.

When possible, this class uses MetaNetX identifiers to represent compounds. This has the advantage that priors can be created and accessed using different namespaces. This function should be called whenever metabolite_distributions is modified.