<div dir="ltr">Thanks Peter,<div><br></div><div>As desperate solution, I've done that:</div><div><br></div><div><div>from __future__ import print_function</div><div>import gzip</div><div>from Bio import SeqIO</div><div>from io import StringIO</div><div>data = gzip.open("file.fasta.gz", "r").read()</div><div>record = SeqIO.parse(StringIO(data.decode()), "fasta")</div><div>for rr in record:</div><div> print(<a href="http://rr.id">rr.id</a>)</div></div><div><br></div><div>But I will follow your suggestion.</div><div><br></div><div>Cheers,</div><div><br></div><div>Alan</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 15 March 2017 at 22:43, Peter Cock <span dir="ltr"><<a href="mailto:p.j.a.cock@googlemail.com" target="_blank">p.j.a.cock@googlemail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Alan,<br>
<br>
Its a really strange error message isn't it? The good<br>
news is its easy to fix.<br>
<br>
Its due to a Python 3 bug / design choice, gzip.open<br>
defaults to bytes so you need to use mode "rt". See:<br>
<br>
<a href="http://bugs.python.org/issue13989" rel="noreferrer" target="_blank">http://bugs.python.org/<wbr>issue13989</a><br>
<br>
We've updated the examples in the tutorial ready for<br>
Biopython 1.69<br>
<br>
See eg<br>
<br>
<a href="https://github.com/biopython/biopython/issues/1009" rel="noreferrer" target="_blank">https://github.com/biopython/<wbr>biopython/issues/1009</a><br>
<a href="https://github.com/biopython/biopython/commit/63194ccff5d72ee78c4bcd1ba72173b8cf3d19f9" rel="noreferrer" target="_blank">https://github.com/biopython/<wbr>biopython/commit/<wbr>63194ccff5d72ee78c4bcd1ba72173<wbr>b8cf3d19f9</a><br>
<br>
Peter<br>
<div><div class="h5"><br>
On Wed, Mar 15, 2017 at 9:25 PM, Alan <<a href="mailto:alanwilter@gmail.com">alanwilter@gmail.com</a>> wrote:<br>
> Please, what do I need to change in this example that works fine in python2<br>
> but not in python3:<br>
><br>
> from __future__ import print_function<br>
> import gzip<br>
> from Bio import SeqIO<br>
> handle = gzip.open("file.fasta.gz", "r")<br>
> record = SeqIO.parse(handle, "fasta")<br>
> for rr in record:<br>
> print(<a href="http://rr.id" rel="noreferrer" target="_blank">rr.id</a>)<br>
><br>
> IndexError: index out of range<br>
><br>
> Thanks,<br>
><br>
> Alan<br>
><br>
</div></div>> ______________________________<wbr>_________________<br>
> Biopython mailing list - <a href="mailto:Biopython@mailman.open-bio.org">Biopython@mailman.open-bio.org</a><br>
> <a href="http://mailman.open-bio.org/mailman/listinfo/biopython" rel="noreferrer" target="_blank">http://mailman.open-bio.org/<wbr>mailman/listinfo/biopython</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Alan Wilter SOUSA da SILVA, DSc<div>Senior Bioinformatician, UniProt</div><div>European Bioinformatics Institute (EMBL-EBI)</div><div>European Molecular Biology Laboratory</div><div>Wellcome Trust Genome Campus</div><div>Hinxton</div><div>Cambridge CB10 1SD</div><div>United Kingdom</div><div>Tel: +44 (0)1223 494588</div></div></div></div></div></div></div>
</div>