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

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.7k views
ADD COMMENT

Login before adding your answer.

Traffic: 1850 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