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