diff --git a/README.md b/README.md index 434fd8063..dc433fe94 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![Documentation Status](https://readthedocs.org/projects/cameo/badge/?version=latest)](https://readthedocs.org/projects/cameo/?badge=latest) ### Vision -Provide a high-level python library to aid _in silico_ strain design process in metabolic engineering projects. The library provides a modular architecture that enables the efficient construction of custom analysis workflows. +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. ### Dependencies This library depends on: diff --git a/benchmarks/common.py b/benchmarks/common.py index b084a2146..6f4bdd759 100644 --- a/benchmarks/common.py +++ b/benchmarks/common.py @@ -1,11 +1,11 @@ # Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/benchmarks/flux_analysis.py b/benchmarks/flux_analysis.py index f0536fc79..5714f4712 100644 --- a/benchmarks/flux_analysis.py +++ b/benchmarks/flux_analysis.py @@ -1,11 +1,11 @@ # Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/benchmarks/model.py b/benchmarks/model.py index b85db20b1..52249c036 100644 --- a/benchmarks/model.py +++ b/benchmarks/model.py @@ -1,11 +1,11 @@ # Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/benchmarks/run.py b/benchmarks/run.py index 5629c9a32..71d25ae24 100644 --- a/benchmarks/run.py +++ b/benchmarks/run.py @@ -1,11 +1,11 @@ # Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/benchmarks/suite.py b/benchmarks/suite.py index 257c6f94f..0af91e6dc 100644 --- a/benchmarks/suite.py +++ b/benchmarks/suite.py @@ -1,11 +1,11 @@ # Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/cameo/__init__.py b/cameo/__init__.py index 40789e4f4..5476c0d76 100644 --- a/cameo/__init__.py +++ b/cameo/__init__.py @@ -1,11 +1,11 @@ # Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,11 +16,36 @@ """ CAMEO: Computer Assisted 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 -model = load_model('../tests/data/EcoliCore.xml') +# 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) """ from ._version import get_versions diff --git a/cameo/config.py b/cameo/config.py index 26149c780..a9d15b050 100644 --- a/cameo/config.py +++ b/cameo/config.py @@ -1,11 +1,11 @@ # Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/cameo/exceptions.py b/cameo/exceptions.py index 4ccc964ce..5baa8b627 100644 --- a/cameo/exceptions.py +++ b/cameo/exceptions.py @@ -1,11 +1,11 @@ # Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/cameo/flux_analysis/__init__.py b/cameo/flux_analysis/__init__.py index 0209c0302..c82f9553d 100644 --- a/cameo/flux_analysis/__init__.py +++ b/cameo/flux_analysis/__init__.py @@ -1,52 +1,18 @@ # Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from functools import partial -from cobra.manipulation.delete import find_gene_knockout_reactions -from cameo.flux_analysis.simulation import fba -from cameo.exceptions import SolveError -from cameo.util import TimeMachine - - -def gene_knockout_growth(gene_id, model, threshold=10 ** -6, simulation_method=fba, - normalize=True, biomass=None, biomass_flux=None, *args, **kwargs): - - if biomass_flux is None: - s = model.solve() - biomass_flux = s.f - if not 'reference' in kwargs: - kwargs['reference'] = s.x_dict - gene = model.genes.get_by_id(gene_id) - knockouts = find_gene_knockout_reactions(model, [gene]) - tm = TimeMachine() - for reaction in knockouts: - tm(do=partial(setattr, reaction, 'lower_bound', 0), - undo=partial(setattr, reaction, 'lower_bound', reaction.lower_bound)) - tm(do=partial(setattr, reaction, 'upper_bound', 0), - undo=partial(setattr, reaction, 'upper_bound', reaction.upper_bound)) +from .simulation import * +from .analysis import * - try: - s = simulation_method(model, *args, **kwargs) - f = s.get_primal_by_id(biomass) - if f >= threshold: - if normalize: - f = f / biomass_flux - else: - f = 0 - except SolveError: - f = float('nan') - finally: - tm.reset() - return f \ No newline at end of file diff --git a/cameo/flux_analysis/analysis.py b/cameo/flux_analysis/analysis.py index 5887b4e70..934ea507c 100644 --- a/cameo/flux_analysis/analysis.py +++ b/cameo/flux_analysis/analysis.py @@ -1,23 +1,24 @@ # Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +__all__ = ['flux_variability_analysis', 'phenotypic_phase_plane', 'fbid'] + import itertools from copy import copy from collections import OrderedDict from functools import partial import numpy -from cobra.core import Reaction from cameo import config from cameo.exceptions import UndefinedSolution, Infeasible, Unbounded, SolveError from cameo.util import TimeMachine, partition @@ -358,7 +359,7 @@ def _production_envelope_inner(self, point): return point + tuple(interval) -def fbip(model, knockouts, view=config.default_view, method="fva"): +def fbid(model, knockouts, view=config.default_view, method="fva"): """ Flux balance impact degree by Zhao et al 2013 @@ -370,14 +371,14 @@ def fbip(model, knockouts, view=config.default_view, method="fva"): """ if method == "fva": - _fbip_fva(model, knockouts, view) + _fbid_fva(model, knockouts, view) elif method == "em": raise NotImplementedError("Elementary modes approach is not implemented") else: raise ValueError("%s method is not valid to compute FBIP" % method) -def _fbip_fva(model, knockouts, view): +def _fbid_fva(model, knockouts, view): tm = TimeMachine() for reaction in model.reactions: if reaction.reversibility: @@ -409,23 +410,6 @@ def _fbip_fva(model, knockouts, view): return perturbation -def reaction_component_production(model, reaction): - tm = TimeMachine() - for metabolite in reaction.metabolites: - test = Reaction("EX_%s_temp" % metabolite.id) - test._metabolites[metabolite] = -1 - # hack frozen set from cobrapy to be able to add a reaction - metabolite._reaction = set(metabolite._reaction) - tm(do=partial(model.add_reactions, [test]), undo=partial(model.remove_reactions, [test])) - tm(do=partial(setattr, model, 'objective', test.id), undo=partial(setattr, model, 'objective', model.objective)) - try: - print metabolite.id, "= ", model.solve().f - except SolveError: - print metabolite, " cannot be produced (reactions: %s)" % metabolite.reactions - finally: - tm.reset() - - if __name__ == '__main__': import time from cameo import load_model diff --git a/cameo/flux_analysis/simulation.py b/cameo/flux_analysis/simulation.py index 9e81f4e95..55d68c3a2 100644 --- a/cameo/flux_analysis/simulation.py +++ b/cameo/flux_analysis/simulation.py @@ -1,16 +1,19 @@ # Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +__all__ = ['fba', 'pfba', 'moma', 'lmoma', 'room'] + import sympy from functools import partial diff --git a/cameo/io.py b/cameo/io.py index f89a0ce94..51c0c0774 100644 --- a/cameo/io.py +++ b/cameo/io.py @@ -1,11 +1,11 @@ # Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/cameo/parallel.py b/cameo/parallel.py index 97e2de24e..44144caff 100644 --- a/cameo/parallel.py +++ b/cameo/parallel.py @@ -4,7 +4,7 @@ # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, diff --git a/cameo/solver_based_model.py b/cameo/solver_based_model.py index fdbb2ba7f..18fd86b4a 100644 --- a/cameo/solver_based_model.py +++ b/cameo/solver_based_model.py @@ -5,7 +5,7 @@ # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, diff --git a/cameo/strain_design/__init__.py b/cameo/strain_design/__init__.py index b6a0df6c8..b01e1f9a3 100644 --- a/cameo/strain_design/__init__.py +++ b/cameo/strain_design/__init__.py @@ -1,11 +1,11 @@ # Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/cameo/strain_design/deterministic/__init__.py b/cameo/strain_design/deterministic/__init__.py index 50fa318b2..06b0edd59 100644 --- a/cameo/strain_design/deterministic/__init__.py +++ b/cameo/strain_design/deterministic/__init__.py @@ -1,11 +1,11 @@ # Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/cameo/strain_design/heuristic/__init__.py b/cameo/strain_design/heuristic/__init__.py index d0702bf86..2c27b5a34 100644 --- a/cameo/strain_design/heuristic/__init__.py +++ b/cameo/strain_design/heuristic/__init__.py @@ -1,16 +1,20 @@ # Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + + +__all__ = ['KnockoutOptimizationResult', 'GeneOptimizationResult'] + from cobra.manipulation.delete import find_gene_knockout_reactions from inspyred.ec.emo import Pareto import time @@ -133,7 +137,7 @@ def __init__(self, model=None, heuristic_method=inspyred.ec.GA, objective_functi super(HeuristicOptimization, self).__init__(*args, **kwargs) logger.debug("Seed: %s" % seed) if seed is None: - seed = int(round(time.time() * 1000)) + seed = int(time.time()) self.seed = seed self.random = Random(seed=seed) self.model = model diff --git a/cameo/strain_design/heuristic/archivers.py b/cameo/strain_design/heuristic/archivers.py index 21e175f81..6489545d5 100644 --- a/cameo/strain_design/heuristic/archivers.py +++ b/cameo/strain_design/heuristic/archivers.py @@ -1,11 +1,11 @@ # Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,7 +21,6 @@ def __init__(self): self.worst_fitness = None self.archive = [] - def __call__(self, random, population, archive, args): self.archive = archive size = args.get('max_archive_size', 100) diff --git a/cameo/strain_design/heuristic/decoders.py b/cameo/strain_design/heuristic/decoders.py index 9ed88dc1e..4233ff70d 100644 --- a/cameo/strain_design/heuristic/decoders.py +++ b/cameo/strain_design/heuristic/decoders.py @@ -1,11 +1,11 @@ # Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/cameo/strain_design/heuristic/generators.py b/cameo/strain_design/heuristic/generators.py index 403745658..7a0d70e29 100644 --- a/cameo/strain_design/heuristic/generators.py +++ b/cameo/strain_design/heuristic/generators.py @@ -1,11 +1,11 @@ # Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/cameo/strain_design/heuristic/genomes.py b/cameo/strain_design/heuristic/genomes.py index 867341ef5..9247c3c4b 100644 --- a/cameo/strain_design/heuristic/genomes.py +++ b/cameo/strain_design/heuristic/genomes.py @@ -1,11 +1,11 @@ # Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/cameo/strain_design/heuristic/metrics.py b/cameo/strain_design/heuristic/metrics.py index 1f15a6a41..84a8ed5ed 100644 --- a/cameo/strain_design/heuristic/metrics.py +++ b/cameo/strain_design/heuristic/metrics.py @@ -1,20 +1,22 @@ # Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +from math import sqrt + + +def wild_type_euclidean_distance(wt, mutant): + return sqrt(sum([(wt[r] - mutant[r])^2 for r in wt.keys()])) -def distance(knockouts, model, simulation_method, **simulation_args): - wt = simulation_args.get("reference", None) - if wt is None: - wt = model.solve().x_dict - \ No newline at end of file +def wild_type_manhattan_distance(wt, mutant): + return sum([(wt[r] - mutant[r]) for r in wt.keys()]) \ No newline at end of file diff --git a/cameo/strain_design/heuristic/multiprocess/__init__.py b/cameo/strain_design/heuristic/multiprocess/__init__.py index 7d8b6d70a..ee14a05e4 100644 --- a/cameo/strain_design/heuristic/multiprocess/__init__.py +++ b/cameo/strain_design/heuristic/multiprocess/__init__.py @@ -1,16 +1,19 @@ # Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +__all__ = ['MultiprocessReactionKnockoutOptimization', 'MultiprocessGeneKnockoutOptimization'] + import inspyred from pandas.core.common import in_ipnb diff --git a/cameo/strain_design/heuristic/multiprocess/migrators.py b/cameo/strain_design/heuristic/multiprocess/migrators.py index 552681221..a828ab921 100644 --- a/cameo/strain_design/heuristic/multiprocess/migrators.py +++ b/cameo/strain_design/heuristic/multiprocess/migrators.py @@ -1,11 +1,11 @@ # Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/cameo/strain_design/heuristic/multiprocess/observers.py b/cameo/strain_design/heuristic/multiprocess/observers.py index f4e20c0b5..537c4815a 100644 --- a/cameo/strain_design/heuristic/multiprocess/observers.py +++ b/cameo/strain_design/heuristic/multiprocess/observers.py @@ -1,11 +1,11 @@ # Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/cameo/strain_design/heuristic/multiprocess/plotters.py b/cameo/strain_design/heuristic/multiprocess/plotters.py index 120dad69a..d26fee5fa 100644 --- a/cameo/strain_design/heuristic/multiprocess/plotters.py +++ b/cameo/strain_design/heuristic/multiprocess/plotters.py @@ -1,11 +1,11 @@ # Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/cameo/strain_design/heuristic/objective_functions.py b/cameo/strain_design/heuristic/objective_functions.py index 6a8985399..1b10bac9c 100644 --- a/cameo/strain_design/heuristic/objective_functions.py +++ b/cameo/strain_design/heuristic/objective_functions.py @@ -1,23 +1,26 @@ # -*- coding: utf-8 -*- # Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +__all__ = ['biomass_product_coupled_yield', 'product_yield', 'number_of_knockouts'] + from cobra import Reaction from cameo import config -class objective_function(object): +class ObjectiveFunction(object): """ Blueprint for objective function. @@ -31,13 +34,13 @@ class objective_function(object): """ def __init__(self, *args, **kwargs): - super(objective_function, self).__init__(*args, **kwargs) + super(ObjectiveFunction, self).__init__(*args, **kwargs) def __call__(self, model, solution, decoded_representation): raise NotImplementedError -class biomass_product_coupled_yield(objective_function): +class biomass_product_coupled_yield(ObjectiveFunction): """ Biomass-Product Coupled Yield: (v[biomass] * v[product]) / v[substrate] [1] @@ -89,7 +92,7 @@ def _repr_latex_(self): return "$$bpcy = \\frac{(%s * %s)}{%s}$$" % (self.biomass.replace("_", "\\_"), self.product.replace("_", "\\_"), self.substrate.replace("_", "\\_")) -class product_yield(objective_function): +class product_yield(ObjectiveFunction): """ Product Yield Objective function: v[product]/v[substrate] @@ -122,7 +125,7 @@ def _repr_latex_(self): return "$$yield = \\frac{%s}{%s}$$" % (self.product, self.substrate) -class number_of_knockouts(objective_function): +class number_of_knockouts(ObjectiveFunction): """ Number of Knockouts objective function. If sense is maximize then fitness is the number of knockouts, otherwise 1/#knockouts diff --git a/cameo/strain_design/heuristic/observers.py b/cameo/strain_design/heuristic/observers.py index c0ec2d13e..835582e30 100644 --- a/cameo/strain_design/heuristic/observers.py +++ b/cameo/strain_design/heuristic/observers.py @@ -1,11 +1,11 @@ # Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/cameo/strain_design/heuristic/plotters.py b/cameo/strain_design/heuristic/plotters.py index e7d489790..158a63edc 100644 --- a/cameo/strain_design/heuristic/plotters.py +++ b/cameo/strain_design/heuristic/plotters.py @@ -2,7 +2,7 @@ # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, diff --git a/cameo/strain_design/heuristic/stats.py b/cameo/strain_design/heuristic/stats.py index 6df3c1c57..c77c17a95 100644 --- a/cameo/strain_design/heuristic/stats.py +++ b/cameo/strain_design/heuristic/stats.py @@ -1,11 +1,11 @@ # Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/cameo/strain_design/heuristic/variators.py b/cameo/strain_design/heuristic/variators.py index 09540b669..e759ea405 100644 --- a/cameo/strain_design/heuristic/variators.py +++ b/cameo/strain_design/heuristic/variators.py @@ -1,11 +1,11 @@ # Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/cameo/stuff.py b/cameo/stuff.py new file mode 100644 index 000000000..83e92177c --- /dev/null +++ b/cameo/stuff.py @@ -0,0 +1,70 @@ +# Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from functools import partial +from cobra.manipulation.delete import find_gene_knockout_reactions +from cobra.core import Reaction +from cameo.flux_analysis.simulation import fba +from cameo.exceptions import SolveError +from cameo.util import TimeMachine + + +def gene_knockout_growth(gene_id, model, threshold=10 ** -6, simulation_method=fba, + normalize=True, biomass=None, biomass_flux=None, *args, **kwargs): + + if biomass_flux is None: + s = model.solve() + biomass_flux = s.f + if not 'reference' in kwargs: + kwargs['reference'] = s.x_dict + gene = model.genes.get_by_id(gene_id) + knockouts = find_gene_knockout_reactions(model, [gene]) + tm = TimeMachine() + + for reaction in knockouts: + tm(do=partial(setattr, reaction, 'lower_bound', 0), + undo=partial(setattr, reaction, 'lower_bound', reaction.lower_bound)) + tm(do=partial(setattr, reaction, 'upper_bound', 0), + undo=partial(setattr, reaction, 'upper_bound', reaction.upper_bound)) + + try: + s = simulation_method(model, *args, **kwargs) + f = s.get_primal_by_id(biomass) + if f >= threshold: + if normalize: + f = f / biomass_flux + else: + f = 0 + except SolveError: + f = float('nan') + finally: + tm.reset() + + return f + +def reaction_component_production(model, reaction): + tm = TimeMachine() + for metabolite in reaction.metabolites: + test = Reaction("EX_%s_temp" % metabolite.id) + test._metabolites[metabolite] = -1 + # hack frozen set from cobrapy to be able to add a reaction + metabolite._reaction = set(metabolite._reaction) + tm(do=partial(model.add_reactions, [test]), undo=partial(model.remove_reactions, [test])) + tm(do=partial(setattr, model, 'objective', test.id), undo=partial(setattr, model, 'objective', model.objective)) + try: + print metabolite.id, "= ", model.solve().f + except SolveError: + print metabolite, " cannot be produced (reactions: %s)" % metabolite.reactions + finally: + tm.reset() diff --git a/cameo/util.py b/cameo/util.py index 16d30bd4b..29ed66736 100644 --- a/cameo/util.py +++ b/cameo/util.py @@ -1,11 +1,11 @@ # Copyright 2013 Novo Nordisk Foundation Center for Biosustainability, DTU. - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - +# # http://www.apache.org/licenses/LICENSE-2.0 - +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/cameo/visualization.py b/cameo/visualization.py index be61f3102..343369dc7 100644 --- a/cameo/visualization.py +++ b/cameo/visualization.py @@ -1,16 +1,17 @@ # Copyright 2013 Novo Nordisk Foundation Center for Biosustainability, DTU. - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + import json import logging import subprocess diff --git a/cameo/webmodels.py b/cameo/webmodels.py index 6f4716483..73a4e1fe5 100644 --- a/cameo/webmodels.py +++ b/cameo/webmodels.py @@ -1,11 +1,11 @@ # Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/examples/gene_ko_so.ipynb b/examples/gene_ko_so.ipynb index 2a22c59ba..27f15e0cd 100644 --- a/examples/gene_ko_so.ipynb +++ b/examples/gene_ko_so.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:e3b24f7711504345f96838a4fdaadff16d66c798c790a6725c9578923ad080e8" + "signature": "sha256:dba5300f646e9193c1d643edeb2e4ce0f41724a5e1ec75a4c84f0b0f304ba316" }, "nbformat": 3, "nbformat_minor": 0, @@ -21,29 +21,31 @@ ], "language": "python", "metadata": {}, - "outputs": [] + "outputs": [], + "prompt_number": 2 }, { "cell_type": "code", "collapsed": false, "input": [ "model = load_model(\"../tests/data/iJO1366.xml\")\n", - "of = biomass_product_coupled_yield(\"Ec_biomass_iJO1366_core_53p95M\", \"EX_succ_LPAREN_e_RPAREN_\", \"EX_glc_LPAREN_e_RPAREN_\")" + "of = biomass_product_coupled_yield(\"Ec_biomass_iJO1366_core_53p95M\", \"EX_succ_lp_e_rp_\", \"EX_glc_lp_e_rp_\")" ], "language": "python", "metadata": {}, - "outputs": [] + "outputs": [], + "prompt_number": 7 }, { "cell_type": "code", "collapsed": false, "input": [ - "ko = GeneKnockoutOptimization(model=model, objective_function=of, \n", - " simulation_method=fba, heuristic_method=inspyred.ec.GA)" + "ko = GeneKnockoutOptimization(model=model, objective_function=of, simulation_method=fba)" ], "language": "python", "metadata": {}, - "outputs": [] + "outputs": [], + "prompt_number": 8 }, { "cell_type": "code", @@ -56,257 +58,132 @@ "language": "python", "metadata": {}, "outputs": [ - { - "html": [ - "" - ], - "metadata": {}, - "output_type": "display_data", - "text": [ - "" - ] - }, { "output_type": "stream", "stream": "stdout", "text": [ - "found config for http://localhost:5006/\n", - "{}\n", - "loading it!\n", - "if you don't wish to load this config, please pass load_from_config=False\n" - ] - }, - { - "html": [ - "

Connecting notebook to document \"ff147e66-037d-11e4-96f4-d0e1408cfa06\" at server http://localhost:5006/

" - ], - "metadata": {}, - "output_type": "display_data" - }, - { - "html": [ - "\n", - " " - ], - "metadata": {}, - "output_type": "display_data" - }, - { - "javascript": [ - "jQuery('#progress-bar-ee6685c7-c46b-4d2e-9ba6-8bf82eaea0cb').val('5')" - ], - "metadata": {}, - "output_type": "display_data", - "text": [ - "" - ] - }, - { - "javascript": [ - "jQuery('#progress-bar-ee6685c7-c46b-4d2e-9ba6-8bf82eaea0cb').val('10')" - ], - "metadata": {}, - "output_type": "display_data", - "text": [ - "" - ] - }, - { - "javascript": [ - "jQuery('#progress-bar-ee6685c7-c46b-4d2e-9ba6-8bf82eaea0cb').val('15')" - ], - "metadata": {}, - "output_type": "display_data", - "text": [ - "" - ] - }, - { - "javascript": [ - "jQuery('#progress-bar-ee6685c7-c46b-4d2e-9ba6-8bf82eaea0cb').val('20')" - ], - "metadata": {}, - "output_type": "display_data", - "text": [ - "" - ] - }, - { - "javascript": [ - "jQuery('#progress-bar-ee6685c7-c46b-4d2e-9ba6-8bf82eaea0cb').val('25')" - ], - "metadata": {}, - "output_type": "display_data", - "text": [ - "" - ] - }, - { - "javascript": [ - "jQuery('#progress-bar-ee6685c7-c46b-4d2e-9ba6-8bf82eaea0cb').val('30')" - ], - "metadata": {}, - "output_type": "display_data", - "text": [ - "" - ] - }, - { - "javascript": [ - "jQuery('#progress-bar-ee6685c7-c46b-4d2e-9ba6-8bf82eaea0cb').val('35')" - ], - "metadata": {}, - "output_type": "display_data", - "text": [ - "" + "Starting optimization at Wed, 29 Oct 2014 11:24:37\n" ] }, { "javascript": [ - "jQuery('#progress-bar-ee6685c7-c46b-4d2e-9ba6-8bf82eaea0cb').val('40')" + "//ce5ff2b1-01cf-4fda-9cfc-5caac3cb0430\n", + "$(\"head\").append(\"\")" ], "metadata": {}, "output_type": "display_data", "text": [ - "" + "" ] }, { "javascript": [ - "jQuery('#progress-bar-ee6685c7-c46b-4d2e-9ba6-8bf82eaea0cb').val('45')" + "\n", + " // ce5ff2b1-01cf-4fda-9cfc-5caac3cb0430 -- used to remove this code blob in the end\n", + " IPython.OutputArea.prototype.cleanProgressBar = function(uuids) {\n", + " // filter by uuid-strings \n", + " var myfilter = function(output) { \n", + " var nuids = uuids.length;\n", + " for (var i=0; i" + "" ] }, { - "javascript": [ - "jQuery('#progress-bar-ee6685c7-c46b-4d2e-9ba6-8bf82eaea0cb').val('50')" - ], - "metadata": {}, - "output_type": "display_data", - "text": [ - "" - ] - }, - { - "javascript": [ - "jQuery('#progress-bar-ee6685c7-c46b-4d2e-9ba6-8bf82eaea0cb').val('55')" - ], - "metadata": {}, - "output_type": "display_data", - "text": [ - "" - ] - }, - { - "javascript": [ - "jQuery('#progress-bar-ee6685c7-c46b-4d2e-9ba6-8bf82eaea0cb').val('60')" - ], - "metadata": {}, - "output_type": "display_data", - "text": [ - "" - ] - }, - { - "javascript": [ - "jQuery('#progress-bar-ee6685c7-c46b-4d2e-9ba6-8bf82eaea0cb').val('65')" - ], - "metadata": {}, - "output_type": "display_data", - "text": [ - "" - ] - }, - { - "javascript": [ - "jQuery('#progress-bar-ee6685c7-c46b-4d2e-9ba6-8bf82eaea0cb').val('70')" - ], - "metadata": {}, - "output_type": "display_data", - "text": [ - "" - ] - }, - { - "javascript": [ - "jQuery('#progress-bar-ee6685c7-c46b-4d2e-9ba6-8bf82eaea0cb').val('75')" - ], - "metadata": {}, - "output_type": "display_data", - "text": [ - "" - ] - }, - { - "javascript": [ - "jQuery('#progress-bar-ee6685c7-c46b-4d2e-9ba6-8bf82eaea0cb').val('80')" + "html": [ + "
\n", + "\n", + "\n", + "
0%
\n", + "
\n", + " \n", + "
" ], "metadata": {}, "output_type": "display_data", "text": [ - "" + "" ] }, { "javascript": [ - "jQuery('#progress-bar-ee6685c7-c46b-4d2e-9ba6-8bf82eaea0cb').val('85')" + "$('div#58e17efe-44ee-4c42-9797-f59c611f97d8').text(' 5%');" ], "metadata": {}, "output_type": "display_data", "text": [ - "" + "" ] }, { "javascript": [ - "jQuery('#progress-bar-ee6685c7-c46b-4d2e-9ba6-8bf82eaea0cb').val('90')" + "\n", + " var $myPB = $(\"div#db82843f-77c7-4c40-8d3f-b5299cb62e25\")\n", + " if ($myPB.hasClass('ui-progressbar')) {\n", + " $myPB.progressbar('value', 100);\n", + " } else {\n", + " $myPB.progressbar({value: 0, max: 2000});\n", + " }\n", + " " ], "metadata": {}, "output_type": "display_data", "text": [ - "" + "" ] }, { "javascript": [ - "jQuery('#progress-bar-ee6685c7-c46b-4d2e-9ba6-8bf82eaea0cb').val('95')" + "$('div#58e17efe-44ee-4c42-9797-f59c611f97d8').text(' 10%');" ], "metadata": {}, "output_type": "display_data", "text": [ - "" + "" ] }, { "javascript": [ - "jQuery('#progress-bar-ee6685c7-c46b-4d2e-9ba6-8bf82eaea0cb').val('100')" + "\n", + " var $myPB = $(\"div#db82843f-77c7-4c40-8d3f-b5299cb62e25\")\n", + " if ($myPB.hasClass('ui-progressbar')) {\n", + " $myPB.progressbar('value', 200);\n", + " } else {\n", + " $myPB.progressbar({value: 0, max: 2000});\n", + " }\n", + " " ], "metadata": {}, "output_type": "display_data", "text": [ - "" - ] - }, - { - "html": [ - "

Result:

  • model: iJO1366
  • heuristic: GA
  • objective function: bpcy = (Ec_biomass_iJO1366_core_53p95M * EX_succ_LPAREN_e_RPAREN_) / EX_glc_LPAREN_e_RPAREN_
  • simulation method: fba
  • type: gene
" - ], - "metadata": {}, - "output_type": "pyout", - "prompt_number": 5, - "text": [ - "" + "" ] } - ], - "prompt_number": 5 + ] }, { "cell_type": "code", diff --git a/examples/islands_model.py b/examples/islands_model.py index 685b5cf96..3af5ee5f7 100644 --- a/examples/islands_model.py +++ b/examples/islands_model.py @@ -1,11 +1,11 @@ # Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/requirements.txt b/requirements.txt index eaeb8b9ff..347efff4e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -numpy>=1.8.1 +numpy>=1.9.1 pyzmq>=14.3.1 ipython>=2.1.0 scipy>=0.9.0 diff --git a/setup.py b/setup.py index e7e70a3db..a4f6883e7 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, diff --git a/tests/test_cobrapy_compatibility.py b/tests/test_cobrapy_compatibility.py index cec424a0c..32afcf744 100644 --- a/tests/test_cobrapy_compatibility.py +++ b/tests/test_cobrapy_compatibility.py @@ -1,3 +1,17 @@ +# Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import types import nose from cobra.test import create_test_model diff --git a/tests/test_flux_analysis.py b/tests/test_flux_analysis.py index 32c03c611..a1db407ee 100644 --- a/tests/test_flux_analysis.py +++ b/tests/test_flux_analysis.py @@ -1,9 +1,19 @@ -# Copyright (c) 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. -# See LICENSE for details. - -import unittest +# Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import os +import unittest from cameo.flux_analysis.simulation import fba, pfba, lmoma from cameo.parallel import SequentialView, MultiprocessingView diff --git a/tests/test_io.py b/tests/test_io.py index e9b46d93a..6c9480ee4 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -1,9 +1,19 @@ -# Copyright (c) 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. -# See LICENSE for details. - -import unittest +# Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import os +import unittest import cobra import optlang diff --git a/tests/test_parallel.py b/tests/test_parallel.py index 3b132869c..07d0bddb1 100644 --- a/tests/test_parallel.py +++ b/tests/test_parallel.py @@ -1,8 +1,19 @@ -# Copyright (c) 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. -# See LICENSE for details. -import Queue +# Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import unittest +import Queue from cameo.parallel import SequentialView import subprocess from time import sleep diff --git a/tests/test_solver_based_model.py b/tests/test_solver_based_model.py index 6404d0f91..6e55191c3 100644 --- a/tests/test_solver_based_model.py +++ b/tests/test_solver_based_model.py @@ -1,10 +1,21 @@ -# Copyright (c) 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. -# See LICENSE for details. -import copy +# Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import os +import copy import unittest -import os from cobra import Metabolite from optlang import Objective from cameo import load_model diff --git a/tests/test_strain_design_heuristics.py b/tests/test_strain_design_heuristics.py index 1a3ea32e0..2363f9d67 100644 --- a/tests/test_strain_design_heuristics.py +++ b/tests/test_strain_design_heuristics.py @@ -1,18 +1,18 @@ # Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + import os -from cameo.util import RandomGenerator as Random import unittest import inspyred import pickle @@ -20,6 +20,7 @@ from pandas.util.testing import assert_frame_equal from cameo import load_model, fba, config +from cameo.util import RandomGenerator as Random from cameo.strain_design.heuristic import HeuristicOptimization, ReactionKnockoutOptimization, set_distance_function from cameo.strain_design.heuristic.archivers import SolutionTuple, BestSolutionArchiver from cameo.strain_design.heuristic.decoders import ReactionKnockoutDecoder, KnockoutDecoder, GeneKnockoutDecoder diff --git a/tests/test_util.py b/tests/test_util.py index debe43b57..db36806d0 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -1,5 +1,16 @@ -# Copyright (c) 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. -# See LICENSE for details. +# Copyright 2014 Novo Nordisk Foundation Center for Biosustainability, DTU. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import unittest from functools import partial