7.1.2.6. pta.pmo

Construction and solution of Probabilistic Metabolic Optimization (PMO) problems.

7.1.2.6.1. Module Contents

class pta.pmo.PmoProblemPool(num_processes: Optional[int], *argv)[source]

Creation of a process pool for solving multiple PMO problems on the same model.

map(fn: Callable[[PmoProblem, Any], Any], inputs: Iterable[Any]) List[Any][source]

Execute a function on each input element.

This is the same as the regular map function, except that it executes in parallel on the available workers.

Parameters:
  • fn (Callable[[PmoProblem, Any], Any]) – Function to be applied to each element.

  • inputs (Iterable[Any]) – An iterable containing the input elements.

Returns:

A list containing the result of applying the function to each input element.

Return type:

List[Any]

close()[source]

Wait for all jobs to be done and closes the pool.

class pta.pmo.PmoProblem(network: Union[cobra.Model, pta.flux_space.FluxSpace], thermodynamic_space: pta.thermodynamic_space.ThermodynamicSpace, thermodynamic_space_basis: pta.thermodynamic_space.ThermodynamicSpaceBasis = None, objective: Callable[[PmoProblem], cvxpy.problems.objective.Objective] = None, confidence_level: float = default_confidence_level, min_drg: float = default_min_drg, max_drg: float = default_max_drg, solver: Optional[str] = None, solver_options: dict = None)[source]

Construction and solution of a PMO problem.

Parameters:
  • network (Union[cobra.Model, FluxSpace]) – Cobra model or FluxSpace object describing the flux space of the metabolic network.

  • thermodynamic_space (ThermodynamicSpace) – Description of the thermodynamic space of the metabolic network.

  • thermodynamic_space_basis (ThermodynamicSpaceBasis, optional) – A basis for the thermodynamic space. If specified, m will be defined in this basis.

  • objective (Callable[ [PmoProblem], cp.problems.objective.Objective], optional) – A function used to set the optimization objective. By default the probability of in thermodynamic space is maximized.

  • confidence_level (float, optional) – Confidence level (in the range \([0.0, 1.0[\)) on the joint of the thermodynamic variables, by default 0.95.

  • min_drg (float, optional) – Minimum magnitude for the reaction energy of each reaction, by default 1e-1.

  • max_drg (float, optional) – Maximum magnitude for the reaction energy of each reaction, by default 1000.

  • solver (Optional[str], optional) – Name of the solver to use, this can be any of the solvers supported by CVXPY, by default None.

  • solver_options (dict, optional) – Dictionary specifying additional options for the solver.

property confidence_level[source]

Gets the confidence level on the thermodynamic space.

property min_drg: float[source]

Gets the minimum absolute value of DrG allowed in the model.

property max_drg: float[source]

Gets the maximum absolute value of DrG in the model.

property flux_scale: numpy.ndarray[source]

Gets the vector of scaling factors for the scaled fluxes.

property objective: Optional[Callable[[PmoProblem], cvxpy.problems.objective.Objective]][source]

Gets the function that constructs the PMO objective.

property vs: cvxpy.Variable[source]

Gets the CVXPY variable representing scaled reaction fluxes.

property m: cvxpy.Variable[source]

Gets the CVXPY variable representing the thermodynamic space in the minimal basis.

property d: cvxpy.Variable[source]

Gets the CVXPY variable representing reaction directions.

property v: numpy.array[source]

Gets the predicted reaction fluxes.

property log_c: numpy.ndarray[source]

Gets the predicted log-concentrations. Can be none if concentrations are not represented explicitely.

property drg0: numpy.ndarray[source]

Gets the predicted standard reaction energies. Can be none if standard reaction energies are not represented explicitely.

property drg: numpy.ndarray[source]

Gets the predicted reaction energies. Can be none if reaction energies are not represented explicitely.

property solver: Optional[str][source]

Gets the selected solver.

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

Gets the solver options.

property F: pta.flux_space.FluxSpace[source]

Gets the flux space associated with the PMO problem.

property T: pta.thermodynamic_space.ThermodynamicSpace[source]

Gets the thermodynamic space associated with the PMO problem.

property B: pta.thermodynamic_space.ThermodynamicSpaceBasis[source]

Gets the thermodynamic space basis associated with the PMO problem.

property flux_lb_constraint: cvxpy.constraints.constraint.Constraint[source]

Gets the lower bound constraint for fluxes.

property flux_ub_constraint: cvxpy.constraints.constraint.Constraint[source]

Gets the upper bound constraint for fluxes.

property steady_state_constraint: cvxpy.constraints.constraint.Constraint[source]

Gets the steady state constraint.

property confidence_constraint: cvxpy.constraints.constraint.Constraint[source]

Gets the constraint for the selected confidence level.

property sign_constraints: cvxpy.constraints.constraint.Constraint[source]

Gets the reaction direction constraints. The constraints at indices 0 and 1 are constraints on the reaction energies, while 2 and 3 are constraints on the fluxes.

solve(verbose=False) str[source]

Solves the PMO problem. The result of the optimization is stored inside the class.

Parameters:

verbose (bool, optional) – True is the solver log should be printed to the console, false otherwise. By default False.

Returns:

The CVXPY result of the optimization.

Return type:

str

rebuild_for_directions(directions: numpy.ndarray) PmoProblem[source]

Construct a copy of this PMO problem constrained to the given reaction directions.

Parameters:

directions (np.ndarray) – Vector containing the directions (0: backward, 1: forward) of the reactions in T.

Returns:

A copy of this problem, constrained to the given directions.

Return type:

PmoProblem