bio-bgzf 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -36,14 +36,14 @@ module Bio::BGZF
36
36
  def decompress_block(f)
37
37
  cdata, in_size, expected_crc = read_bgzf_block(f)
38
38
  return nil if cdata == nil
39
- crc = Zlib.crc32(cdata, 0)
40
- if crc != expected_crc
41
- raise "CRC error: expected #{expected_crc.to_s(16)}, got #{crc.to_s(16)}"
42
- end
43
39
  data = unpack(cdata)
44
40
  if data.bytesize != in_size
45
41
  raise "Expected #{in_size} bytes from BGZF block at #{pos}, but got #{data.bytesize} bytes!"
46
42
  end
43
+ crc = Zlib.crc32(data, 0)
44
+ if crc != expected_crc
45
+ raise "CRC error: expected #{expected_crc.to_s(16)}, got #{crc.to_s(16)}"
46
+ end
47
47
  return data
48
48
  end
49
49
  module_function :decompress_block
@@ -9,7 +9,7 @@ module Bio::BGZF
9
9
  cdata = zs.deflate str, Zlib::FINISH
10
10
  zs.close
11
11
 
12
- crc32 = Zlib.crc32 cdata, 0
12
+ crc32 = Zlib.crc32 str, 0
13
13
  isize = str.length
14
14
 
15
15
  bsize = cdata.length + 19 + XLEN
@@ -8,6 +8,15 @@ describe Bio::BGZF do
8
8
  Bio::BGZF.pack("asdfghjkl").should be_instance_of String
9
9
  end
10
10
 
11
+ it "should be able to read BGZF blocks from a samtools file" do
12
+ File.open("test/data/mm8.chrM.maf.gz") do |f|
13
+ r = Bio::BGZF::Reader.new(f)
14
+ r.each_block do |block|
15
+ block.size.should <= 65536
16
+ end
17
+ end
18
+ end
19
+
11
20
  it "should be able to iteratively read BGZF blocks from stream" do
12
21
  str = ''
13
22
  1000.times { str += (Random.rand(26) + 65).chr }
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bio-bgzf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -89,6 +89,7 @@ files:
89
89
  - lib/bio-bgzf/unpack.rb
90
90
  - lib/bio-bgzf/vo.rb
91
91
  - spec/bio-bgzf_spec.rb
92
+ - test/data/mm8.chrM.maf.gz
92
93
  homepage: http://github.com/csw/bioruby-bgzf
93
94
  licenses:
94
95
  - MIT
@@ -104,7 +105,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
104
105
  version: '0'
105
106
  segments:
106
107
  - 0
107
- hash: -2167366817840907754
108
+ hash: 887449106420092676
108
109
  required_rubygems_version: !ruby/object:Gem::Requirement
109
110
  none: false
110
111
  requirements: