[Biopython-dev] Bug in Bio.Blast.NCBIWWW ?

Brad Chapman chapmanb at 50mail.com
Wed Jan 25 02:14:58 UTC 2012


Micheal;
Thanks for the e-mail and problem report. For Biopython issues, the best
approach is to e-mail the development list (cc'ed here). Since it's a
community project, there are a wide variety of contributors that can
provide help and expertise.

In this particular case, I am not especially familiar with python 3 as
I'm still a python 2 user myself. Peter, Eric and other folks have been
doing a lot of work on this, so hopefully they can confirm or provide
additional details.

Thanks again,
Brad

> Dear Mr. Chapman,
> 
> I perhaps found a bug in the Bio.Blast.NCBIWWW module.
> But since I'm using Python 3.2.2 and didn't test this with Python2.x, I don't know if this is a Python2/Python3 issue.
> 
> When I try to execute the following line of code (where contig is a string):
> 
>     resultHandle = NCBIWWW.qblast('blastn', 'nr', contig)
> 
> I get the following error message:
> 
> Traceback (most recent call last):
>   File "/home/michael/python/gb/sheet11/ex80_all-contigs.py", line 575, in <module>
>     blastContig(contigs[i])
>   File "/home/michael/python/gb/sheet11/ex80_all-contigs.py", line 441, in blastContig
>     resultHandle = NCBIWWW.qblast('blastn', 'nr', contig, hitlist_size=1)
>   File "/usr/local/lib/python3.2/dist-packages/Bio/Blast/NCBIWWW.py", line 122, in qblast
>     handle = urllib.request.urlopen(request)
>   File "/usr/lib/python3.2/urllib/request.py", line 138, in urlopen
>     return opener.open(url, data, timeout)
>   File "/usr/lib/python3.2/urllib/request.py", line 367, in open
>     req = meth(req)
>   File "/usr/lib/python3.2/urllib/request.py", line 1066, in do_request_
>     raise TypeError("POST data should be bytes"
> TypeError: POST data should be bytes or an iterable of bytes. It cannot be str.
> 
> 
> After trying different things, I found that this can be fixed by replacing
> 
>     message = urllib.parse.urlencode(query)
> 
> in lines 113 and 145 in the NCBIWWW.py script by
> 
>     message = urllib.parse.urlencode(query, encoding='ascii')
>     message = bytes(message, 'ascii')
> 
> If this is not a Python2/Python3 thing, you perhaps want to use this fix for the next version of Biopython.
> 
> Yours sincerely,
> Michael Grauvogl
> 
> 
Non-text part: text/html



More information about the Biopython-dev mailing list