Skip to content

Commit aa45d59

Browse files
committed
hotfix: fix integercut ID clash in PathwayPredictor
1 parent 0df95b5 commit aa45d59

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

cameo/strain_design/pathway_prediction/pathway_predictor.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,10 @@ def run(self, product=None, max_predictions=float("inf"), min_production=.1,
294294
product_reaction = self.model.add_boundary(product, type='demand')
295295

296296
product_reaction.lower_bound = min_production
297-
counter = 1
298-
while counter <= max_predictions:
299-
logger.debug('Predicting pathway No. %d' % counter)
297+
pathway_counter = 1
298+
integer_cut_counter = 1
299+
while pathway_counter <= max_predictions:
300+
logger.debug('Predicting pathway No. %d' % pathway_counter)
300301
try:
301302
self.model.slim_optimize(error_value=None)
302303
except OptimizationError as err:
@@ -342,10 +343,10 @@ def run(self, product=None, max_predictions=float("inf"), min_production=.1,
342343

343344
pathway = PathwayResult(pathway, exchanges, adapters, product_reaction)
344345
if not silent:
345-
util.display_pathway(pathway, counter)
346+
util.display_pathway(pathway, pathway_counter)
346347

347348
integer_cut = self.model.solver.interface.Constraint(Add(*vars_to_cut),
348-
name="integer_cut_" + str(counter),
349+
name="integer_cut_" + str(integer_cut_counter),
349350
ub=len(vars_to_cut) - 1)
350351
logger.debug('Adding integer cut.')
351352
tm(
@@ -368,7 +369,8 @@ def run(self, product=None, max_predictions=float("inf"), min_production=.1,
368369
if value > non_zero_flux_threshold:
369370
pathways.append(pathway)
370371
logger.info("Max flux: %.5G", value)
371-
counter += 1
372+
pathway_counter += 1
373+
integer_cut_counter += 1
372374
if callback is not None:
373375
callback(pathway)
374376
else:
@@ -377,6 +379,7 @@ def run(self, product=None, max_predictions=float("inf"), min_production=.1,
377379
"flux %.5G is below the requirement %.5G. "
378380
"Skipping.", pathway, value,
379381
non_zero_flux_threshold)
382+
integer_cut_counter += 1
380383

381384
return PathwayPredictions(pathways)
382385

0 commit comments

Comments
 (0)