Skip to content

Commit 0aa128e

Browse files
committed
style
1 parent 8be3527 commit 0aa128e

File tree

4 files changed

+29
-19
lines changed

4 files changed

+29
-19
lines changed

modelseedpy/core/msatpcorrection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def run_atp_correction(self):
334334
"""
335335
# Ensure all specified media work
336336
self.evaluate_growth_media()
337-
self.determine_growth_media2()
337+
self.determine_growth_media()
338338
self.apply_growth_media_gapfilling()
339339
self.evaluate_growth_media()
340340
self.expand_model_to_genome_scale()

modelseedpy/core/msbuilder.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,4 +650,7 @@ def gapfill_model(original_mdl, target_reaction, template, media):
650650
else:
651651
rxn.upper_bound = 0
652652
rxn.lower_bound = -100
653-
return original_mdl
653+
return original_mdl
654+
655+
def build_metabolic_model(genome, media=None, atp_test_medias=None, core_template=None, genome_scale_template=None):
656+
pass

modelseedpy/core/msmodelutl.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ def __init__(self,model):
7474
self.test_objective = None
7575
self.score = None
7676

77-
def printlp(self,lpfilename="debug.lp"):
77+
def printlp(self, lpfilename="debug.lp"):
7878
with open(lpfilename, 'w') as out:
79-
out.write(str(self.model.solver))
79+
out.write(str(self.model.solver))
8080

8181
def build_metabolite_hash(self):
8282
self.metabolite_hash = {}
@@ -345,7 +345,7 @@ def add_gapfilling_solution_to_kbase_model(self,newmodel,gapfilled_reactions,gfi
345345
kbrxn["gapfill_data"][gfid]["0"] = [gapfilled_reactions["reversed"][rxn],1,[]]
346346
return rxn_table
347347

348-
def apply_test_condition(self,condition,model = None):
348+
def apply_test_condition(self, condition, model=None):
349349
"""Applies constraints and objective of specified condition to model
350350
351351
Parameters
@@ -363,7 +363,7 @@ def apply_test_condition(self,condition,model = None):
363363
Raises
364364
------
365365
"""
366-
if model == None:
366+
if model is None:
367367
model = self.model
368368
pkgmgr = self.pkgmgr
369369
else:
@@ -375,7 +375,7 @@ def apply_test_condition(self,condition,model = None):
375375
model.objective.direction = "min"
376376
pkgmgr.getpkg("KBaseMediaPkg").build_package(condition["media"])
377377

378-
def test_single_condition(self,condition,apply_condition=True,model=None):
378+
def test_single_condition(self, condition, apply_condition=True, model=None):
379379
"""Runs a single test condition to determine if objective value on set media exceeds threshold
380380
381381
Parameters
@@ -395,14 +395,14 @@ def test_single_condition(self,condition,apply_condition=True,model=None):
395395
Raises
396396
------
397397
"""
398-
if model == None:
398+
if model is None:
399399
model = self.model
400400
if apply_condition:
401-
self.apply_test_condition(condition,model)
401+
self.apply_test_condition(condition, model)
402402
new_objective = model.slim_optimize()
403403
value = new_objective
404404
if "change" in condition and condition["change"]:
405-
if self.test_objective != None:
405+
if self.test_objective is not None:
406406
value = new_objective - self.test_objective
407407
self.score = value
408408
if model.solver.status != 'optimal':
@@ -418,7 +418,7 @@ def test_single_condition(self,condition,apply_condition=True,model=None):
418418
self.test_objective = new_objective
419419
return True
420420

421-
def test_condition_list(self,condition_list,model=None):
421+
def test_condition_list(self, condition_list: list, model=None):
422422
"""Runs a set of test conditions to determine if objective values on set medias exceed thresholds
423423
424424
Parameters
@@ -443,7 +443,7 @@ def test_condition_list(self,condition_list,model=None):
443443
return False
444444
return True
445445

446-
def reaction_expansion_test(self,reaction_list,condition_list):
446+
def reaction_expansion_test(self, reaction_list: list, condition_list: list):
447447
"""Adds reactions in reaction list one by one and appplies tests, filtering reactions that fail
448448
449449
Parameters
@@ -461,10 +461,15 @@ def reaction_expansion_test(self,reaction_list,condition_list):
461461
Raises
462462
------
463463
"""
464-
print("Expansion started!")
465464
tic = time.perf_counter()
465+
466+
logger.info(f"Expansion started! reaction list: {len(reaction_list)} conditions: {len(condition_list)}")
467+
466468
filtered_list = []
467469
for condition in condition_list:
470+
471+
logger.debug(f'testing condition {condition}')
472+
468473
currmodel = self.model
469474
with currmodel:
470475
self.apply_test_condition(condition)

modelseedpy/fbapkg/gapfillingpkg.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,11 @@ def binary_check_gapfilling_solution(self, solution=None, flux_values=None):
450450
self.model.optimize()
451451
new_solution = self.compute_gapfilled_solution()
452452
return new_solution
453-
454-
#This function is designed to KO all gapfilled reactions not included in the solution
453+
455454
def knockout_gf_reactions_outside_solution(self,solution = None,flux_values = None):
455+
"""
456+
This function is designed to KO all gap filled reactions not included in the solution
457+
"""
456458
if solution == None:
457459
solution = self.compute_gapfilled_solution()
458460
if flux_values == None:
@@ -500,18 +502,18 @@ def run_test_conditions(self,condition_list,solution = None,max_iterations = 10)
500502
return None
501503
return solution
502504

503-
def filter_database_based_on_tests(self,test_conditions):
505+
def filter_database_based_on_tests(self, test_conditions):
504506
filetered_list = []
505507
with self.model:
506508
rxnlist = []
507509
for reaction in self.model.reactions:
508510
if reaction.id in self.gapfilling_penalties:
509511
if "reverse" in self.gapfilling_penalties[reaction.id]:
510-
rxnlist.append([reaction,"<"])
512+
rxnlist.append([reaction, "<"])
511513
if "forward" in self.gapfilling_penalties[reaction.id]:
512-
rxnlist.append([reaction,">"])
514+
rxnlist.append([reaction, ">"])
513515
self.pkgmgr.getpkg("ObjConstPkg").constraints["objc"]["1"].lb = 0
514-
filtered_list = self.modelutl.reaction_expansion_test(rxnlist,test_conditions)
516+
filtered_list = self.modelutl.reaction_expansion_test(rxnlist, test_conditions)
515517
#Now constraining filtered reactions to zero
516518
for item in filtered_list:
517519
logger.debug("Filtering:",item[0].id,item[1])

0 commit comments

Comments
 (0)