15.1.1.1.1.4. cobra.core.metabolite
¶
15.1.1.1.1.4.1. Module Contents¶
-
class
cobra.core.metabolite.
Metabolite
(id=None, formula=None, name="", charge=None, compartment=None)[source]¶ Metabolite is a class for holding information regarding a metabolite in a cobra.Reaction object.
Parameters: -
constraint
()¶ Get the constraints associated with this metabolite from the solve
Returns: the optlang constraint for this metabolite Return type: optlang.<interface>.Constraint
-
elements
()¶ Dictionary of elements as keys and their count in the metabolite as integer. When set, the formula property is update accordingly
-
elements
(elements_dict)
-
formula_weight
()¶ Calculate the formula weight
-
y
()¶ The shadow price for the metabolite in the most recent solution
Shadow prices are computed from the dual values of the bounds in the solution.
-
shadow_price
()¶ The shadow price in the most recent solution.
Shadow price is the dual value of the corresponding constraint in the model.
Warning
- Accessing shadow prices through a Solution object is the safer, preferred, and only guaranteed to be correct way. You can see how to do so easily in the examples.
- Shadow price is retrieved from the currently defined self._model.solver. The solver status is checked but there are no guarantees that the current solver state is the one you are looking for.
- If you modify the underlying model after an optimization, you will retrieve the old optimization values.
Raises: RuntimeError
– If the underlying model was never optimized beforehand or the metabolite is not part of a model.OptimizationError
– If the solver status is anything other than ‘optimal’.
Examples
>>> import cobra >>> import cobra.test >>> model = cobra.test.create_test_model("textbook") >>> solution = model.optimize() >>> model.metabolites.glc__D_e.shadow_price -0.09166474637510488 >>> solution.shadow_prices.glc__D_e -0.091664746375104883
-
remove_from_model
(destructive=False)[source]¶ Removes the association from self.model
The change is reverted upon exit when using the model as a context.
Parameters: destructive (bool) – If False then the metabolite is removed from all associated reactions. If True then all associated reactions are removed from the Model.
-
summary
(solution=None, threshold=0.01, fva=None, names=False, floatfmt=".3g")[source]¶ Print a summary of the production and consumption fluxes.
This method requires the model for which this metabolite is a part to be solved.
Parameters: - solution (cobra.Solution, optional) – A previously solved model solution to use for generating the summary. If none provided (default), the summary method will resolve the model. Note that the solution object must match the model, i.e., changes to the model such as changed bounds, added or removed reactions are not taken into account by this method.
- threshold (float, optional) – Threshold below which fluxes are not reported.
- fva (pandas.DataFrame, float or None, optional) – Whether or not to include flux variability analysis in the output. If given, fva should either be a previous FVA solution matching the model or a float between 0 and 1 representing the fraction of the optimum objective to be searched.
- names (bool, optional) – Emit reaction and metabolite names rather than identifiers (default False).
- floatfmt (string, optional) – Format string for floats (default ‘.3g’).
-