Skip to content

Commit

Permalink
Add pubmed api key to allow up to 10 queries/sec
Browse files Browse the repository at this point in the history
  • Loading branch information
wshayes committed Jun 15, 2018
1 parent 453186c commit 7dbce8c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions bel/nanopub/pubmed.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@
import bel.lang.bel_utils as bel_utils
from bel.utils import get_url, url_path_param_quoting

# Replace pmid
PUBMED_TMPL = 'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&retmode=xml&id=PMID'
# Replace PMID
if config['bel_api']['servers'].get('pubmed_api_key', False):
PUBMED_TMPL = f'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&retmode=xml&api_key={config["bel_api"]["servers"]["pubmed_api_key"]}&id=PMID'
else:
PUBMED_TMPL = 'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&retmode=xml&id=PMID'

PUBTATOR_TMPL = 'https://www.ncbi.nlm.nih.gov/CBBresearch/Lu/Demo/RESTful/tmTool.cgi/BioConcept/PMID/JSON'

pubtator_ns_convert = {'CHEBI': 'CHEBI', 'Species': 'TAX', 'Gene': 'EG', 'Chemical': 'MESH', 'Disease': 'MESH'}
Expand Down Expand Up @@ -116,7 +120,7 @@ def get_pubmed(pmid: str) -> Mapping[str, Any]:
Returns:
pubmed json
"""
pubmed_url = PUBMED_TMPL.replace('PMID', pmid)
pubmed_url = PUBMED_TMPL.replace('PMID', str(pmid))
r = get_url(pubmed_url)
log.info(f'Getting Pubmed URL {pubmed_url}')

Expand Down

0 comments on commit 7dbce8c

Please sign in to comment.