17.1.1.4. cobra.manipulation
¶
17.1.1.4.1. Submodules¶
17.1.1.4.2. Package Contents¶
17.1.1.4.2.1. Functions¶
|
Add SBO terms for demands and exchanges. |
|
Temporarily remove the effect of genes in gene_list. |
|
Identify reactions which will be disabled when genes are knocked out. |
|
Remove metabolites not involved in any reactions. |
|
Remove reactions with no assigned metabolites, returns pruned model. |
|
Remove genes entirely from the model. |
|
Undo the effects of a call to delete_model_genes in place. |
|
Make all model component object IDs SBML compliant. |
|
Generate a dictionary of compiled gene-reaction rules. |
|
Rename genes in a model from the rename_dict. |
|
Check mass balance for reactions of model and return unbalanced ones. |
|
Check metabolite formulae of model. |
-
cobra.manipulation.
add_SBO
(model: Model) → None[source]¶ Add SBO terms for demands and exchanges.
This works for models which follow the standard convention for constructing and naming these reactions.
The reaction should only contain the single metabolite being exchanged, and the id should be EX_<met_id> or DM_<met_id> .
- Parameters
model (cobra.Model) – The model whose demand and exchange reactions need to be annotated.
-
cobra.manipulation.
delete_model_genes
(model: Model, gene_list: List['Gene'], cumulative_deletions: bool = True, disable_orphans: bool = False) → None[source]¶ Temporarily remove the effect of genes in gene_list.
It sets the bounds to “zero” for reactions catalysed by the genes in gene_list if deleting the genes stops the reactions from proceeding.
- Parameters
model (cobra.Model) – The model whose reaction bounds are to be set.
gene_list (list of cobra.Gene) – The list of genes to knock-out.
cumulative_deletions (bool, optional) – If True, then any previous deletions will be maintained in the model (default True).
disable_orphans (bool, optional) – If True, then orphan reactions will be disabled. Currently, this is not implemented (default False).
-
cobra.manipulation.
find_gene_knockout_reactions
(model: Model, gene_list: List['Gene'], compiled_gene_reaction_rules: Optional[Dict['Reaction', Module]] = None) → List['Reaction'][source]¶ Identify reactions which will be disabled when genes are knocked out.
- Parameters
model (cobra.Model) – The model for which to find gene knock-out reactions.
gene_list (list of cobra.Gene) – The list of genes to knock-out.
compiled_gene_reaction_rules (dict of {reaction: compiled_string},) – optional If provided, this gives pre-compiled gene-reaction rule strings. The compiled rule strings can be evaluated much faster. If a rule is not provided, the regular expression evaluation will be used. Because not all gene-reaction rule strings can be evaluated, this dict must exclude any rules which can not be used with eval (default None).
- Returns
list of cobra.Reaction – The list of cobra.Reaction objects which will be disabled.
.. deprecated:: 0.22.1 – Internal function that has outlived its purpose.
-
cobra.manipulation.
prune_unused_metabolites
(model: Model) → Tuple['Model', List['Metabolite']][source]¶ Remove metabolites not involved in any reactions.
- Parameters
model (cobra.Model) – The model to remove unused metabolites from.
- Returns
cobra.Model – Input model with unused metabolites removed.
list of cobra.Metabolite – List of metabolites that were removed.
-
cobra.manipulation.
prune_unused_reactions
(model: Model) → Tuple['Model', List['Reaction']][source]¶ Remove reactions with no assigned metabolites, returns pruned model.
- Parameters
model (cobra.Model) – The model to remove unused reactions from.
- Returns
cobra.Model – Input model with unused reactions removed.
list of cobra.Reaction – List of reactions that were removed.
-
cobra.manipulation.
remove_genes
(model: Model, gene_list: List['Gene'], remove_reactions: bool = True) → None[source]¶ Remove genes entirely from the model.
This will also simplify all gene-reaction rules with the genes inactivated.
- Parameters
model (cobra.Model) – The model to remove genes from.
gene_list (list of cobra.Gene) – The list of gene objects to remove.
remove_reactions (bool, optional) – Whether to remove reactions associated with genes in gene_list (default True).
-
cobra.manipulation.
undelete_model_genes
(model: Model) → None[source]¶ Undo the effects of a call to delete_model_genes in place.
- Parameters
model (cobra.Model) – The model which will be modified in place.
-
cobra.manipulation.
escape_ID
(model: Model) → None[source]¶ Make all model component object IDs SBML compliant.
- Parameters
model (cobra.Model) – The model to operate on.
-
cobra.manipulation.
get_compiled_gene_reaction_rules
(model: Model) → Dict['Reaction', Module]¶ Generate a dictionary of compiled gene-reaction rules.
Any gene-reaction rule expression which cannot be compiled or do not evaluate after compiling will be excluded. The result can be used in the find_gene_knockout_reactions function to speed up evaluation of these rules.
- Parameters
model (cobra.Model) – The model to get gene-reaction rules for.
- Returns
The dictionary of cobra.Reaction objects as keys and ast.Module objects as keys.
- Return type
dict of cobra.Reaction, ast.Module
-
cobra.manipulation.
rename_genes
(model: Model, rename_dict: Dict[str, str]) → None[source]¶ Rename genes in a model from the rename_dict.
- Parameters
model (cobra.Model) – The model to operate on.
rename_dict (dict of {str: str}) – The dictionary having keys as old gene names and value as new gene names.
-
cobra.manipulation.
check_mass_balance
(model: Model) → Dict['Reaction', Dict['Metabolite', float]][source]¶ Check mass balance for reactions of model and return unbalanced ones.
- Parameters
model (cobra.Model) – The model to perform check on.
- Returns
dict of {cobra.Reaction – Returns an empty dict if all components are balanced.
- Return type
dict of {cobra.Metabolite: float}}
-
cobra.manipulation.
check_metabolite_compartment_formula
(model: Model) → List[str][source]¶ Check metabolite formulae of model.
- Parameters
model (cobra.Model) – The model to perform check on.
- Returns
Returns an empty list if no errors are found.
- Return type
list of str