Skip to content

Commit 52a0f51

Browse files
authored
Merge pull request #232 from biosustain/fix-pathway
Fix up pathway predictor
2 parents aa45d59 + f2f5e75 commit 52a0f51

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

cameo/strain_design/pathway_prediction/pathway_predictor.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -315,18 +315,19 @@ def run(self, product=None, max_predictions=float("inf"), min_production=.1,
315315
if len(vars_to_cut) == 0:
316316
# no pathway found:
317317
logger.info("It seems %s is a native product in model %s. "
318-
"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)
319319
# knockout adapter with native product
320320
for adapter in self.adpater_reactions:
321321
if product in adapter.metabolites:
322-
logger.info('Knocking out adapter reaction %s containing native product.' % adapter)
322+
logger.info('Knocking out adapter reaction %s '
323+
'containing native product.', adapter)
323324
adapter.knock_out()
324325
continue
325326

326327
pathway = [self.model.reactions.get_by_id(y_var.name[2:]) for y_var in vars_to_cut]
327328

328329
pathway_metabolites = set([m for pathway_reaction in pathway for m in pathway_reaction.metabolites])
329-
logger.info('Pathway predicted: %s' % '\t'.join(
330+
logger.info('Pathway predicted: %s', '\t'.join(
330331
[r.build_reaction_string(use_metabolite_names=True) for r in pathway]))
331332
pathway_metabolites.add(product)
332333

@@ -358,28 +359,28 @@ def run(self, product=None, max_predictions=float("inf"), min_production=.1,
358359
pathway.apply(self.original_model)
359360
self.original_model.objective = pathway.product.id
360361
try:
361-
value = self.original_model.slim_optimize(error_value=None)
362+
production_flux = self.original_model.slim_optimize(error_value=None)
362363
except OptimizationError as err:
363364
logger.error(err)
364365
logger.error(
365-
"Addition of pathway {} made the model unsolvable. "
366-
"Skipping pathway.".format(pathway))
366+
"Addition of pathway %r made the model unsolvable. "
367+
"Skipping pathway.", pathway)
367368
continue
368369
else:
369-
if value > non_zero_flux_threshold:
370+
if production_flux > non_zero_flux_threshold:
370371
pathways.append(pathway)
371-
logger.info("Max flux: %.5G", value)
372+
logger.info("Max flux: %.5G", production_flux)
372373
pathway_counter += 1
373-
integer_cut_counter += 1
374374
if callback is not None:
375375
callback(pathway)
376376
else:
377377
logger.warning(
378378
"Pathway %r could not be verified. Production "
379379
"flux %.5G is below the requirement %.5G. "
380-
"Skipping.", pathway, value,
380+
"Skipping.", pathway, production_flux,
381381
non_zero_flux_threshold)
382-
integer_cut_counter += 1
382+
finally:
383+
integer_cut_counter += 1
383384

384385
return PathwayPredictions(pathways)
385386

0 commit comments

Comments
 (0)