bio-bgzf 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/bio-bgzf/block.rb +4 -4
- data/lib/bio-bgzf/pack.rb +1 -1
- data/spec/bio-bgzf_spec.rb +9 -0
- data/test/data/mm8.chrM.maf.gz +0 -0
- metadata +3 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/bio-bgzf/block.rb
CHANGED
@@ -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
|
data/lib/bio-bgzf/pack.rb
CHANGED
data/spec/bio-bgzf_spec.rb
CHANGED
@@ -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.
|
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:
|
108
|
+
hash: 887449106420092676
|
108
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
110
|
none: false
|
110
111
|
requirements:
|