lib/bio-bgzf/block.rb in bio-bgzf-0.1.0 vs lib/bio-bgzf/block.rb in bio-bgzf-0.1.1
- old
+ new
@@ -34,16 +34,16 @@
module_function :read_bgzf_block
def decompress_block(f)
cdata, in_size, expected_crc = read_bgzf_block(f)
return nil if cdata == nil
- crc = Zlib.crc32(cdata, 0)
- if crc != expected_crc
- raise "CRC error: expected #{expected_crc.to_s(16)}, got #{crc.to_s(16)}"
- end
data = unpack(cdata)
if data.bytesize != in_size
raise "Expected #{in_size} bytes from BGZF block at #{pos}, but got #{data.bytesize} bytes!"
+ end
+ crc = Zlib.crc32(data, 0)
+ if crc != expected_crc
+ raise "CRC error: expected #{expected_crc.to_s(16)}, got #{crc.to_s(16)}"
end
return data
end
module_function :decompress_block