Skip to content

Commit

Permalink
Deprecate Bio.Entrez.egquery
Browse files Browse the repository at this point in the history
See issue # #4698 and NCBI Entrez Utilities team case #: CAS-1295533-Y0X6Q5 
  • Loading branch information
peterjc committed May 13, 2024
1 parent 8088f20 commit 3a39de9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
16 changes: 12 additions & 4 deletions Bio/Entrez/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
This module provides a number of functions like ``efetch`` (short for
Entrez Fetch) which will return the data as a handle object. This is
a standard interface used in Python for reading data from a file, or
a standad interface used in Python for reading data from a file, or
in this case a remote network connection, and provides methods like
``.read()`` or offers iteration over the contents line by line. See
also "What the heck is a handle?" in the Biopython Tutorial and
Expand Down Expand Up @@ -134,6 +134,7 @@
from urllib.parse import urlencode
from urllib.request import urlopen, Request

from Bio import BiopythonDeprecationWarning
from Bio._utils import function_with_previous

email = None
Expand Down Expand Up @@ -342,10 +343,11 @@ def esummary(**keywds):


def egquery(**keywds):
"""Provide Entrez database counts for a global search.
"""Provide Entrez database counts for a global search (DEPRECATED).
EGQuery provides Entrez database counts in XML for a single search
using Global Query.
EGQuery provided Entrez database counts in XML for a single search
using Global Query. However, the NCBI are no longer maintaining this
function and suggest using esearch on each database of interest.
See the online documentation for an explanation of the parameters:
http://www.ncbi.nlm.nih.gov/books/NBK25499/#chapter4.EGQuery
Expand All @@ -367,6 +369,12 @@ def egquery(**keywds):
:returns: Handle to the results, by default in XML format.
:raises urllib.error.URLError: If there's a network error.
"""
warnings.warn(
"The Bio.Entrez.egquery function is deprecated and will be removed "
"in a future release of Biopython because the underlying NCBI EGQuery "
"API is no longer maintained.",
BiopythonDeprecationWarning,
)
cgi = "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/egquery.fcgi"
variables = {}
variables.update(keywds)
Expand Down
6 changes: 6 additions & 0 deletions DEPRECATED.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ was deprecated as of Release 1.70.
Biopython modules, methods, functions
=====================================

Bio.Entrez
----------
The ``egquery`` function wrapping the NCBI EGQuery (Entrez Global Query)
API was deprecated in Release 1.84. The API has stopped working and the
NCBI said this API was no longer being maintained.

Bio.AlignInfo
-------------
The ``pos_specific_score_matrix`` method of the ``SummaryInfo`` class and the
Expand Down
16 changes: 0 additions & 16 deletions Tests/test_Entrez_online.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,22 +180,6 @@ def test_epost(self):
stream = Entrez.epost("nuccore", id=["160418", "160351"])
stream.close()

def test_egquery(self):
"""Test Entrez.egquery.
which searches in all Entrez databases for a single text query.
"""
stream = Entrez.egquery(term="biopython")
record = Entrez.read(stream)
stream.close()

done = False
for row in record["eGQueryResult"]:
if "pmc" in row["DbName"]:
self.assertGreater(int(row["Count"]), 60)
done = True
self.assertTrue(done)

def test_espell(self):
"""Test misspellings with Entrez.espell."""
stream = Entrez.espell(term="biopythooon")
Expand Down

0 comments on commit 3a39de9

Please sign in to comment.