cameo.core package¶
Submodules¶
cameo.core.manipulation module¶
Manage manipulations such as swapping reaction cofactors, overexpress or downregulate genes and reactions.

cameo.core.manipulation.
increase_flux
(reaction, ref_value, value)[source]¶ lb 0 ub  ' 
Parameters:

cameo.core.manipulation.
decrease_flux
(reaction, ref_value, value)[source]¶ lb 0 ub  ' 
   >———‘
 ‘———<   
Parameters:

cameo.core.manipulation.
reverse_flux
(reaction, ref_value, value)[source]¶ Forces a reaction to have a minimum flux level in the opposite direction of a reference state.
lb 0 ub  ' 
<———‘       >Parameters:

cameo.core.manipulation.
swap_cofactors
(reaction, model, swap_pairs, inplace=True)[source]¶ Swaps the cofactors of a reaction. For speed, it can be done inplace which just changes the coefficients. If not done inplace, it will create a new Reaction, add it to the model, and knockout the original reaction.
Parameters:  reaction (cobra.Reaction) – The reaction to swap.
 model (cameo.cobra.Model) – A constraintbased model.
 swap_pairs (tuple) – A tuple of (cofactors, equivalent_cofactors)
 inplace (bool) – If replace is done inplace, it changes the coefficients in the matrix. Otherwise, it creates a new reaction with the other cofactors and adds it to the model.
Returns: A reaction with swapped cofactors (the same if inplace).
Return type: Reaction
cameo.core.model_dual module¶

class
cameo.core.model_dual.
ModelDual
(*args, **kwargs)[source]¶ Bases:
cobra.core.model.Model
A cobra.Model that also contains the dual variables and constraints, allowing primal and dual problems to be combined.
Dual variables corresponding to stoichiometric constraints are prefixed by lambda Dual variables corresponding to flux bounds are prefixed by mu Other constraints are not supported at the moment!
Dual constraints will be set according to the original primal objective. The objective can be changed subsequently to optimize an outer problem.
Attributes: boundary
Boundary reactions in the model.
 compartments
constraints
The constraints in the cobra model.
demands
Demand reactions in model.
 description
 dual_objective
exchanges
Exchange reactions in model.
 id
 medium
objective
Get or set the solver objective
objective_direction
Get or set the objective direction.
problem
The interface to the model’s underlying mathematical problem.
sinks
Sink reactions in model.
solver
Get or set the attached solver instance.
variables
The mathematical variables in the cobra model.
Methods
add_boundary
(metabolite[, type, …])Add a boundary reaction for a given metabolite. add_cons_vars
(what, **kwargs)Add constraints and variables to the model’s mathematical problem. add_metabolites
(metabolite_list)Will add a list of metabolites to the model object and add new constraints accordingly. add_reaction
(reaction)Will add a cobra.Reaction object to the model, if reaction.id is not in self.reactions. add_reactions
(reaction_list)Add reactions to the model. copy
()Provides a partial ‘deepcopy’ of the Model. get_metabolite_compartments
()Return all metabolites’ compartments. merge
(right[, prefix_existing, inplace, …])Merge two models to create a model with the reactions from both models. optimize
([objective_sense, raise_error])Optimize the model using flux balance analysis. remove_cons_vars
(what)Remove variables and constraints from the model’s mathematical problem. remove_metabolites
(metabolite_list[, …])Remove a list of metabolites from the the object. remove_reactions
(reactions[, remove_orphans])Remove reactions from the model. repair
([rebuild_index, rebuild_relationships])Update all indexes and pointers in a model slim_optimize
([error_value, message])Optimize model without creating a solution object. summary
([solution, threshold, fva, names, …])Print a summary of the input and output fluxes of the model. primal_objective 
objective
¶ Get or set the solver objective
Before introduction of the optlang based problems, this function returned the objective reactions as a list. With optlang, the objective is not limited a simple linear summation of individual reaction fluxes, making that return value ambiguous. Henceforth, use
cobra.util.solver.linear_reaction_coefficients
to get a dictionary of reactions with their linear coefficients (empty if there are none)The set value can be dictionary (reactions as keys, linear coefficients as values), string (reaction identifier), int (reaction index), Reaction or problem.Objective or sympy expression directly interpreted as objectives.
When using a
HistoryManager
context, this attribute can be set temporarily, reversed when the exiting the context.

dual_objective
¶
cameo.core.pathway module¶
This module implements a pathway data structure that can be added to a model for example.

class
cameo.core.pathway.
Pathway
(reactions, *args, **kwargs)[source]¶ Bases:
object
Representation of a pathway (a set of reactions)

