@@ -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 :
@@ -314,18 +315,19 @@ def run(self, product=None, max_predictions=float("inf"), min_production=.1,
314315 if len (vars_to_cut ) == 0 :
315316 # no pathway found:
316317 logger .info ("It seems %s is a native product in model %s. "
317- "Let's see if we can find better heterologous pathways." % ( product , self .model ) )
318+ "Let's see if we can find better heterologous pathways." , product , self .model )
318319 # knockout adapter with native product
319320 for adapter in self .adpater_reactions :
320321 if product in adapter .metabolites :
321- logger .info ('Knocking out adapter reaction %s containing native product.' % adapter )
322+ logger .info ('Knocking out adapter reaction %s '
323+ 'containing native product.' , adapter )
322324 adapter .knock_out ()
323325 continue
324326
325327 pathway = [self .model .reactions .get_by_id (y_var .name [2 :]) for y_var in vars_to_cut ]
326328
327329 pathway_metabolites = set ([m for pathway_reaction in pathway for m in pathway_reaction .metabolites ])
328- logger .info ('Pathway predicted: %s' % '\t ' .join (
330+ logger .info ('Pathway predicted: %s' , '\t ' .join (
329331 [r .build_reaction_string (use_metabolite_names = True ) for r in pathway ]))
330332 pathway_metabolites .add (product )
331333
@@ -342,10 +344,10 @@ def run(self, product=None, max_predictions=float("inf"), min_production=.1,
342344
343345 pathway = PathwayResult (pathway , exchanges , adapters , product_reaction )
344346 if not silent :
345- util .display_pathway (pathway , counter )
347+ util .display_pathway (pathway , pathway_counter )
346348
347349 integer_cut = self .model .solver .interface .Constraint (Add (* vars_to_cut ),
348- name = "integer_cut_" + str (counter ),
350+ name = "integer_cut_" + str (integer_cut_counter ),
349351 ub = len (vars_to_cut ) - 1 )
350352 logger .debug ('Adding integer cut.' )
351353 tm (
@@ -357,26 +359,28 @@ def run(self, product=None, max_predictions=float("inf"), min_production=.1,
357359 pathway .apply (self .original_model )
358360 self .original_model .objective = pathway .product .id
359361 try :
360- value = self .original_model .slim_optimize (error_value = None )
362+ production_flux = self .original_model .slim_optimize (error_value = None )
361363 except OptimizationError as err :
362364 logger .error (err )
363365 logger .error (
364- "Addition of pathway {} made the model unsolvable. "
365- "Skipping pathway." . format ( pathway ) )
366+ "Addition of pathway %r made the model unsolvable. "
367+ "Skipping pathway." , pathway )
366368 continue
367369 else :
368- if value > non_zero_flux_threshold :
370+ if production_flux > non_zero_flux_threshold :
369371 pathways .append (pathway )
370- logger .info ("Max flux: %.5G" , value )
371- counter += 1
372+ logger .info ("Max flux: %.5G" , production_flux )
373+ pathway_counter += 1
372374 if callback is not None :
373375 callback (pathway )
374376 else :
375377 logger .warning (
376378 "Pathway %r could not be verified. Production "
377379 "flux %.5G is below the requirement %.5G. "
378- "Skipping." , pathway , value ,
380+ "Skipping." , pathway , production_flux ,
379381 non_zero_flux_threshold )
382+ finally :
383+ integer_cut_counter += 1
380384
381385 return PathwayPredictions (pathways )
382386
0 commit comments