:mod:`geckopy.protein` ====================== .. py:module:: geckopy.protein .. autoapi-nested-parse:: API for proteins. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: geckopy.protein.Protein geckopy.protein.Kcats .. data:: LOGGER .. data:: UNIPROT_PATTERN .. data:: config .. class:: Protein(id: Union[(str, Metabolite)] = None, concentration: float = None, molecular_weight: float = 0.0, name: str = '') Bases: :class:`cobra.Object` Representation of an enzyme. A protein sets an upper bound to a set of reactions, given the kcat and concentration. Adapted from `cobra.Reaction`. In terms of the inner LP model, `Proteins` populates both variables (as pseudorreactions with the mentioned upper_bound) and constraints (as metabolites). .. attribute:: id identifier of protein, should be an Uniprot ID or "prot_" :type: str .. attribute:: name human readable name :type: str .. attribute:: concentration parsed from `initialAmount` of `Species` in the SBML specification. :type: float .. attribute:: kcats 1 / stoichimetry coefficients of its reactions. :type: Kcats .. attribute:: mw TODO: parsed from initalParameters/calculate from formula :type: float .. attribute:: contribution value of flux of variable, only accessible after optimizing the model. :type: float .. attribute:: lower_bound should be 0 :type: float .. attribute:: upper_bound concentration * kcat if there is a concentration, mmw if is part of the pool constraint (unmeasured proteins) or 1000. :type: float .. attribute:: formula :type: str .. attribute:: charge :type: float .. method:: _set_id_with_model(self, value) Overwrite parent id setter to change constraints and variables. .. method:: from_metabolite(self, met: cobra.Metabolite) Initialize `Protein` from `Metabolite`; i.e., when reading from SBML. .. method:: update_variable_bounds(self) Sync object bounds with inner model variable bounds. .. method:: suscribe_to_pool(self, mmw: float) Change internal pseudorreaction to have the common pool as reactant. .. method:: unsuscribe_to_pool(self) Change internal pseudorreaction to have the common pool as reactant. .. method:: concentration(self) -> float :property: Get upper bounds as [E] (conventionally in $\frac{mmol}{gDW}$). [E] multiplied by the kcat (expressed in the reaction stoichiometry as 1/kcat) yields $\frac{mmol}/{gDW h}$. Taken from [Benjamín J Sánchez et al., 2016] (https://www.embopress.org/doi/full/10.15252/msb.20167411). .. method:: upper_bound(self) -> float :property: Get upper bounds as [E] (conventionally in $\frac{mmol}{gDW}$). [E] multiplied by the kcat (expressed in the reaction stoichiometry as 1/kcat) yields $\frac{mmol}/{gDW h}$. Taken from [Benjamín J Sánchez et al., 2016] (https://www.embopress.org/doi/full/10.15252/msb.20167411). .. method:: add_concentration(self, value: float) Add concentration value. It will unsuscribe the protein to the common protein pool, if suscribed. .. method:: reverse_id(self) -> str :property: Generate the id of reverse_variable from the reaction's id. .. method:: contribution(self) -> str :property: Get primal value (analogous to flux) in the most recent solution. .. method:: flux(self) -> float :property: Get flux value in the most recent solution. Flux is the primal value of the corresponding variable in the model. .. warning:: * Accessing reaction fluxes 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. * Reaction flux 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 reaction is not part of a model. :raises OptimizationError: If the solver status is anything other than 'optimal'. :raises AssertionError: If the flux value is not within the bounds. .. method:: forward_variable(self) -> optlang.Variable :property: Get `optlang.Variable` representing the forward flux. :returns: An optlang variable for the forward flux or None if reaction is not associated with a model. :rtype: optlang.interface.Variable .. method:: reverse_variable(self) -> optlang.Variable :property: Get `optlang.Variable` representing the reverse flux. :returns: An optlang variable for the reverse flux or None if reaction is not associated with a model. :rtype: optlang.interface.Variable .. method:: objective_coefficient(self) -> float :property: Get the coefficient for this reaction in a linear objective (float). Assuming that the objective of the associated model is summation of fluxes from a set of reactions, the coefficient for each reaction can be obtained individually using this property. A more general way is to use the `model.objective` property directly. .. method:: bounds(self) -> Tuple[(float, float)] :property: Get or set the bounds directly from a tuple. Convenience method for setting upper and lower bounds in one line using a tuple of lower and upper bound. Invalid bounds will raise an AssertionError. When using a `HistoryManager` context, this attribute can be set temporarily, reversed when the exiting the context. .. method:: _metabolites(self) :property: Get metabolites. .. method:: metabolites(self) -> Dict :property: Get metabolite of the protein pseudoreaction as the protein itself. .. method:: reactions(self) -> FrozenSet[Reaction] :property: Retrieve immutable private reactions property. .. method:: model(self) :property: Retrieve the model the reaction is a part of. .. method:: reactants(self) :property: Return a list of reactants for the reaction. .. method:: products(self) :property: Return a list of products for the reaction. .. method:: __setstate__(self, state) Set attribute to point to model, mimicking `cobra.Reaction`. .. method:: __str__(self) -> str Print str representation as id. .. method:: _repr_html_(self) -> str .. class:: Kcats(prot: geckopy.protein.Protein) Interface to modify kcats of a protein. The user interacts with kcats in 1/s, translated to h to the model in the form stoichiometry coefficients of protein participating in a given reaction. .. rubric:: Example .. doctest:: # dictionary of Reaction to kcat in s >>> model.proteins.prot_P0A796.kcats # the user inputs the kcat in 1/s >>> model.proteins.prot_P0A796.kcats["PFKNo1"] = 1 / 30 # the corresponding stoichiometry value is in -h >>> ec_model.reactions.PFKNo1.metabolites[model.proteins.prot_P0A796] == -1/120 .. method:: _update(self) Build the map on the fly. .. method:: __getitem__(self, key: Union[(Reaction, str)]) -> float Return the kcat of the protein in the Reaaction `key`. .. method:: __setitem__(self, key: Union[(Reaction, str)], val: float) Assing kcat as `val` in the given `key` Reaction (as 1/kcat). .. method:: _model_warn(self, key: Union[(Reaction, str)], action: str) .. method:: __iter__(self) Iterate inner dict. .. method:: items(self) Iterate inner items. .. method:: keys(self) Return inner dict's keys. .. method:: values(self) Return inner dict's values. .. method:: __repr__(self) Represent inner dict.