reactions
¶ The list of reactions in the pathway.
Type: list o Reaction
Attributes:  data_frame
Methods
from_file
(file_path[, sep])Read a pathway from a file. plug_model
(model)Plugs the pathway to a model. to_file
(file_path[, sep])Writes the pathway to a file. 
data_frame
¶

classmethod
from_file
(file_path, sep='\t')[source]¶ Read a pathway from a file. The file format is: reaction_id<sep>equation<sep>lower_limit<sep>upper_limit<sep>name<sep>comments
The equation is defined by: coefficient * substrate_name#substrate_id + … <=> coefficient * product_name#product_id
Parameters: Returns: Return type:

cameo.core.result module¶
cameo.core.strain_design module¶
Core implementation of strain design. It contains core structures. Targets (and subclasses) are identified by strain design methods.

class
cameo.core.strain_design.
StrainDesignMethod
(*args, **kwargs)[source]¶ Bases:
object
Methods
__call__
(*args, **kwargs)Call self as a function. run

class
cameo.core.strain_design.
StrainDesign
(targets)[source]¶ Bases:
object
A StrainDesign is a collection of targets in a COBRA model. The targets, identified by a StrainDesignMethod, map elements in the model that need to be modified to achieve the objective of the design method.
Methods
apply to_gnomic

class
cameo.core.strain_design.
StrainDesignMethodResult
(designs, *args, **kwargs)[source]¶ Bases:
cameo.core.result.Result
Attributes:  data_frame
 meta_information
Methods
display_on_map plot 
data_frame
¶
cameo.core.target module¶

class
cameo.core.target.
ReactionCofactorSwapTarget
(id, swap_pairs, *args, **kwargs)[source]¶ Bases:
cameo.core.target.Target
Swap cofactors of a given reaction.
Attributes:  swap_str
Methods
apply
(model)Applies the modification on the target, depending on the target type. to_gnomic
()If gnomic is available, return a Gnomic representation of the Target. 
apply
(model)[source]¶ Applies the modification on the target, depending on the target type.
See also
Subclass()

swap_str
¶

class
cameo.core.target.
ReactionKnockinTarget
(id, value, *args, **kwargs)[source]¶ Bases:
cameo.core.target.KnockinTarget
Methods
apply
(model)Applies the modification on the target, depending on the target type. to_gnomic
()If gnomic is available, return a Gnomic representation of the Target.

class
cameo.core.target.
GeneModulationTarget
(id, value, reference_value, *args, **kwargs)[source]¶ Bases:
cameo.core.target.FluxModulationTarget
Attributes: fold_change
(B  A)/A
Methods
apply
(model)Applies a change to the flux. to_gnomic
()If gnomic is available, return a Gnomic representation of the Target. get_model_target

class
cameo.core.target.
GeneKnockoutTarget
(id, *args, **kwargs)[source]¶ Bases:
cameo.core.target.GeneModulationTarget
Gene Knockout Target. Knockout a gene present in a COBRA model.
Attributes: fold_change
(B  A)/A
Methods
apply
(model)Applies a change to the flux. to_gnomic
()If gnomic is available, return a Gnomic representation of the Target. get_model_target

class
cameo.core.target.
ReactionModulationTarget
(id, value, reference_value)[source]¶ Bases:
cameo.core.target.FluxModulationTarget
Attributes: fold_change
(B  A)/A
Methods
apply
(model)Applies a change to the flux. to_gnomic
()If gnomic is available, return a Gnomic representation of the Target. get_model_target

class
cameo.core.target.
ReactionKnockoutTarget
(id)[source]¶ Bases:
cameo.core.target.ReactionModulationTarget
Reaction Knockout Target. Knockout a reaction present in a COBRA model.
Attributes: fold_change
(B  A)/A
Methods
apply
(model)Applies a change to the flux. to_gnomic
()If gnomic is available, return a Gnomic representation of the Target. get_model_target
cameo.core.utils module¶

cameo.core.utils.
get_reaction_for
(model, value, add=True)[source]¶ Get or create a reaction for a metabolite or a reaction.
If value is a Metabolite or a Metabolite id, return any already existing demand or exchange reaction. If add is true, add a demand reaction if it does not already exist.
Parameters: Returns: Return type: Reaction
Raises: KeyError
– If value does not match any Reaction or Metabolite

cameo.core.utils.
load_medium
(model, medium_def, copy=False, delimiter='\t')[source]¶ Loads a medium into the model. If copy is true it will return a copy of the model. Otherwise it applies the medium to itself. Supported formats TODO
Parameters: Returns: If copy=True, returns a copy of the model.
Return type: cobra.Model
Module contents¶
This package implements the basic data structures (models, reactions etc.) used in cameo.