Question: How to write a BGZF file with Biopython?
0
gravatar for mrals89
8 months ago by
mrals8950
United States
mrals8950 wrote:

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 • 282 views
ADD COMMENTlink written 8 months ago by mrals8950
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2106 users visited in the last hour