geckopy.model¶
Model class that extends cobra.Model to account for enzyme constraints.
Module Contents¶
Classes¶
Extension of cobra.Model providing an API for proteins in EC models. |
- class geckopy.model.Model(id_or_model: Union[str, cobra.Model] = None, name: str = None, hardcoded_rev_reactions: bool = True)[source]¶
Bases:
cobra.ModelExtension of cobra.Model providing an API for proteins in EC models.
- reactions¶
A DictList where the key is the reaction identifier and the value a Reaction.
- Type
DictList
- metabolites¶
A DictList where the key is the metabolite identifier and the value a Metabolite.
- Type
DictList
- proteins¶
A DictList where the key is the metabolite identifier and the value a Protein.
- Type
DictList
- genes¶
A DictList where the key is the gene identifier and the value a Gene.
- Type
DictList
- groups¶
A DictList where the key is the group identifier and the value a Group.
- Type
DictList
- solution¶
# TODO: separate proteins from cobra.Reactions The last obtained solution from optimizing the model.
- Type
Solution
- __setstate__(self, state: Dict)[source]¶
Make sure all cobra.Objects in the model point to the model.
- from_cobra(self, model: cobra.Model, name: str)[source]¶
Initialize from cobra model.
- get_total_measured_proteins(self) → float[source]¶
Sum of all Proteins in the model that has a concentration.
- constrain_pool(self, p_total: float, sigma_saturation_factor: float, fn_mass_fraction_unmeasured_matched: float, protein_list: List[str] = None)[source]¶
Constrain the draw reactions for the unmeasured (common protein pool) proteins.
Adapted from [geckopy] (https://github.com/SysBioChalmers/GECKO/blob/master/geckopy/geckopy/gecko.py#L184)
Proteins without their own protein pool are collectively constrained by the common protein pool. Remove protein pools for all proteins that don’t have measurements, along with corresponding draw reactions, and add these to the common protein pool and reaction.
- Parameters
p_total (float) – measured total protein fraction in cell in g protein / gDW
sigma_saturation_factor (float) – part of proteome that can be used by metabolism
fn_mass_fraction_unmeasured_matched (float) – TODO: add convenience function to handle this sum of the product of average abundances of unmesured proteins (from, e.g., paxDB) times their molecular weight.
protein_list (List[str]) – list of ids of proteins to constrain. This is useful for inspecting the protein utilization of, e.g., a heterologous pathway.
- add_pool(self, reac_id: str = 'prot_pool_exchange', met_id: str = 'prot_pool')[source]¶
Add the reaction and metabolite to constraint the common pool of proteins.
- Parameters
read_id (str) – id of the common protein pool pseudorreaction to add.
met_id (str) – id of the common protein pool metabolite to add.
- copy(self)[source]¶
Provide a partial ‘deepcopy’ of the Model.
All of the Metabolite, Gene, and Reaction objects are created anew but in a faster fashion than deepcopy. Enzyme constrained changes: also deepcopy proteins.
- _populate_solver(self, reaction_list: Iterator[Reaction], metabolite_list: Iterator[Metabolite] = None, protein_list: Iterator[Protein] = None)[source]¶
Populate attached solver with LP problem given reactions + proteins.
Note that proteins are added both as Constraints and Variables.
- add_proteins(self, protein_list: Iterator[Protein])[source]¶
Add proteins to the model, in the same fashion as .add_metabollites.
- add_reactions(self, reaction_list: Iterator[Reaction])[source]¶
Add reactions to the model.
Reactions with identifiers identical to a reaction already in the model are ignored. The change is reverted upon exit when using the model as a context. Enzyme Constrained changes: avoid adding proteins as metabolites.
- Parameters
reaction_list (list) – A list of cobra.Reaction objects
- optimize(self, objective_sense: Optional[str] = None, raise_error: bool = False) → Tuple[cobra.Solution, cobra.Solution][source]¶
Optimize the model using flux balance analysis.
- Parameters
objective_sense ({None, 'maximize' 'minimize'}, optional) – Whether fluxes should be maximized or minimized. In case of None, the previous direction is used.
raise_error (bool) –
- If true, raise an OptimizationError if solver status is not
optimal.
Notes
Only the most commonly used parameters are presented here. Additional parameters for cobra.solvers may be available and specified with the appropriate keyword argument.
- add_boundary(self, metabolite: Union[cobra.Metabolite, Protein], type: str = 'exchange', reaction_id: Optional[str] = None, lb: Optional[float] = None, ub: Optional[float] = None, sbo_term: Optional[str] = None) → geckopy.reaction.Reaction[source]¶
Add a boundary reaction for a given metabolite.
Enzyme constraint changes: return an geckopy.Reaction.