# cameo.core package¶

## cameo.core.manipulation module¶

Manage manipulations such as swapping reaction cofactors, over-express or down-regulate genes and reactions.

cameo.core.manipulation.increase_flux(reaction, ref_value, value)[source]

lb 0 ub |--------------------------- ' ---------------------------|

<- - -|———-‘
‘———-|- - - ->
Parameters: reaction (cobra.Reaction) – The reaction to over-express. ref_value (float) – The flux value to come from. value (float) – The flux value to achieve.
cameo.core.manipulation.decrease_flux(reaction, ref_value, value)[source]

lb 0 ub |--------------------------- ' ---------------------------|

|- - >———-‘
‘———-<- - - -|
Parameters: reaction (cobra.Reaction) – The reaction to down_regulate. ref_value (float) – The flux value to come from. value (float) – The flux value to achieve.
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: reaction (cobra.Reaction) – The reaction that will be inverted. ref_value (float) – The flux value to come from. value (float) – The flux value to achieve.
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 constraint-based 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. A reaction with swapped cofactors (the same if inplace). Reaction

## cameo.core.model_dual module¶

cameo.core.model_dual.convert_to_dual(model)[source]
cameo.core.model_dual.to_dual_model(model, solver_interface=None)[source]
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
primal_objective()[source]

## 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]

The equation is defined by: coefficient * substrate_name#substrate_id + … <=> coefficient * product_name#product_id

Parameters: file_path (str) – The path to the file containing the pathway sep (str) – The separator between elements in the file (default: ” “) Pathway
to_file(file_path, sep='\t')[source]

Writes the pathway to a file.

Parameters: file_path (str) – The path to the file where the pathway will be written sep (str) – The separator between elements in the file (default: ” “)
plug_model(model)[source]

Plugs the pathway to a model.

Metabolites are matched in the model by id. For metabolites with no ID in the model, an exchange reaction is added to the model

Parameters: model (cobra.Model) – The model to plug in the pathway

## cameo.core.result module¶

class cameo.core.result.MetaInformation(*args, **kwargs)[source]

Bases: object

Attributes: human_readable_timestamp responsible system_info timestamp doc string
system_info
responsible
timestamp

doc string

human_readable_timestamp
class cameo.core.result.Result(*args, **kwargs)[source]

Bases: object

Attributes: data_frame meta_information

Methods

 plot
meta_information
data_frame
plot(grid=None, width=None, height=None, title=None, *args, **kwargs)[source]

## 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
run(*args, **kwargs)[source]
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
apply(model)[source]
to_gnomic()[source]
class cameo.core.strain_design.StrainDesignMethodResult(designs, *args, **kwargs)[source]
Attributes: data_frame meta_information

Methods

 display_on_map plot
data_frame
display_on_map(index, map_name)[source]
plot(grid=None, width=None, height=None, title=None, *args, **kwargs)[source]

## 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.

Subclass()

swap_str
to_gnomic()[source]

If gnomic is available, return a Gnomic representation of the Target.

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.
apply(model)[source]

Applies the modification on the target, depending on the target type.

Subclass()

to_gnomic()[source]

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
get_model_target(model)[source]
class cameo.core.target.GeneKnockoutTarget(id, *args, **kwargs)[source]

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
apply(model)[source]

Applies a change to the flux. If the fold change is higher than 0 it increases the flux. If the target flux is zero it applies a knockout. If the fold change is lower than 0, then it decreases the flux.

Parameters: model (cobra.Model) – A model.
to_gnomic()[source]

If gnomic is available, return a Gnomic representation of the 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
get_model_target(model)[source]
class cameo.core.target.ReactionKnockoutTarget(id)[source]

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
apply(model)[source]

Applies a change to the flux. If the fold change is higher than 0 it increases the flux. If the target flux is zero it applies a knockout. If the fold change is lower than 0, then it decreases the flux.

Parameters: model (cobra.Model) – A model.

## 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: model (cobra.Model) – The model to for which to get / create a reaction value (str, Reaction or Metabolite) – A reaction identifier, a Reaction or a Metabolite for which an exchange reaction is to be created. add (bool) – Adds a demand reaction for a metabolite if a metabolite is found for value Reaction KeyError – If value does not match any Reaction or Metabolite
cameo.core.utils.medium(model)[source]

Current medium for this model.

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: model (cobra.Model) – The model to load medium for medium_def (str, pandas.DataFrame, dict.) – The medium to load copy (boolean, optional) – If True copies the model, otherwise the changes will happen inplace. delimiter (str) – Only if loading the medium from a file. If copy=True, returns a copy of the model. cobra.Model

## Module contents¶

This package implements the basic data structures (models, reactions etc.) used in cameo.