How to write a BGZF file with Biopython?
0
0
Entering edit mode
4.5 years ago
mrals89 ▴ 50

Hi everyone, I've read the documentation for Bio.bgzf and I'm sufficiently confused by it.

To create an example bgzf file, I've tried the following. The write method internally uses _write_block which AFAICT adds a bgzf header. The close method flushes and adds the EOF marker.

from Bio import bgzf

header="hello\nworld\somestuff"
text="an\nexample\nbody"

test=bgzf.BgzfWriter("helloworld.bgzf")
test.write(header)
test.write(text)
test.close() # works fine

But when parsing, I'm getting a ValueError when parsing the file. zcat works just fine at the command line.

infile=bgzf.BgzfReader("helloworld.bgzf")
for values in bgzf.BgzfBlocks(infile):
   print("Raw start %i, raw length %i; data start %i, data length %i" % values)
...
ValueError: A BGZF (e.g. a BAM file) block should start with b'\x1f\x8b\x08\x04', not 'hell'; handle.tell() now says 4
biopython bgzf • 1.6k views
ADD COMMENT

Login before adding your answer.

Traffic: 1787 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6