Skip to content

Commit b4a0d81

Browse files
authored
Remove code that was deprecated in 1.85 (#5144)
1 parent 0d829a8 commit b4a0d81

11 files changed

Lines changed: 57 additions & 174 deletions

File tree

Bio/Entrez/__init__.py

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@
136136
from urllib.request import Request
137137
from urllib.request import urlopen
138138

139-
from Bio import BiopythonDeprecationWarning
140139
from Bio._utils import function_with_previous
141140

142141
email = None
@@ -345,46 +344,6 @@ def esummary(**keywds):
345344
return _open(request)
346345

347346

348-
def egquery(**keywds):
349-
"""Provide Entrez database counts for a global search (DEPRECATED).
350-
351-
EGQuery provided Entrez database counts in XML for a single search
352-
using Global Query. However, the NCBI are no longer maintaining this
353-
function and suggest using esearch on each database of interest.
354-
355-
See the online documentation for an explanation of the parameters:
356-
http://www.ncbi.nlm.nih.gov/books/NBK25499/#chapter4.EGQuery
357-
358-
This quick example based on a longer version from the Biopython
359-
Tutorial just checks there are over 60 matches for 'Biopython'
360-
in PubMedCentral:
361-
362-
>>> from Bio import Entrez
363-
>>> Entrez.email = "Your.Name.Here@example.org"
364-
>>> handle = Entrez.egquery(term="biopython") # doctest: +SKIP
365-
>>> record = Entrez.read(handle) # doctest: +SKIP
366-
>>> handle.close() # doctest: +SKIP
367-
>>> for row in record["eGQueryResult"]: # doctest: +SKIP
368-
... if "pmc" in row["DbName"]: # doctest: +SKIP
369-
... print(int(row["Count"]) > 60) # doctest: +SKIP
370-
True
371-
372-
:returns: Handle to the results, by default in XML format.
373-
:raises urllib.error.URLError: If there's a network error.
374-
"""
375-
warnings.warn(
376-
"The Bio.Entrez.egquery function is deprecated and will be removed "
377-
"in a future release of Biopython because the underlying NCBI EGQuery "
378-
"API is no longer maintained.",
379-
BiopythonDeprecationWarning,
380-
)
381-
cgi = "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/egquery.fcgi"
382-
variables = {}
383-
variables.update(keywds)
384-
request = _build_request(cgi, variables)
385-
return _open(request)
386-
387-
388347
def espell(**keywds):
389348
"""Retrieve spelling suggestions as a results handle.
390349

Bio/SeqIO/FastaIO.py

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -199,40 +199,27 @@ def __init__(
199199
line = None
200200
else:
201201
if not line.startswith(">"):
202-
warnings.warn(
203-
"Previously, the FASTA parser silently ignored comments at the "
204-
"beginning of the FASTA file (before the first sequence).\n"
205-
"\n"
206-
"Nowadays, the FASTA file format is usually understood not to "
207-
"have any such comments, and most software packages do not allow "
208-
"them. Therefore, the use of comments at the beginning of a FASTA "
209-
"file is now deprecated in Biopython.\n"
210-
"\n"
211-
"In a future Biopython release, this deprecation warning will be "
212-
"replaced by a ValueError. To avoid this, there are three "
213-
"options:\n"
214-
"\n"
215-
"(1) Modify your FASTA file to remove such comments at the "
216-
"beginning of the file.\n"
217-
"\n"
218-
"(2) Use SeqIO.parse with the 'fasta-pearson' format instead of "
219-
"'fasta'. This format is consistent with the FASTA format defined "
220-
"by William Pearson's FASTA aligner software. This format allows "
221-
"for comments before the first sequence; lines starting with the "
222-
"';' character anywhere in the file are also regarded as comment "
223-
"lines and are ignored.\n"
224-
"\n"
225-
"(3) Use the 'fasta-blast' format. This format regards any lines "
226-
"starting with '!', '#', or ';' as comment lines. The "
227-
"'fasta-blast' format may be safer than the 'fasta-pearson' "
228-
"format, as it explicitly indicates which lines are comments. ",
229-
BiopythonDeprecationWarning,
202+
raise ValueError(
203+
"""\
204+
This FASTA file contains comments at the beginning of the file, which are not
205+
allowed by the 'fasta' parser.
206+
207+
To parse this file, you have three options:
208+
209+
(1) Modify your FASTA file to remove such comments at the beginning of the
210+
file.
211+
212+
(2) Use SeqIO.parse with the 'fasta-pearson' format instead of 'fasta'. This
213+
format is consistent with the FASTA format defined by William Pearson's FASTA
214+
aligner software. This format allows for comments before the first sequence;
215+
lines starting with the ';' character anywhere in the file are also regarded
216+
as comment lines and are ignored.
217+
218+
(3) Use the 'fasta-blast' format. This format regards any lines "starting with
219+
'!', '#', or ';' as comment lines. The 'fasta-blast' format may be safer than
220+
the 'fasta-pearson' format, as it explicitly indicates which lines are comments.
221+
"""
230222
)
231-
for line in self.stream:
232-
if line.startswith(">"):
233-
break
234-
else:
235-
line = None
236223
self._line = line
237224

238225
def __next__(self):

Bio/SeqIO/UniprotIO.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from xml.etree import ElementTree
2121
from xml.parsers.expat import errors
2222

23-
from Bio import BiopythonDeprecationWarning, SeqFeature
23+
from Bio import SeqFeature
2424
from Bio.Seq import Seq
2525
from Bio.SeqRecord import SeqRecord
2626

@@ -33,7 +33,7 @@
3333
class UniprotIterator(SequenceIterator):
3434
"""Parser for UniProt XML files, returning SeqRecord objects."""
3535

36-
modes = "bt"
36+
modes = "b"
3737

3838
def __init__(
3939
self,
@@ -57,16 +57,6 @@ def __init__(
5757
if alphabet is not None:
5858
raise ValueError("The alphabet argument is no longer supported")
5959
super().__init__(source, fmt="UniProt XML")
60-
if self.mode == "t":
61-
warnings.warn(
62-
"Opening a UniProt XML file in text mode is "
63-
"deprecated, as it may lead to garbled characters. "
64-
"We recommend opening the file in binary mode; "
65-
"parsing UniProt XML files opened in text mode will "
66-
"no longer be supported in a future release of "
67-
"Biopython.",
68-
BiopythonDeprecationWarning,
69-
)
7060
self.return_raw_comments = return_raw_comments
7161
self._data = ElementTree.iterparse(
7262
self.stream, events=("start", "start-ns", "end")

Bio/SeqUtils/ProtParam.py

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@
5151

5252
import functools
5353
import sys
54-
import warnings
5554

56-
from Bio import BiopythonDeprecationWarning
5755
from Bio.Data import IUPACData
5856
from Bio.Seq import Seq
5957
from Bio.SeqUtils import IsoelectricPoint # Local
@@ -101,26 +99,13 @@ def count_amino_acids(self):
10199

102100
return self.amino_acids_content
103101

104-
def get_amino_acids_percent(self):
105-
"""Included for backwards compatibility (DEPRECATED)."""
106-
warnings.warn(
107-
"The get_amino_acids_percent method has been deprecated "
108-
"and will likely be removed from Biopython in the near "
109-
"future. Please use the amino_acids_percent attribute instead.",
110-
BiopythonDeprecationWarning,
111-
)
112-
113-
return {aa: percent / 100 for aa, percent in self.amino_acids_percent.items()}
114-
115102
@functools.cached_property
116103
def amino_acids_percent(self):
117104
"""Get the amino acid content in percentages.
118105
119-
The same as count_amino_acids only returns the Number in percentage of
120-
entire sequence. Returns a dictionary of {AminoAcid:percentage}.
121-
122-
Unlike the deprecated get_amino_acids_percent method, this attribute
123-
returns percentages in the range 0-100.
106+
The same as count_amino_acids, but returns the number as a percentage
107+
of the sequence length. Returns a dictionary of {AminoAcid:percentage},
108+
where the percentage is in the range 0-100.
124109
"""
125110
aa_counts = self.count_amino_acids()
126111
percentages = {

Bio/motifs/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
and MAST programs, as well as files in the TRANSFAC format.
1616
"""
1717

18-
import warnings
1918
from urllib.parse import urlencode
2019
from urllib.request import Request
2120
from urllib.request import urlopen

Bio/motifs/meme.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
from Bio.Seq import Seq
1414

1515

16-
import warnings
17-
from Bio import BiopythonDeprecationWarning
18-
19-
2016
def read(handle):
2117
"""Parse the text output of the MEME program into a meme.Record object.
2218
@@ -77,28 +73,6 @@ def __init__(self, alphabet=None, alignment=None):
7773
self.alt_id = None
7874

7975

80-
class Instance(Seq):
81-
"""A class describing the instances of a MEME motif, and the data thereof."""
82-
83-
def __init__(self, *args, **kwds):
84-
"""Initialize the class."""
85-
warnings.warn(
86-
"The class Bio.motifs.meme.Instance is deprecated, as it does not "
87-
"provide any real advantages compared to the Seq class from which "
88-
"it is derived. Please use the Seq class directly instead of the "
89-
"Instance class.",
90-
BiopythonDeprecationWarning,
91-
)
92-
Seq.__init__(self, *args, **kwds)
93-
self.sequence_name = ""
94-
self.sequence_id = ""
95-
self.start = 0
96-
self.pvalue = 1.0
97-
self.strand = 0
98-
self.length = 0
99-
self.motif_name = ""
100-
101-
10276
class Record(list):
10377
"""A class for holding the results of a MEME run.
10478

DEPRECATED.rst

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Parsing a FASTA file using Bio.SeqIO.parse with ``format='fasta'`` interprets
6767
lines before the first line starting with '>' as comments and skips them. To be
6868
consistent with the most common interpretation of the FASTA file format, the
6969
use of such comment lines at the beginning of the FASTA file was deprecated in
70-
Biopython Release 1.85.
70+
Biopython Release 1.85, and removed in Biopython release 1.87.
7171
As an alternative, you can use ``format='fasta-pearson'`` to specify the FASTA
7272
file format as defined by William Pearson's FASTA aligner program, allowing for
7373
comment lines at the top of the FASTA file (lines anywhere in the file starting
@@ -94,17 +94,18 @@ Please use ``format(record, "tab")`` instead.
9494

9595
Bio.SeqIO.UniprotIO
9696
-------------------
97-
Parsing a UniProt XML file opened in text mode (if the file was opened using
98-
``open("myuniprotfile.xml")``) was deprecated in Release 1.85, as this may lead
99-
to garbled characters. Please open the file in binary mode (as in
100-
``open("myuniprotfile.xml", "rb")``), or let ``Bio.SeqIO.parse`` take care of
101-
opening and closing files by passing the file name instead of a file handle.
97+
The ability to parse a UniProt XML file opened in text mode (if the file was
98+
opened using ``open("myuniprotfile.xml")``) was deprecated in Release 1.85 and
99+
removed in Release 1.87, as this may lead to garbled characters. Please open
100+
the file in binary mode (as in ``open("myuniprotfile.xml", "rb")``), or let
101+
``Bio.SeqIO.parse`` take care of opening and closing files by passing the file
102+
name instead of a file handle.
102103

103104
Bio.Entrez
104105
----------
105106
The ``egquery`` function wrapping the NCBI EGQuery (Entrez Global Query)
106-
API was deprecated in Release 1.84. The API has stopped working and the
107-
NCBI said this API was no longer being maintained.
107+
API was deprecated in Release 1.84, and removed in Release 1.87. The API has
108+
stopped working and the NCBI said this API was no longer being maintained.
108109

109110
Bio.SCOP
110111
--------
@@ -251,9 +252,9 @@ The ``instances`` attribute of the ``Motif`` class in ``Bio.motifs`` was
251252
deprecated in release 1.82, and removed in release 1.86. Instead of
252253
``mymotif.instances``, please use ``mymotif.alignment.sequences``.
253254

254-
The ``Instance`` class in ``Bio.motifs.meme`` was deprecated in release 1.85.
255-
This class is a subclass from ``Seq``, but does not provide any additional
256-
capabilities. Please use a ``Seq`` object instead.
255+
The ``Instance`` class in ``Bio.motifs.meme`` was deprecated in release 1.85,
256+
and removed in release 1.87. This class is a subclass from ``Seq``, but does
257+
not provide any additional capabilities. Please use a ``Seq`` object instead.
257258

258259
Bio.Restriction.RanaConfig
259260
--------------------------
@@ -590,7 +591,8 @@ Function 'GC' in Bio.SeqUtils was deprecated in Release 1.80, and removed in
590591
Release 1.82. Instead use function 'gc_fraction'.
591592

592593
Function get_amino_acids_percent in Bio.SeqUtils.ProteinAnalysis was deprecated
593-
in Release 1.85. Use the amino_acids_percent property instead.
594+
in Release 1.85, and removed in Release 1.87. Use the amino_acids_percent
595+
property instead.
594596

595597
Bio.PopGen.Async
596598
----------------

Tests/test_ProtParam.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import unittest
1111

12-
from Bio import BiopythonDeprecationWarning
1312
from Bio.Seq import Seq
1413
from Bio.SeqRecord import SeqRecord
1514
from Bio.SeqUtils import molecular_weight
@@ -39,17 +38,6 @@ def test_count_amino_acids(self):
3938
for i in count_dict:
4039
self.assertEqual(count_dict[i], self.text.count(i))
4140

42-
def test_get_amino_acids_percent(self):
43-
"""Calculate amino acid percentages (DEPRECATED)."""
44-
with self.assertWarns(BiopythonDeprecationWarning):
45-
for analysis in self.analyses:
46-
percent_dict = analysis.get_amino_acids_percent()
47-
seq_len = len(self.text)
48-
for i in percent_dict:
49-
self.assertAlmostEqual(
50-
percent_dict[i], self.text.count(i) / seq_len
51-
)
52-
5341
def test_amino_acids_percent(self):
5442
"""Calculate amino acid percentages."""
5543
for analysis in self.analyses:

Tests/test_SeqIO.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
from Bio import AlignIO
1717
from Bio import BiopythonParserWarning
18-
from Bio import BiopythonDeprecationWarning
1918
from Bio import BiopythonWarning
2019
from Bio import SeqIO
2120
from Bio import StreamModeError
@@ -70,8 +69,6 @@ def get_mode(cls, fmt):
7069
SeqIO.read(stream, fmt)
7170
except StreamModeError:
7271
continue
73-
except BiopythonDeprecationWarning: # uniprot-xml
74-
continue
7572
except ValueError as exception:
7673
# If the mode is correct, then SeqIO.read will complain
7774
# that the stream is empty,

Tests/test_SeqIO_FastaIO.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
from Bio.SeqIO.FastaIO import FastaTwoLineParser
1313
from Bio.SeqIO.FastaIO import SimpleFastaParser
1414

15-
from Bio import BiopythonDeprecationWarning
16-
1715

1816
def title_to_ids(title):
1917
"""Convert a FASTA title line into the id, name, and description.
@@ -226,10 +224,8 @@ def test_valueerrors(self):
226224
self.assertRaises(
227225
ValueError, SeqIO.read, "Fasta/aster_pearson.pro", "fasta-blast"
228226
)
229-
with self.assertWarns(BiopythonDeprecationWarning):
230-
record = SeqIO.read("Fasta/aster_pearson.pro", "fasta")
231-
with self.assertWarns(BiopythonDeprecationWarning):
232-
record = SeqIO.read("Fasta/aster_blast.pro", "fasta")
227+
self.assertRaises(ValueError, SeqIO.read, "Fasta/aster_pearson.pro", "fasta")
228+
self.assertRaises(ValueError, SeqIO.read, "Fasta/aster_blast.pro", "fasta")
233229

234230

235231
if __name__ == "__main__":

0 commit comments

Comments
 (0)