Skip to content

Commit

Permalink
check_compound_names allows 'None' (#324)
Browse files Browse the repository at this point in the history
  • Loading branch information
wholtz authored Aug 19, 2021
1 parent 0a12323 commit d963269
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions metatlas/plots/dill2plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -2918,18 +2918,20 @@ def make_groups_from_fileinfo_sheet(filename,filetype='tab',store=False):
metob.store(myGroup)
return return_groups

def check_compound_names(df):
# compounds that have the wrong compound name will be listed
# Keep running this until no more compounds are listed
bad_names = []
for i,row in df.iterrows():
#if type(df.name[x]) != float or type(df.label[x]) != float:
#if type(df.name[x]) != float:
if (not pd.isnull(row.inchi_key)) and (len(row.inchi_key)>0):# or type(df.inchi_key[x]) != float:
if not metob.retrieve('Compounds',inchi_key=row.inchi_key, username = '*'):
print((row.inchi_key, "compound is not in database. Exiting Without Completing Task!"))
bad_names.append(row.inchi_key)
return bad_names

def check_compound_names(atlas_df):
"""
Returns a list of inchi key values that could not be found in the database
NaN, None, 'None' and '' are excluded from the returned list
"""
not_found = []
for i, row in atlas_df.iterrows():
if (not pd.isnull(row.inchi_key)) and (len(row.inchi_key) > 0) and row.inchi_key != 'None':
if not metob.retrieve('Compounds', inchi_key=row.inchi_key, username='*'):
print((f"Compound with label '{row.label}' and index {i} has inchi key '{row.inchi_key}' "
"which cannot be found in the database. Exiting Without Completing Task!"))
not_found.append(row.inchi_key)
return not_found


def check_file_names(df,field):
Expand Down

0 comments on commit d963269

Please sign in to comment.