[Biopython-dev] Bio/SearchIO/BlastIO/blast_xml.py output under Python 2.7.4

Wibowo Arindrarto bow at bow.web.id
Mon Apr 8 17:02:39 UTC 2013


Hi Peter, everyone,

This is reproducible in my machine (which just happen to update its default
Python2.x to 2.7.4 actually). Looks like they changed the underlying SAX
XML writer (xml.sax.saxutils.XMLGenerator ~ which the SearchIO blast_xml
writer subclasses). The new write() method calls the
io.TextIOWrapper.write() function, which expects unicode only.

See the comparison here:
Python2.7.3 (
http://hg.python.org/cpython/file/70274d53c1dd/Lib/xml/sax/saxutils.py#l84)
vs Python2.7.4 (
http://hg.python.org/cpython/file/026ee0057e2d/Lib/xml/sax/saxutils.py#l109).
Also, here's the io module doc page for reference:
http://docs.python.org/2/library/io.html

I'll write up a Python <=2.7.3-compatible patch to fix this soon, if
everybody's ok with it :).

Cheers,
Bow


On Mon, Apr 8, 2013 at 5:28 PM, Peter Cock <p.j.a.cock at googlemail.com>wrote:

> Hi Bow,
>
> I've just updated the 64bit Linux buildslave from Python 2.7.3 to
> 2.7.4 and there
> is a new unicode failure with the BLAST XML writing code in SearchIO
> (below).
>
> Can you reproduce this? Keep in mind this could be a new bug in Python
> itself ;)
>
> Separately the are some BGZF issues, see also this thread:
> http://lists.open-bio.org/pipermail/biopython/2013-April/008490.html
>
> Thanks,
>
> Peter
>
> ======================================================================
> ERROR: test_write_multiple_from_blastxml
> (test_SearchIO_write.BlastXmlWriteCases)
> Test blast-xml writing from blast-xml, BLAST 2.2.26+, multiple queries
> (xml_2226_blastp_001.xml)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "test_SearchIO_write.py", line 55, in
> test_write_multiple_from_blastxml
>     self.parse_write_and_compare(source, self.fmt, self.out, self.fmt)
>   File "test_SearchIO_write.py", line 27, in parse_write_and_compare
>     SearchIO.write(source_qresults, out_file, out_format, **kwargs)
>   File
> "/home_local/buildslave/repositories/biopython/build/lib.linux-x86_64-2.7/Bio/SearchIO/__init__.py",
> line 610, in write
>     writer.write_file(qresults)
>   File
> "/home_local/buildslave/repositories/biopython/build/lib.linux-x86_64-2.7/Bio/SearchIO/BlastIO/blast_xml.py",
> line 695, in write_file
>     xml.startDocument()
>   File
> "/home_local/buildslave/repositories/biopython/build/lib.linux-x86_64-2.7/Bio/SearchIO/BlastIO/blast_xml.py",
> line 612, in startDocument
>     self.write('<?xml version="1.0"?>\n'
>   File "/home_local/buildslave/lib/python2.7/xml/sax/saxutils.py",
> line 103, in write
>     super(UnbufferedTextIOWrapper, self).write(s)
> TypeError: must be unicode, not str
>
> ======================================================================
> ERROR: test_write_single_from_blastxml
> (test_SearchIO_write.BlastXmlWriteCases)
> Test blast-xml writing from blast-xml, BLAST 2.2.26+, single query
> (xml_2226_blastp_004.xml)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "test_SearchIO_write.py", line 49, in
> test_write_single_from_blastxml
>     self.parse_write_and_compare(source, self.fmt, self.out, self.fmt)
>   File "test_SearchIO_write.py", line 27, in parse_write_and_compare
>     SearchIO.write(source_qresults, out_file, out_format, **kwargs)
>   File
> "/home_local/buildslave/repositories/biopython/build/lib.linux-x86_64-2.7/Bio/SearchIO/__init__.py",
> line 610, in write
>     writer.write_file(qresults)
>   File
> "/home_local/buildslave/repositories/biopython/build/lib.linux-x86_64-2.7/Bio/SearchIO/BlastIO/blast_xml.py",
> line 695, in write_file
>     xml.startDocument()
>   File
> "/home_local/buildslave/repositories/biopython/build/lib.linux-x86_64-2.7/Bio/SearchIO/BlastIO/blast_xml.py",
> line 612, in startDocument
>     self.write('<?xml version="1.0"?>\n'
>   File "/home_local/buildslave/lib/python2.7/xml/sax/saxutils.py",
> line 103, in write
>     super(UnbufferedTextIOWrapper, self).write(s)
> TypeError: must be unicode, not str
>



More information about the Biopython-dev mailing list