@@ -953,6 +953,22 @@ def build_biomass(self, rxn_id, cobra_model, template, biomass_compounds):
953953 bio_rxn .annotation [SBO_ANNOTATION ] = "SBO:0000629"
954954 return bio_rxn
955955
956+ @staticmethod
957+ def integrate_gapfill_solution (template , model , gap_fill_solution ):
958+ added_reactions = []
959+ for rxn_id , (lb , ub ) in gap_fill_solution .items ():
960+ template_reaction = template .reactions .get_by_id (rxn_id )
961+ model_reaction = template_reaction .to_reaction (model )
962+ model_reaction .lower_bound = lb
963+ model_reaction .upper_bound = ub
964+ _str = model_reaction .build_reaction_string (True )
965+ # print(f'{model.id} add {model_reaction.id}: {_str}')
966+ added_reactions .append (model_reaction )
967+ model .add_reactions (added_reactions )
968+ add_exchanges = MSBuilder .add_exchanges_to_model (model )
969+
970+ return added_reactions , add_exchanges
971+
956972 def build (
957973 self ,
958974 model_or_id ,
@@ -1018,30 +1034,15 @@ def build(
10181034
10191035 gapfill_res = gapfill .run_gapfilling (gapfill_media )
10201036
1021- def _integrate_solution (template , model , gap_fill_solution ):
1022- added_reactions = []
1023- for rxn_id , (lb , ub ) in gap_fill_solution .items ():
1024- template_reaction = template .reactions .get_by_id (rxn_id )
1025- model_reaction = template_reaction .to_reaction (model )
1026- model_reaction .lower_bound = lb
1027- model_reaction .upper_bound = ub
1028- _str = model_reaction .build_reaction_string (True )
1029- # print(f'{model.id} add {model_reaction.id}: {_str}')
1030- added_reactions .append (model_reaction )
1031- model .add_reactions (added_reactions )
1032- add_exchanges = MSBuilder .add_exchanges_to_model (model )
1033-
1034- return added_reactions , add_exchanges
1035-
10361037 from modelseedpy .core .msmodel import get_reaction_constraints_from_direction
10371038
10381039 gap_sol = {}
10391040 for rxn_id , d in gapfill_res ["new" ].items ():
1040- if rxn_id [:- 1 ] in template .reactions :
1041+ if rxn_id [:- 1 ] in self . template .reactions :
10411042 gap_sol [rxn_id [:- 1 ]] = get_reaction_constraints_from_direction (d )
10421043 # print(gap_sol)
10431044 model_gapfilled = model_base .copy ()
1044- _integrate_solution (self .template , model_gapfilled , gap_sol )
1045+ MSBuilder . integrate_gapfill_solution (self .template , model_gapfilled , gap_sol )
10451046
10461047 return model_gapfilled , atp_correction , tests , gap_sol
10471048
0 commit comments