Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from PGScatalog:master #153

Merged
merged 2 commits into from
Dec 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion curation/parsers/publication.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,22 @@ def rest_api_call_to_epmc(self,query):
result = requests.get(constants.USEFUL_URLS['EPMC_REST_SEARCH'], params=payload)
result = result.json()
if 'result' in result['resultList']:
return result['resultList']['result'][0]
if len(result['resultList']['result']) > 1:
# If multiple results, the first one might be a PMC entry, which doesn't contain PMID or DOI, therefore needs to be skipped.
if query.startswith('doi:'):
query_id = query.removeprefix('doi:')
id_type = 'doi'
elif query.startswith('ext_id:'):
query_id = query.removeprefix('ext_id:')
id_type = 'pmid'
else:
raise Exception('Unexpected query format: {}'.format(query))
for single_result in result['resultList']['result']:
if id_type in single_result and single_result[id_type] == query_id:
return single_result
raise Exception('Results from EuropePMC for {} not in the expected format.'.format(query))
else:
return result['resultList']['result'][0]
else:
raise Exception(f'Can\'t find the paper in EuropePMC! (query:{query})')

Expand Down
Loading