Skip to content

Commit

Permalink
hotfix: fix integercut ID clash in PathwayPredictor
Browse files Browse the repository at this point in the history
  • Loading branch information
phantomas1234 committed Feb 6, 2019
1 parent 0df95b5 commit aa45d59
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions cameo/strain_design/pathway_prediction/pathway_predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,10 @@ def run(self, product=None, max_predictions=float("inf"), min_production=.1,
product_reaction = self.model.add_boundary(product, type='demand')

product_reaction.lower_bound = min_production
counter = 1
while counter <= max_predictions:
logger.debug('Predicting pathway No. %d' % counter)
pathway_counter = 1
integer_cut_counter = 1
while pathway_counter <= max_predictions:
logger.debug('Predicting pathway No. %d' % pathway_counter)
try:
self.model.slim_optimize(error_value=None)
except OptimizationError as err:
Expand Down Expand Up @@ -342,10 +343,10 @@ def run(self, product=None, max_predictions=float("inf"), min_production=.1,

pathway = PathwayResult(pathway, exchanges, adapters, product_reaction)
if not silent:
util.display_pathway(pathway, counter)
util.display_pathway(pathway, pathway_counter)

integer_cut = self.model.solver.interface.Constraint(Add(*vars_to_cut),
name="integer_cut_" + str(counter),
name="integer_cut_" + str(integer_cut_counter),
ub=len(vars_to_cut) - 1)
logger.debug('Adding integer cut.')
tm(
Expand All @@ -368,7 +369,8 @@ def run(self, product=None, max_predictions=float("inf"), min_production=.1,
if value > non_zero_flux_threshold:
pathways.append(pathway)
logger.info("Max flux: %.5G", value)
counter += 1
pathway_counter += 1
integer_cut_counter += 1
if callback is not None:
callback(pathway)
else:
Expand All @@ -377,6 +379,7 @@ def run(self, product=None, max_predictions=float("inf"), min_production=.1,
"flux %.5G is below the requirement %.5G. "
"Skipping.", pathway, value,
non_zero_flux_threshold)
integer_cut_counter += 1

return PathwayPredictions(pathways)

Expand Down

0 comments on commit aa45d59

Please sign in to comment.