Unverified Commit 2c559f1d authored by Mihai's avatar Mihai Committed by GitHub
Browse files

Merge pull request #485 from mutalyzer/entrez-api-key

Add support for NCBI E-utilities API key
parents 97a6309c 0ff4864f
......@@ -47,6 +47,8 @@ class Retriever(object):
if not os.path.isdir(settings.CACHE_DIR):
os.mkdir(settings.CACHE_DIR)
Entrez.email = settings.EMAIL
if hasattr(settings, 'ENTREZ_API_KEY'):
Entrez.api_key = settings.ENTREZ_API_KEY
self.file_type = None
def _name_to_file(self, name):
......
......@@ -77,6 +77,8 @@ def _get_link_from_ncbi(source_db, target_db, match_link_name,
# below, so we cannot move to `accession.version` here. This is fine for
# now, but should be reconsidered at some point.
Entrez.email = settings.EMAIL
if hasattr(settings, 'ENTREZ_API_KEY'):
Entrez.api_key = settings.ENTREZ_API_KEY
# If we are currently strictly matching on version, we can try again if
# no result is found. Otherwise, we just report failure.
......@@ -343,6 +345,8 @@ def _get_snp_from_ncbi(rsid):
:return: response_text(str)
"""
Entrez.email = settings.EMAIL
if hasattr(settings, 'ENTREZ_API_KEY'):
Entrez.api_key = settings.ENTREZ_API_KEY
try:
response = Entrez.efetch(db='snp', id=rsid[2:], retmode='xml')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment