15.1.1.1.1.3. cobra.core.gene

15.1.1.1.1.3.1. Module Contents

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

Parameters:
  • expr (Expression) – The ast of the gene reaction rule
  • knockouts (DictList, set) – Set of genes that are knocked out
Returns:

True if the gene reaction rule is true with the given knockouts otherwise false

Return type:

bool

class cobra.core.gene.GPRCleaner[source]

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

__init__()[source]
visit_Name(node)[source]
visit_BinOp(node)[source]
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:tuple
class cobra.core.gene.Gene(id=None, name="", functional=True)[source]

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.
__init__(id=None, name="", functional=True)[source]
functional()

A flag indicating if the gene is functional.

Changing the flag is reverted upon exit if executed within the model as context.

functional(value)
knock_out()[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(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.

_repr_html_()[source]