marsi.cobra.strain_design package¶
Submodules¶
marsi.cobra.strain_design.design_methods module¶
-
class
marsi.cobra.strain_design.design_methods.GenericMARSIDesignMethod(model=None, nearest_neighbors_model=None, min_tanimoto=0.75, currency_metabolites=None, essential_metabolites=None)[source]¶ Bases:
objectGeneric wrapper for Metabolite Analog design method.
This one just runs a optimization method
Example
>>> from marsi.cobra import strain_design >>> from cameo import models >>> from cameo.strain_design import OptGene >>> designer = strain_design.GenericMARSIDesignMethod(model=models.bigg.iJO1366) >>> designer.optimize_with_reaction("succ_e", max_interventions=5, substrate="EX_glc__D_e", >>> biomass="BIOMASS_Ec_iJO1366_core_53p95M", max_results=25, design_method=OptGene, manipulation_type="reactions")
Methods
essential_metabolites_reactions()optimize_with_metabolites(target[, …])optimize_with_reaction(target[, …])-
optimize_with_reaction(target, max_interventions=1, substrate=None, biomass=None, design_method=<class 'cameo.strain_design.deterministic.linear_programming.OptKnock'>, max_results=100, non_essential_metabolites=False, max_evaluations=20000, **design_kwargs)[source]¶
-
-
class
marsi.cobra.strain_design.design_methods.RandomMutagenesisDesign(model=None, nearest_neighbors_model=None, min_tanimoto=0.75, currency_metabolites=None, essential_metabolites=None)[source]¶ Bases:
marsi.cobra.strain_design.design_methods.GenericMARSIDesignMethodApply only knockout like designs where total loss of functions are expected.
Methods
essential_metabolites_reactions()optimize_with_metabolites(target[, …])optimize_with_reaction(target[, …])
-
class
marsi.cobra.strain_design.design_methods.ALEDesign(model=None, nearest_neighbors_model=None, min_tanimoto=0.75, currency_metabolites=None, essential_metabolites=None)[source]¶ Bases:
marsi.cobra.strain_design.design_methods.GenericMARSIDesignMethodApply both knockout and flux modulation. The strains will be selected via growth rate proxy.
Methods
essential_metabolites_reactions()optimize_with_metabolites(target[, …])optimize_with_reaction(target[, …])
marsi.cobra.strain_design.evolutionary module¶
-
class
marsi.cobra.strain_design.evolutionary.OptMet(model, evolutionary_algorithm=<class 'inspyred.ec.ec.GA'>, essential_metabolites=None, plot=True, *args, **kwargs)[source]¶ Bases:
cameo.core.strain_design.StrainDesignMethodAttributes
manipulation_typeplotMethods
__call__(*args, **kwargs)run([target, biomass, substrate, …])param target: The design target -
manipulation_type¶
-
plot¶
-
run(target=None, biomass=None, substrate=None, max_knockouts=5, variable_size=True, simulation_method=<function fba>, growth_coupled=False, max_evaluations=20000, population_size=200, max_results=50, seed=None, **kwargs)[source]¶ Parameters: - target (str, Metabolite or Reaction) – The design target
- biomass (str, Metabolite or Reaction) – The biomass definition in the model
- substrate (str, Metabolite or Reaction) – The main carbon source
- max_knockouts (int) – Max number of knockouts allowed
- variable_size (bool) – If true, all candidates have the same size. Otherwise the candidate size can be from 1 to max_knockouts.
- simulation_method (function) – Any method from cameo.flux_analysis.simulation or equivalent
- growth_coupled (bool) – If true will use the minimum flux rate to compute the fitness
- max_evaluations (int) – Number of evaluations before stop
- population_size (int) – Number of individuals in each generation
- max_results (int) – Max number of different designs to return if found.
- kwargs (dict) – Arguments for the simulation method.
- seed (int) – A seed for random.
Returns: Return type: OptMetResult
-
marsi.cobra.strain_design.metaheuristic module¶
-
class
marsi.cobra.strain_design.metaheuristic.MetaboliteKnockoutOptimization(metabolites=None, essential_metabolites=None, n_carbons=2, compartments='c', skip_essential_metabolites=False, *args, **kwargs)[source]¶ Bases:
cameo.strain_design.heuristic.evolutionary.optimization.TargetOptimizationKnockout optimization using metabolites.
-
model¶ SolverBasedModel – A constraint-based model.
-
heuristic_method¶ inspyred.ec.EvolutionaryComputation – An evolutionary algorithm.
-
objective_function¶ objective function or list(objective function) – The objectives for the algorithm to maximize.
-
seed¶ int – A seed for random. It is auto-generated if None is given.
-
termination¶ inspyred.ec.terminators – A termination criteria for the algorithm. The default is inspyred.ec.terminators.evaluation_termination.
-
simulation_method¶ flux_analysis.simulation – The method used to simulate the model.
-
wt_reference¶ dict – A reference initial state for the optimization. It is required for flux_analysis.simulation.lmoma and flux_analysis.simulation.room. If not given, it will be computed using flux_analysis.simulation.pfba
-
metabolites¶ list – A list of valid metabolites to knockout. If None, then all metabolites in the model will be knockout candidates except the ones defined in essential_metabolites
-
essential_metabolites¶ list – A list of metabolites that cannot be knocked out. If None, then all essential genes will be removed from the valid genes set.
-
run(view=config.default_view, maximize=True, **kwargs)¶
See also
inspyred,cameo.config.default_viewExample
>>> from cameo import models >>> model = models.bigg.iJO1366 >>> from cameo.strain_design.heuristic.evolutionary.objective_functions import biomass_product_coupled_yield >>> bpcy = biomass_product_coupled_yield(model.reactions.Ec_biomass_iJO1366_core_53p95, >>> model.reactions.EX_succ_e, >>> model.reactions.EX_glc__D_e) >>> knockout_optimization = MetaboliteKnockoutOptimization(model=model, objective_function=bpcy) >>> knockout_optimization.run(max_evaluations=50000)
Attributes
archiverheuristic_methodmetadataobjective_functionrandomsimulation_kwargssimulation_methodMethods
run([max_size, variable_size, diversify, view])Runs the evolutionary algorithm. -
simulation_method
-
simulation_kwargs¶
-
marsi.cobra.strain_design.post_processing module¶
-
marsi.cobra.strain_design.post_processing.find_anti_metabolite_knockouts(reaction, ref_flux=0, ignore_metabolites=None, ignore_transport=True, allow_accumulation=True)[source]¶ Generates a dictionary {species_id -> MetaboliteKnockoutTarget}.
Parameters: - reaction (cobra.Reaction) – A COBRA reaction
- ref_flux (float) – The flux from the reference state (0 if unknown)
- ignore_metabolites (list) – A list of metabolites that should not be targeted (currency metabolites, etc.)
- ignore_transport (bool) – If False, also knockout the transport reactions.
- allow_accumulation (bool) – If True, create an exchange reaction (unless already exists) to simulate accumulation of the metabolites.
Returns: Return type:
-
marsi.cobra.strain_design.post_processing.find_anti_metabolite_modulation(reaction, fold_change, essential_metabolites, ref_flux=0, ignore_metabolites=None, ignore_transport=True, allow_accumulation=True)[source]¶ Generates a dictionary {species_id -> AntiMetaboliteManipulationTarget}.
- If the fold change > 0:
- Search for metabolites that are essential.
- Calculate fraction using a link function.
- If fold change < 0:
- Search for metabolites that are not essential
- Calculated fraction is 1 - fold change
Parameters: - reaction (cobra.Reaction) – A COBRA reaction.
- fold_change (float) – The fold change of the reaction flux.
- essential_metabolites (list) – A list of essential metabolites.
- ref_flux (float) – The flux from the reference state (0 if unknown)
- ignore_metabolites (list) – A list of metabolites that should not be targeted (essential metabolites, currency metabolites, etc.).
- ignore_transport (bool) – If False, also knockout the transport reactions.
- allow_accumulation (bool) – If True, create an exchange reaction (unless already exists) to simulate accumulation of the metabolites.
Returns: {MetaboliteID -> AntiMetaboliteManipulationTarget}
Return type:
-
marsi.cobra.strain_design.post_processing.convert_strain_design_results(model, results, objective_function, simulation_method, simulation_kwargs=None, ignore_metabolites=None, ignore_transport=True, allow_accumulation=True, nullspace_matrix=None, essential_metabolites=None, max_loss=0.2)[source]¶ Converts a StrainDesignMethodResult into a DataFrame of possible substitutions.
Parameters: - model (cobra.Model) – A COBRA model.
- results (cameo.core.strain_design.StrainDesignMethodResult) – The results of a strain design method.
- objective_function (cameo.strain_design.heuristic.evolutionary.objective_functions.ObjectiveFunction) – The cellular objective to evaluate.
- simulation_method (cameo.flux_analysis.simulation.fba or equivalent) – The method to compute a flux distribution using a COBRA model.
- simulation_kwargs (dict) – The arguments for the simulation_method.
- ignore_metabolites (list) – A list of metabolites that should not be targeted (essential metabolites, currency metabolites, etc).
- ignore_transport (bool) – If False, also knockout the transport reactions.
- allow_accumulation (bool) – If True, create an exchange reaction (unless already exists) to simulate accumulation of the metabolites.
- nullspace_matrix (numpy.ndarray) – The nullspace of the model.
- essential_metabolites (list) – A list of essential metabolites.
- max_loss (float) – A number between 0 and 1 for how much the fitness is allowed to drop with the metabolite target.
Returns: A data frame with the possible replacements.
Return type: pandas.DataFrame
-
marsi.cobra.strain_design.post_processing.convert_design(model, strain_design, fitness, objective_function, simulation_method, simulation_kwargs=None, ignore_metabolites=None, ignore_transport=True, allow_accumulation=True, nullspace_matrix=None, essential_metabolites=None, max_loss=0.2)[source]¶ Converts a StrainDesign into a DataFrame of possible substitutions.
Parameters: - model (cobra.Model) – A COBRA model.
- strain_design (cameo.core.strain_design.StrainDesign) – The results of a strain design method.
- objective_function (cameo.strain_design.heuristic.evolutionary.objective_functions.ObjectiveFunction) – The cellular objective to evaluate.
- simulation_method (cameo.flux_analysis.simulation.fba or equivalent) – The method to compute a flux distribution using a COBRA model.
- simulation_kwargs (dict) – The arguments for the simulation_method.
- ignore_metabolites (list) – A list of metabolites that should not be targeted (essential metabolites, currency metabolites, etc).
- ignore_transport (bool) – If False, also knockout the transport reactions.
- allow_accumulation (bool) – If True, create an exchange reaction (unless already exists) to simulate accumulation of the metabolites.
- nullspace_matrix (numpy.ndarray) – The nullspace of the model.
- essential_metabolites (list) – A list of essential metabolites.
- max_loss (float) – A number between 0 and 1 for how much the fitness is allowed to drop with the metabolite target.
Returns: A data frame with the possible replacements.
Return type: pandas.DataFrame
-
marsi.cobra.strain_design.post_processing.test_target_substitutions(model, all_targets, target, replacement_targets, objective_function, fitness, base_fitness, simulation_method, simulation_kwargs, reference, loss_validation, results)[source]¶
-
marsi.cobra.strain_design.post_processing.replace_strain_design_results(model, results, objective_function, simulation_method, simulation_kwargs=None, ignore_metabolites=None, ignore_transport=True, allow_accumulation=True, essential_metabolites=None, max_loss=0.2)[source]¶ Converts a StrainDesignMethodResult into a DataFrame of possible substitutions.
Parameters: - model (cobra.Model) – A COBRA model.
- results (cameo.core.strain_design.StrainDesignMethodResult) – The results of a strain design method.
- objective_function (cameo.strain_design.heuristic.evolutionary.objective_functions.ObjectiveFunction) – The cellular objective to evaluate.
- simulation_method (cameo.flux_analysis.simulation.fba or equivalent) – The method to compute a flux distribution using a COBRA model.
- simulation_kwargs (dict) – The arguments for the simulation_method.
- ignore_metabolites (list) – A list of metabolites that should not be targeted (essential metabolites, currency metabolites, etc).
- ignore_transport (bool) – If False, also knockout the transport reactions.
- allow_accumulation (bool) – If True, create an exchange reaction (unless already exists) to simulate accumulation of the metabolites.
- essential_metabolites (list) – A list of essential metabolites.
- max_loss (float) – A number between 0 and 1 for how much the fitness is allowed to drop with the metabolite target.
Returns: A data frame with the possible replacements.
Return type: pandas.DataFrame
-
marsi.cobra.strain_design.post_processing.replace_design(model, strain_design, fitness, objective_function, simulation_method, simulation_kwargs=None, ignore_metabolites=None, ignore_transport=True, allow_accumulation=True, essential_metabolites=None, max_loss=0.2, allow_modulation=True)[source]¶ Converts a StrainDesign into a DataFrame of possible substitutions.
Parameters: - model (cobra.Model) – A COBRA model.
- strain_design (cameo.core.strain_design.StrainDesign) – The results of a strain design method.
- objective_function (cameo.strain_design.heuristic.evolutionary.objective_functions.ObjectiveFunction) – The cellular objective to evaluate.
- simulation_method (cameo.flux_analysis.simulation.fba or equivalent) – The method to compute a flux distribution using a COBRA model.
- simulation_kwargs (dict) – The arguments for the simulation_method.
- ignore_metabolites (list) – A list of metabolites that should not be targeted (essential metabolites, currency metabolites, etc).
- ignore_transport (bool) – If False, also knockout the transport reactions.
- allow_accumulation (bool) – If True, create an exchange reaction (unless already exists) to simulate accumulation of the metabolites.
- essential_metabolites (list) – A list of essential metabolites.
- max_loss (float) – A number between 0 and 1 for how much the fitness is allowed to drop with the metabolite target.
- allow_modulation (bool) – If False does not allow modulation targets (MILP and QP are not compatible)
Returns: A data frame with the possible replacements.
Return type: pandas.DataFrame
-
marsi.cobra.strain_design.post_processing.convert_target(model, target, essential_metabolites, ignore_transport=True, ignore_metabolites=None, allow_accumulation=True, reference=None, allow_modulation=True)[source]¶ Generates a dictionary {species_id -> (MetaboliteKnockoutTarget, MetaboliteModulationTarget)}.
Parameters: - model (cobra.Model) – A COBRA model
- target (ReactionModulationTarget, ReactionKnockoutTarget) – The flux from the reference state (0 if unknown)
- ignore_metabolites (list) – A list of metabolites that should not be targeted (essential metabolites, currency metabolites, etc.)
- ignore_transport (bool) – If False, also knockout the transport reactions.
- allow_accumulation (bool) – If True, create an exchange reaction (unless already exists) to simulate accumulation of the metabolites.
- reference (dict) – A dictionary containing the flux values of a reference flux distribution.
- essential_metabolites (list) – A list of essential metabolites
- allow_modulation (bool) – If False does not allow modulation targets (MILP and QP are not compatible).
Returns: Return type:
-
marsi.cobra.strain_design.post_processing.convert_target_group(model, target_group, essential_metabolites, ignore_transport=True, ignore_metabolites=None, allow_accumulation=True, reference=None, allow_modulation=True)[source]¶ Generates a dictionary {species_id -> MetaboliteKnockoutTarget}.
Parameters: - model (cobra.Model) – A COBRA model
- target_group (dict) – A dictionary of (target: relative coefficient)
- ignore_metabolites (set) – A list of metabolites that should not be targeted (essential metabolites, currency metabolites, etc.)
- ignore_transport (bool) – If False, also knockout the transport reactions.
- allow_accumulation (bool) – If True, create an exchange reaction (unless already exists) to simulate accumulation of the metabolites.
- reference (dict) – A dictionary containing the flux values of a reference flux distribution.
- essential_metabolites (set) – A list of essential metabolites.
- allow_modulation (bool) – If False does not allow modulation targets (MILP and QP are not compatible).
Returns: A dictionary with the antimetabolites to test and another dictionary with the reaction where those metabolites belong.
Return type:
marsi.cobra.strain_design.target module¶
-
class
marsi.cobra.strain_design.target.AntiMetaboliteManipulationTarget(species_id, fraction=0.5, ignore_transport=True, allow_accumulation=True, accession_id=None, accession_db=None)[source]¶ Bases:
cameo.core.target.TargetMetabolite target used to manipulate fluxes. There are three modes of action: 1. Inhibition 2. Competition 3. Knockout (see Metabolite Knockout Target)
If the metabolite is essential, the fluxes around the metabolite will be increased for the cells to survive. If the metabolite is not essential, the fluxes will be decreased as a consequence of the metabolite presence.
Methods
apply(model[, reference])get_model_target(model)Finds the metabolites in the model across compartments. to_gnomic()
-
class
marsi.cobra.strain_design.target.MetaboliteKnockoutTarget(species_id, ignore_transport=True, allow_accumulation=True)[source]¶ Bases:
marsi.cobra.strain_design.target.AntiMetaboliteManipulationTargetMethods
apply(model[, reference])get_model_target(model)Finds the metabolites in the model across compartments. to_gnomic()
Module contents¶
-
class
marsi.cobra.strain_design.OptMet(model, evolutionary_algorithm=<class 'inspyred.ec.ec.GA'>, essential_metabolites=None, plot=True, *args, **kwargs)[source]¶ Bases:
cameo.core.strain_design.StrainDesignMethodAttributes
manipulation_typeplotMethods
__call__(*args, **kwargs)run([target, biomass, substrate, …])param target: The design target -
manipulation_type¶
-
plot¶
-
run(target=None, biomass=None, substrate=None, max_knockouts=5, variable_size=True, simulation_method=<function fba>, growth_coupled=False, max_evaluations=20000, population_size=200, max_results=50, seed=None, **kwargs)[source]¶ Parameters: - target (str, Metabolite or Reaction) – The design target
- biomass (str, Metabolite or Reaction) – The biomass definition in the model
- substrate (str, Metabolite or Reaction) – The main carbon source
- max_knockouts (int) – Max number of knockouts allowed
- variable_size (bool) – If true, all candidates have the same size. Otherwise the candidate size can be from 1 to max_knockouts.
- simulation_method (function) – Any method from cameo.flux_analysis.simulation or equivalent
- growth_coupled (bool) – If true will use the minimum flux rate to compute the fitness
- max_evaluations (int) – Number of evaluations before stop
- population_size (int) – Number of individuals in each generation
- max_results (int) – Max number of different designs to return if found.
- kwargs (dict) – Arguments for the simulation method.
- seed (int) – A seed for random.
Returns: Return type: OptMetResult
-
-
class
marsi.cobra.strain_design.RandomMutagenesisDesign(model=None, nearest_neighbors_model=None, min_tanimoto=0.75, currency_metabolites=None, essential_metabolites=None)[source]¶ Bases:
marsi.cobra.strain_design.design_methods.GenericMARSIDesignMethodApply only knockout like designs where total loss of functions are expected.
Methods
essential_metabolites_reactions()optimize_with_metabolites(target[, …])optimize_with_reaction(target[, …])
-
class
marsi.cobra.strain_design.ALEDesign(model=None, nearest_neighbors_model=None, min_tanimoto=0.75, currency_metabolites=None, essential_metabolites=None)[source]¶ Bases:
marsi.cobra.strain_design.design_methods.GenericMARSIDesignMethodApply both knockout and flux modulation. The strains will be selected via growth rate proxy.
Methods
essential_metabolites_reactions()optimize_with_metabolites(target[, …])optimize_with_reaction(target[, …])