cameo package¶
Subpackages¶
- cameo.api package
- cameo.core package
- Submodules
- cameo.core.gene module
- cameo.core.manipulation module
- cameo.core.metabolite module
- cameo.core.pathway module
- cameo.core.reaction module
- cameo.core.result module
- cameo.core.solution module
- cameo.core.solver_based_model module
- cameo.core.solver_based_model_dual module
- cameo.core.strain_design module
- cameo.core.target module
- Module contents
- cameo.data package
- cameo.flux_analysis package
- cameo.models package
- cameo.network_analysis package
- cameo.strain_design package
- cameo.ui package
- cameo.visualization package
Submodules¶
cameo.config module¶
cameo.exceptions module¶
-
exception
cameo.exceptions.
Infeasible
(message)[source]¶ Bases:
cameo.exceptions.SolveError
-
exception
cameo.exceptions.
Unbounded
(message)[source]¶ Bases:
cameo.exceptions.SolveError
-
exception
cameo.exceptions.
FeasibleButNotOptimal
(message)[source]¶ Bases:
cameo.exceptions.SolveError
-
exception
cameo.exceptions.
UndefinedSolution
(message)[source]¶ Bases:
cameo.exceptions.SolveError
cameo.io module¶
-
cameo.io.
load_model
(path_or_handle, solver_interface=<module ‘optlang’ from ‘/home/travis/virtualenv/python3.6.1/lib/python3.6/site-packages/optlang/__init__.py’>, sanitize=True)[source]¶ Read a metabolic model .
Parameters: - path_or_handle (path, fhandle or name.) –
- One of:
- file path of a model file;
- file handle to a SBML or pickled model; or
- the identifier of a model in a web database (optflux.org/models)
- solver_interface (solver_interface, optional) – E.g. optlang.glpk_interface or any other optlang interface.
- sanitize (boolean, optional) – If reaction and metabolite IDs should be sanitized (works only for SBML models).
- path_or_handle (path, fhandle or name.) –
-
cameo.io.
sanitize_ids
(model)[source]¶ Makes IDs crippled by the XML specification less annoying.
For example, EX_glc_LPAREN_e_RPAREN_ will be converted to EX_glc_lp_e_rp_. Furthermore, reactions and metabolites will be equipped with a nice_id attribute that provides the original ID, i.e., EX_glc(d).
Parameters: model (model) – Notes
Will add a nice_id attribute.
cameo.parallel module¶
-
class
cameo.parallel.
MultiprocessingView
(processes=2, **kwargs)[source]¶ Bases:
cameo.util.Singleton
Provides a parallel view (similar to IPython)
Attributes
Methods
-
pool
¶
-
cameo.util module¶
-
class
cameo.util.
frozendict
() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)[source]¶ Bases:
dict
Methods
-
cameo.util.
float_ceil
(val, decimals=0)[source]¶ Like ceil but the number of decimals can be set.
Equivalent of $$round(val + 1e^{-decimals}/2, decimals)$$
- val: float, numpy.array
- The initial value.
- decimals: int
- The number of decimal places.
Returns: Return type: float, numpy.array
-
cameo.util.
float_floor
(val, decimals=0)[source]¶ Like floor but the number of decimals can be set.
Equivalent of $$round(val - 1e^{-decimals}/2, decimals)$$
- val: float, numpy.array
- The initial value.
- decimals: int
- The number of decimal places.
Returns: Return type: float, numpy.array
-
class
cameo.util.
ProblemCache
(model)[source]¶ Bases:
object
Variable and constraint cache for models.
To be used in complex methods that require many extra variables and constraints when one must run simulations with the same method many times.
It allows rollback to the previous state in case one iteration fails to build the problem or generates an invalid state.
Attributes
Methods
-
begin_transaction
()[source]¶ Creates a time point. If rollback is called, the variables and constrains will be reverted to this point.
-
model
¶
-
add_constraint
(constraint_id, create, update, *args, **kwargs)[source]¶ Adds a new cached constraint.
The create and update functions must have the following signatures: >>> create(model, constraint_id, *args) >>> update(model, constraint, *args)
“args” in the first example must match args on the second example.
Parameters: - constraint_id (str) – The identifier of the constraint
- create (function) – A function that creates an optlang.interface.Constraint
- update (function) – a function that updates an optlang.interface.Constraint
-
add_variable
(variable_id, create, update, *args, **kwargs)[source]¶ Adds a new cached variable.
The create and update functions must have the following signatures: >>> create(model, variable_id, *args) >>> update(model, variable, *args)
“args” in the first example must match args on the second example.
Parameters: - constraint_id (str) – The identifier of the constraint
- create (function) – A function that creates an optlang.interface.Variable
- update (function) – a function that updates an optlang.interface.Variable
-
-
class
cameo.util.
AutoVivification
[source]¶ Bases:
dict
Implementation of perl’s autovivification feature. Checkout http://stackoverflow.com/a/652284/280182
Methods
-
class
cameo.util.
Timer
(name=None)[source]¶ Bases:
object
Taken from http://stackoverflow.com/a/5849861/280182
-
cameo.util.
inheritdocstring
(name, bases, attrs)[source]¶ Use as metaclass to inherit class and method docstrings from parent. Adapted from http://stackoverflow.com/questions/13937500/inherit-a-parent-class-docstring-as-doc-attribute
-
cameo.util.
in_ipnb
()[source]¶ Check if it is running inside an IPython Notebook (updated for new notebooks)
-
cameo.util.
str_to_valid_variable_name
(s)[source]¶ Adapted from http://stackoverflow.com/a/3303361/280182
-
cameo.util.
zip_repeat
(long_iter, short_iter)[source]¶ Zips two iterable objects but repeats the second one if it is shorter than the first one.
Parameters: - long_iter (iterable) –
- short_iter (iterable) –
Returns: Return type: generator
-
cameo.util.
pick_one
(iterable)[source]¶ Helper function that returns an element of an iterable (it the iterable is ordered this will be the first element).
-
cameo.util.
reduce_reaction_set
(reaction_set, groups)[source]¶ Reduces a set of reactions according to a number of groups of reactions. The reduction will be performed so that the resulting set will contain no more than 1 reaction from each group. Reactions that are not in any of the groups will remain in the set.
Parameters: - reaction_set (Set) –
- groups (Iterable of sets) –
Returns: Return type: Set
Module contents¶
CAMEO: Computer Aided Metabolic Engineering & Optimization
Cameo is a high-level python library developed to aid the in silico strain design process in metabolic engineering projects. The library provides a modular architecture that enables the efficient construction of custom analysis workflows.
Example
from cameo import load_model
# load a model from SBML format (can be found under cameo/tests/data) model = load_model(‘EcoliCore.xml’)
# solve the model and print the objective value solution = model.solve() print ‘Objective value:’, solution.f
# Determine a set of gene deletions that will optimize the production # of a desired compound from cameo.strain_design.heuristic import GeneKnockoutOptimization from cameo.strain_design.heuristic.objective_functions import biomass_product_coupled_yield from cameo.flux_analysis.simulation import fba
- objective = biomass_product_coupled_yield(“Ec_biomass_iJO1366_core_53p95M”,
- “EX_succ_lp_e_rp_”, “EX_glc_lp_e_rp_”)
- optimization = GeneKnockoutOptimization(model=model, objective_function=of,
- simulation_method=fba, heuristic_method=inspyred.ec.GA)
- optimization.run(max_evaluations=2000, n=1,
- mutation_rate=0.3, view=cameo.parallel.SequentialView(), product=”EX_succ_lp_e_rp_”, num_elites=1)