17.1.1.1.2.4. cobra.core.gene
¶
17.1.1.1.2.4.1. Module Contents¶
17.1.1.1.2.4.1.1. Classes¶
Parses compiled ast of a gene_reaction_rule and identifies genes |
|
A Gene in a cobra model |
17.1.1.1.2.4.1.2. Functions¶
|
convert compiled ast to gene_reaction_rule str |
|
evaluate compiled ast of gene_reaction_rule with knockouts |
|
parse gpr into AST |
-
cobra.core.gene.
replacements
= [['.', '__COBRA_DOT__'], ["'", '__COBRA_SQUOTE__'], ['"', '__COBRA_DQUOTE__'], [':', '__COBRA_COLON__'], ['/', '__COBRA_FSLASH__'], ['\\', '__COBRA_BSLASH'], ['-', '__COBRA_DASH__'], ['=', '__COBRA_EQ__']][source]¶
-
cobra.core.gene.
ast2str
(expr, level=0, names=None)[source]¶ convert compiled ast to gene_reaction_rule str
- Parameters
expr (str) – string for a gene reaction rule, e.g “a and b”
level (int) – internal use only
names (dict) – Dict where each element id a gene identifier and the value is the gene name. Use this to get a rule str which uses names instead. This should be done for display purposes only. All gene_reaction_rule strings which are computed with should use the id.
- Returns
The gene reaction rule
- Return type
string
-
cobra.core.gene.
eval_gpr
(expr, knockouts)[source]¶ evaluate compiled ast of gene_reaction_rule with knockouts
-
class
cobra.core.gene.
GPRCleaner
[source]¶ Bases:
ast.NodeTransformer
Parses compiled ast of a gene_reaction_rule and identifies genes
Parts of the tree are rewritten to allow periods in gene ID’s and bitwise boolean operations
-
cobra.core.gene.
parse_gpr
(str_expr)[source]¶ parse gpr into AST
- Parameters
str_expr (string) – string with the gene reaction rule to parse
- Returns
elements ast_tree and gene_ids as a set
- Return type
-
class
cobra.core.gene.
Gene
(id=None, name='', functional=True)[source]¶ Bases:
cobra.core.species.Species
A Gene in a cobra model
- Parameters
id (string) – The identifier to associate the gene with
name (string) – A longer human readable name for the gene
functional (bool) – Indicates whether the gene is functional. If it is not functional then it cannot be used in an enzyme complex nor can its products be used.
-
property
functional
(self)[source]¶ A flag indicating if the gene is functional.
Changing the flag is reverted upon exit if executed within the model as context.
-
knock_out
(self)[source]¶ Knockout gene by marking it as non-functional and setting all associated reactions bounds to zero.
The change is reverted upon exit if executed within the model as context.
-
remove_from_model
(self, model=None, make_dependent_reactions_nonfunctional=True)[source]¶ Removes the association
- Parameters
model (cobra model) – The model to remove the gene from
make_dependent_reactions_nonfunctional (bool) – If True then replace the gene with ‘False’ in the gene association, else replace the gene with ‘True’
Deprecated since version 0.4: Use cobra.manipulation.delete_model_genes to simulate knockouts and cobra.manipulation.remove_genes to remove genes from the model.