Skip to content

Commit 3ae0da4

Browse files
committed
Add test for bgzip, make sure peek is checked
1 parent c7e8af4 commit 3ae0da4

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/isal/igzip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ def __init__(self, fp):
266266
self._new_member = True
267267
self._last_mtime = None
268268
self._read_buffer_size = READ_BUFFER_SIZE
269-
if detect_bgzip(fp.peek(18)):
269+
if hasattr(fp, "peek") and detect_bgzip(fp.peek(18)):
270270
# bgzip consists of puny little blocks of max 64K uncompressed data
271271
# so in practice probably more around 16K in compressed size. A
272272
# 128K buffer is a massive overshoot and slows down the

tests/data/test.fastq.bgzip.gz

1.48 MB
Binary file not shown.

tests/test_igzip.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,3 +443,13 @@ def test_concatenated_gzip():
443443
with igzip.open(concat, "rb") as igzip_h:
444444
result = igzip_h.read()
445445
assert data == result
446+
447+
448+
def test_bgzip():
449+
bgzip_file = Path(__file__).parent / "data" / "test.fastq.bgzip.gz"
450+
gzip_file = Path(__file__).parent / "data" / "test.fastq.gz"
451+
with igzip.open(bgzip_file, "rb") as bgz:
452+
bgz_data = bgz.read()
453+
with igzip.open(gzip_file, "rb") as gz:
454+
gz_data = gz.read()
455+
assert bgz_data == gz_data

0 commit comments

Comments
 (0)