Skip to content

Commit 28de76a

Browse files
authored
Merge pull request #88 from Fxe/dev
added detection for compatibility with old repo
2 parents 96bed5d + 76ce3ee commit 28de76a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

modelseedpy/biochem/modelseed_biochem.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,13 @@ def load_metabolites_from_df(
139139
if cpd_id in structures:
140140
if "SMILE" in structures[cpd_id]:
141141
smiles = structures[cpd_id]["SMILE"]
142+
aliases_annotation['SMILE'] = smiles
142143
if "InChI" in structures[cpd_id]:
143144
inchi = structures[cpd_id]["InChI"]
145+
aliases_annotation['InChI'] = inchi
144146
if "InChIKey" in structures[cpd_id]:
145147
inchi_key = structures[cpd_id]["InChIKey"]
148+
aliases_annotation['InChIKey'] = inchi_key
146149
inchi_key = None if pd.isna(inchi_key) or len(inchi_key) == 0 else inchi_key
147150
other_names = set()
148151
if cpd_id in names:
@@ -158,9 +161,6 @@ def load_metabolites_from_df(
158161
mass,
159162
delta_g,
160163
delta_g_err,
161-
smiles,
162-
inchi_key,
163-
inchi,
164164
is_core,
165165
is_obsolete,
166166
is_cofactor,
@@ -763,6 +763,10 @@ def from_local_old(path):
763763

764764

765765
def from_local(database_path: str):
766+
contents = os.listdir(f'{database_path}/Biochemistry/')
767+
if 'compounds.tsv' in contents:
768+
return from_local_old(database_path)
769+
766770
compound_aliases_url = f'{database_path}/Biochemistry/Aliases/Unique_ModelSEED_Compound_Aliases.txt'
767771
reaction_aliases_url = f'{database_path}/Biochemistry/Aliases/Unique_ModelSEED_Reaction_Aliases.txt'
768772
compound_aliases = _load_aliases_df(pd.read_csv(compound_aliases_url, index_col=None, sep='\t'))

0 commit comments

Comments
 (0)