17.1.1.4.1.2. cobra.manipulation.delete
¶
17.1.1.4.1.2.1. Module Contents¶
17.1.1.4.1.2.1.1. Classes¶
A |
17.1.1.4.1.2.1.2. Functions¶
|
Remove metabolites that are not involved in any reactions and |
|
Remove reactions with no assigned metabolites, returns pruned model |
|
Undoes the effects of a call to delete_model_genes in place. |
|
Generates a dict of compiled gene_reaction_rules |
|
identify reactions which will be disabled when the genes are knocked out |
|
delete_model_genes will set the upper and lower bounds for reactions |
|
remove genes entirely from the model |
-
cobra.manipulation.delete.
prune_unused_metabolites
(cobra_model)[source]¶ Remove metabolites that are not involved in any reactions and returns pruned model
- Parameters
cobra_model (class:~cobra.core.Model.Model object) – the model to remove unused metabolites from
- Returns
output_model (class:~cobra.core.Model.Model object) – input model with unused metabolites removed
inactive_metabolites (list of class:~cobra.core.reaction.Reaction) – list of metabolites that were removed
-
cobra.manipulation.delete.
prune_unused_reactions
(cobra_model)[source]¶ Remove reactions with no assigned metabolites, returns pruned model
- Parameters
cobra_model (class:~cobra.core.Model.Model object) – the model to remove unused reactions from
- Returns
output_model (class:~cobra.core.Model.Model object) – input model with unused reactions removed
reactions_to_prune (list of class:~cobra.core.reaction.Reaction) – list of reactions that were removed
-
cobra.manipulation.delete.
undelete_model_genes
(cobra_model)[source]¶ Undoes the effects of a call to delete_model_genes in place.
cobra_model: A cobra.Model which will be modified in place
-
cobra.manipulation.delete.
get_compiled_gene_reaction_rules
(cobra_model)[source]¶ Generates a dict of compiled gene_reaction_rules
Any gene_reaction_rule expressions 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.
-
cobra.manipulation.delete.
find_gene_knockout_reactions
(cobra_model, gene_list, compiled_gene_reaction_rules=None)[source]¶ identify reactions which will be disabled when the genes are knocked out
cobra_model:
Model
gene_list: iterable of
Gene
- compiled_gene_reaction_rules: dict of {reaction_id: compiled_string}
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.
-
cobra.manipulation.delete.
delete_model_genes
(cobra_model, gene_list, cumulative_deletions=True, disable_orphans=False)[source]¶ delete_model_genes will set the upper and lower bounds for reactions catalysed by the genes in gene_list if deleting the genes means that the reaction cannot proceed according to cobra_model.reactions[:].gene_reaction_rule
cumulative_deletions: False or True. If True then any previous deletions will be maintained in the model.
-
class
cobra.manipulation.delete.
_GeneRemover
(target_genes)[source]¶ Bases:
ast.NodeTransformer
A
NodeVisitor
subclass that walks the abstract syntax tree and allows modification of nodes.The NodeTransformer will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is
None
, the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place.Here is an example transformer that rewrites all occurrences of name lookups (
foo
) todata['foo']
:class RewriteName(NodeTransformer): def visit_Name(self, node): return Subscript( value=Name(id='data', ctx=Load()), slice=Index(value=Str(s=node.id)), ctx=node.ctx )
Keep in mind that if the node you’re operating on has child nodes you must either transform the child nodes yourself or call the
generic_visit()
method for the node first.For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node.
Usually you use the transformer like this:
node = YourTransformer().visit(node)