Skip to content

Commit b35af66

Browse files
committed
biochem
1 parent d164850 commit b35af66

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

modelseedpy/biochem/modelseed_biochem.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -194,19 +194,21 @@ def load_reactions_from_df(df: pd.DataFrame, database_metabolites: dict, names:
194194
reactions.append(rxn)
195195
except Exception as e:
196196
logger.error('failed to read reaction at Index: %s. %s', t[0], e)
197-
return reactions
197+
return reactions, list(metabolites_indexed.values())
198198

199199

200200
class ModelSEEDDatabase:
201201
"""
202202
ModelSEED database instance.
203203
"""
204204

205-
def __init__(self, compounds, reactions):
205+
def __init__(self, compounds, reactions, compound_tokens):
206206
self.compounds = DictList()
207+
self.compound_tokens = DictList()
207208
self.reactions = DictList()
208209
self.compounds += compounds
209210
self.reactions += reactions
211+
self.reactions += compound_tokens
210212
self.inchi_key_lookup = {}
211213
self.metabolite_reactions = {}
212214

@@ -403,8 +405,9 @@ def load_database(compounds_url, reactions_url,
403405
reaction_ecs = get_aliases_from_df(pd.read_csv(reactions_ec_url, sep='\t'))
404406

405407
df_reactions = pd.read_csv(reactions_url, sep='\t', low_memory=False)
406-
reactions = load_reactions_from_df(df_reactions, dict(map(lambda x: (x.id, x), compounds)), reaction_names,
407-
reaction_aliases, reaction_ecs)
408+
reactions, metabolites_indexed = load_reactions_from_df(
409+
df_reactions, dict(map(lambda x: (x.id, x), compounds)), reaction_names,
410+
reaction_aliases, reaction_ecs)
408411

409412
database = ModelSEEDDatabase(compounds, reactions)
410413
return database

modelseedpy/biochem/modelseed_reaction.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,7 @@ def to_template_reaction(self, compartment_setup=None):
158158
raise ValueError(f'invalid compartment setup missing key [{m.compartment}] in {compartment_setup}')
159159
cpd = m.to_template_compartment_compound(compartment_setup[m.compartment])
160160
metabolites[cpd] = v
161-
print(m.id, m.compartment, cpd)
162-
163-
print(v)
161+
# print(m.id, m.compartment, cpd, v)
164162

165163
# if len(str(index)) > 0:
166164
# name = f'{self.name} [{compartment}]'

modelseedpy/core/msatpcorrection.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def __init__(self, model, core_template, atp_medias,compartment="c0",
3737
self.max_gapfilling = max_gapfilling
3838
self.gapfilling_delta = gapfilling_delta
3939
self.coretemplate = core_template
40-
self.msgapfill = MSGapfill(model,default_gapfill_templates=core_template)
40+
self.msgapfill = MSGapfill(model, default_gapfill_templates=core_template)
4141
self.original_bounds = {}
4242
self.noncore_reactions = []
4343
self.other_compartments = []
@@ -126,7 +126,7 @@ def evaluate_growth_media(self):
126126
logger.debug('evaluate media %s - %f (%s)', media.id, solution.objective_value, solution.status)
127127
self.media_gapfill_stats[media] = None
128128
if solution.objective_value == 0 or solution.status != 'optimal':
129-
self.media_gapfill_stats[media] = self.msgapfill.run_gapfilling(media, self.atp_hydrolysis.id)
129+
self.media_gapfill_stats[media] = self.msgapfill.run_gapfilling(media, self.atp_hydrolysis.id)
130130
#IF gapfilling fails - need to activate and penalize the noncore and try again
131131
elif solution.objective_value > 0 or solution.status == 'optimal':
132132
self.media_gapfill_stats[media] = {'reversed': {}, 'new': {}}

modelseedpy/core/msgapfill.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def run_gapfilling(self, media=None, target="bio1", minimum_obj=0.01, binary_che
5656
"gapfill_all_indecies_with_default_models": self.gapfill_all_indecies_with_default_models,
5757
"default_excretion":100,
5858
"default_uptake":100,
59-
"minimum_obj":minimum_obj,
59+
"minimum_obj": minimum_obj,
6060
"blacklist": self.blacklist,
6161
"reaction_scores": self.reaction_scores,
6262
"set_objective": 1

0 commit comments

Comments
 (0)