[Biopython-dev] Bio.Wise
Michiel De Hoon
mdehoon at c2b2.columbia.edu
Wed Aug 8 02:57:23 UTC 2007
Hi everybody,
Bio.Wise currently causes a deprecation warning when running the Biopython
tests (using Biopython from CVS).
This warning is caused by the deprecated Bio.SeqIO.FASTA:
# In Bio.Wise.__init__.py:
from Bio.SeqIO.FASTA import FastaReader, FastaWriter
The FastaReader, FastaWriter functions are used as follows:
for filename, input_file in zip(pair, input_files):
input_file.close()
FastaWriter(file(input_file.name,
"w")).write(FastaReader(file(filename)).next())
To me, it looks like all this does is to read one Fasta record from filename,
and then store it in input_file.
I was wondering why we go through the Fasta reader/writer instead of
reading/writing the file contents directly, as in
for filename, input_file in zip(pair, input_files):
input_file.close()
file(input_file.name, "w").write(file(filename).read())
On a related note, the input_file refers to a temporary file. To create this
temporary file, Bio.Wise prefers to use NamedTemporaryFile in the poly
module, instead of NamedTemporaryFile in the tempfile module:
try:
import poly
_NamedTemporaryFile = poly.NamedTemporaryFile
except ImportError:
import tempfile
try:
_NamedTemporaryFile = tempfile.NamedTemporaryFile
except AttributeError: # no NamedTemporaryFile on 2.2, stuck without it
_NamedTemporaryFile = tempfile.TemporaryFile
The tempfile module is in the Python standard library, the poly module is
not.
Is using the poly module still relevant?
I am asking since the current code in Bio.Wise does not seem to be handling
temporary files correctly, and it'll be easier to fix it if we don't have to
consider both poly.NamedTemporaryFile and tempfile.NamedTemporaryFile.
--Michiel.
Michiel de Hoon
Center for Computational Biology and Bioinformatics
Columbia University
1150 St Nicholas Avenue
New York, NY 10032
More information about the Biopython-dev
mailing list