Skip to content

Commit

Permalink
Add try-except
Browse files Browse the repository at this point in the history
  • Loading branch information
kozo2 committed Aug 19, 2023
1 parent 4658166 commit 18e20bb
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pywikipathways/find_pathway_by_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

def find_pathways_by_text(query):
res = wikipathways_get('findPathwaysByText', {'query': query, 'format': 'json'})
tmp = pandas.DataFrame(res['result'])
score = tmp['score'].apply(lambda x: x['0'])
tmp['score'] = score
return tmp.drop(['fields'], axis=1).drop_duplicates(ignore_index=True)
tmp = pandas.DataFrame(res['result'])
try:
score = tmp['score'].apply(lambda x: x['0'])
tmp['score'] = score
return tmp.drop(['fields'], axis=1).drop_duplicates(ignore_index=True)
except KeyError:
print("No results")

def find_pathway_ids_by_text(query):
res = find_pathways_by_text(query)
Expand Down

0 comments on commit 18e20bb

Please sign in to comment.