[Biopython] random access to bgz file
Peter Cock
p.j.a.cock at googlemail.com
Wed Apr 9 21:11:46 UTC 2014
On Wed, Apr 9, 2014 at 10:00 PM, Peter Cock <p.j.a.cock at googlemail.com> wrote:
> On Wed, Apr 9, 2014 at 6:35 PM, tc9 wrote:
>>
>> Trying to get the block offsets like this fails:
>>
>> import Bio
>> handle = Bio.bgzf.open('file.haps.bgz')
>> for values in Bio.bgzf.BgzfBlocks(handle):
>> print("Raw start %i, raw length %i; data start %i, data length %i" %
>> values)
>
> The BgzfBlocks function (which was intended for
> low level debugging originally) wants a raw handle
> (which should be opened in binary mode). I concede
> its docstring doesn't say that (yet) but its example
> show this. Try:
>
> from Bio import bgzf
> for values in bgzf.BgzfBlocks(open('file.haps.bgz', 'rb')):
> print("Raw start %i, raw length %i; data start %i, data length %i" % values)
>
> Peter
Hi again Tommy,
I have tried to clarify the BgzfBlocks docstring for
the next release,
https://github.com/biopython/biopython/commit/44e943fd5c1e1a2ee6d8520eb01ab5e8114b1b56
Please keep the questions coming - your feedback
is being very useful - e.g. the context manager
omission you reported earlier (off list):
https://github.com/biopython/biopython/commit/a669757305962202516a192d16166eb0870d8ebe
Thanks,
Peter
More information about the Biopython
mailing list