@@ -74,9 +74,9 @@ def __init__(self,model):
74
74
self .test_objective = None
75
75
self .score = None
76
76
77
- def printlp (self ,lpfilename = "debug.lp" ):
77
+ def printlp (self , lpfilename = "debug.lp" ):
78
78
with open (lpfilename , 'w' ) as out :
79
- out .write (str (self .model .solver ))
79
+ out .write (str (self .model .solver ))
80
80
81
81
def build_metabolite_hash (self ):
82
82
self .metabolite_hash = {}
@@ -345,7 +345,7 @@ def add_gapfilling_solution_to_kbase_model(self,newmodel,gapfilled_reactions,gfi
345
345
kbrxn ["gapfill_data" ][gfid ]["0" ] = [gapfilled_reactions ["reversed" ][rxn ],1 ,[]]
346
346
return rxn_table
347
347
348
- def apply_test_condition (self ,condition ,model = None ):
348
+ def apply_test_condition (self , condition , model = None ):
349
349
"""Applies constraints and objective of specified condition to model
350
350
351
351
Parameters
@@ -363,7 +363,7 @@ def apply_test_condition(self,condition,model = None):
363
363
Raises
364
364
------
365
365
"""
366
- if model == None :
366
+ if model is None :
367
367
model = self .model
368
368
pkgmgr = self .pkgmgr
369
369
else :
@@ -375,7 +375,7 @@ def apply_test_condition(self,condition,model = None):
375
375
model .objective .direction = "min"
376
376
pkgmgr .getpkg ("KBaseMediaPkg" ).build_package (condition ["media" ])
377
377
378
- def test_single_condition (self ,condition ,apply_condition = True ,model = None ):
378
+ def test_single_condition (self , condition , apply_condition = True , model = None ):
379
379
"""Runs a single test condition to determine if objective value on set media exceeds threshold
380
380
381
381
Parameters
@@ -395,14 +395,14 @@ def test_single_condition(self,condition,apply_condition=True,model=None):
395
395
Raises
396
396
------
397
397
"""
398
- if model == None :
398
+ if model is None :
399
399
model = self .model
400
400
if apply_condition :
401
- self .apply_test_condition (condition ,model )
401
+ self .apply_test_condition (condition , model )
402
402
new_objective = model .slim_optimize ()
403
403
value = new_objective
404
404
if "change" in condition and condition ["change" ]:
405
- if self .test_objective != None :
405
+ if self .test_objective is not None :
406
406
value = new_objective - self .test_objective
407
407
self .score = value
408
408
if model .solver .status != 'optimal' :
@@ -418,7 +418,7 @@ def test_single_condition(self,condition,apply_condition=True,model=None):
418
418
self .test_objective = new_objective
419
419
return True
420
420
421
- def test_condition_list (self ,condition_list , model = None ):
421
+ def test_condition_list (self , condition_list : list , model = None ):
422
422
"""Runs a set of test conditions to determine if objective values on set medias exceed thresholds
423
423
424
424
Parameters
@@ -443,7 +443,7 @@ def test_condition_list(self,condition_list,model=None):
443
443
return False
444
444
return True
445
445
446
- def reaction_expansion_test (self ,reaction_list , condition_list ):
446
+ def reaction_expansion_test (self , reaction_list : list , condition_list : list ):
447
447
"""Adds reactions in reaction list one by one and appplies tests, filtering reactions that fail
448
448
449
449
Parameters
@@ -461,10 +461,15 @@ def reaction_expansion_test(self,reaction_list,condition_list):
461
461
Raises
462
462
------
463
463
"""
464
- print ("Expansion started!" )
465
464
tic = time .perf_counter ()
465
+
466
+ logger .info (f"Expansion started! reaction list: { len (reaction_list )} conditions: { len (condition_list )} " )
467
+
466
468
filtered_list = []
467
469
for condition in condition_list :
470
+
471
+ logger .debug (f'testing condition { condition } ' )
472
+
468
473
currmodel = self .model
469
474
with currmodel :
470
475
self .apply_test_condition (condition )
0 commit comments