[Biopython] Fwd: Bug in bgzf module

Peter Cock p.j.a.cock at googlemail.com
Wed Jan 30 22:12:39 UTC 2013


On Wed, Jan 30, 2013 at 9:50 PM, Petra Kubincová
<petra.kubincova at gmail.com> wrote:
> Hello,
>
> recently I have installed and tried out biopython 1.60, especially bgzf
> module. I have discovered that calling method "tell()" of object of
> bgzf.BgzfWriter type raises this error:
>
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "/usr/local/lib/python2.6/dist-packages/Bio/bgzf.py", line 743, in
> tell
>     return make_virtual_offset(self.handle.tell(), len(self._buffer))
> AttributeError: 'BgzfWriter' object has no attribute 'handle'
>
> I've checked out source code of bgzf module. Source code of error-raising
> method "tell()" looks like this:
>
> def tell(self):
>     """Returns a BGZF 64-bit virtual offset."""
>     return make_virtual_offset(self.handle.tell(), len(self._buffer))
>
> The problem is that BgzfWriter does not have variable called "handle", only
> "_handle". So (IMHO) all that needs to be done to fix this bug is change
> "self.handle.tell()" to "self._handle.tell()".
>
> Cheers,
> Petra Kubincova

Hi Petra,

It is nice to know people are using this relatively new code :)

Thank you for pointing that out, that is the correct fix:
https://github.com/biopython/biopython/commit/2a1be2f3e9b731fa05cc4ad7a01a67866155827c

We should add a unit test for this too, in Tests/test_bgzf.py -
is that something you'd like to try and do? If not I'll try to
remember to add something myself.

The reason I implemented the BgzfWriter tell method was for
the use-case of writing a BGZF compressed file while also
recording an index. I'm curious if that's what you are doing,
or if you had another purpose?

Thanks,

Peter




More information about the Biopython mailing list