htslib 0.2.8 → 0.2.9
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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/hts/bam/auxi.rb +31 -27
- data/lib/hts/bam/flag.rb +8 -6
- data/lib/hts/bam/header.rb +43 -9
- data/lib/hts/bam/record.rb +68 -2
- data/lib/hts/bam.rb +1 -1
- data/lib/hts/bcf/header.rb +2 -0
- data/lib/hts/bcf.rb +2 -2
- data/lib/hts/libhts/constants.rb +13 -0
- data/lib/hts/libhts/cram.rb +113 -1
- data/lib/hts/libhts/hts.rb +1 -1
- data/lib/hts/libhts/sam.rb +20 -2
- data/lib/hts/libhts/tbx.rb +7 -0
- data/lib/hts/libhts/tbx_funcs.rb +7 -2
- data/lib/hts/libhts/vcf.rb +6 -0
- data/lib/hts/libhts/vcf_funcs.rb +2 -2
- data/lib/hts/version.rb +1 -1
- metadata +3 -73
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c98f3937d65f091e9e834060f3a94578034d1bf55e7bc372e5ed388e618a6da4
|
4
|
+
data.tar.gz: 8e180044fef210935695bc60c0352b747b570b705f3ce9318b7538d19ddaf645
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5324913bdbe97580fee1e54b6268f22aed2a0b84d449c8a4f62529981c82a57d6ae5cea7cc77ff1be7332425eea259bfe5daa1107b6144e36ef40bb4997dd28f
|
7
|
+
data.tar.gz: 7b230700951223aeda09d64fac7cca44d734d54ec03a7836c5a0fb036e552854db80b9ecaf57aa478e317c684e4712f2f03244e02474fd2ea53a4b93346d1371
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# ruby-htslib
|
2
2
|
|
3
3
|
[](https://badge.fury.io/rb/htslib)
|
4
|
-
](https://github.com/kojix2/ruby-htslib/actions/workflows/ci.yml)
|
5
5
|
[](LICENSE.txt)
|
6
6
|
[](https://zenodo.org/badge/latestdoi/247078205)
|
7
7
|
[](https://rubydoc.info/gems/htslib)
|
data/lib/hts/bam/auxi.rb
CHANGED
@@ -30,10 +30,10 @@ module HTS
|
|
30
30
|
# which provides methods like `get_int`, `get_float`, etc.
|
31
31
|
# I think they are better than `fetch_int`` and `fetch_float`.
|
32
32
|
def get(key, type = nil)
|
33
|
-
|
34
|
-
return nil if
|
33
|
+
aux_ptr = LibHTS.bam_aux_get(@record.struct, key)
|
34
|
+
return nil if aux_ptr.null?
|
35
35
|
|
36
|
-
get_ruby_aux(
|
36
|
+
get_ruby_aux(aux_ptr, type)
|
37
37
|
end
|
38
38
|
|
39
39
|
# For compatibility with HTS.cr.
|
@@ -56,43 +56,47 @@ module HTS
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def first
|
59
|
-
|
60
|
-
return nil if
|
59
|
+
aux_ptr = first_pointer
|
60
|
+
return nil if aux_ptr.null?
|
61
61
|
|
62
|
-
get_ruby_aux(
|
62
|
+
get_ruby_aux(aux_ptr)
|
63
63
|
end
|
64
64
|
|
65
65
|
def each
|
66
66
|
return enum_for(__method__) unless block_given?
|
67
67
|
|
68
|
-
|
69
|
-
return nil if
|
68
|
+
aux_ptr = first_pointer
|
69
|
+
return nil if aux_ptr.null?
|
70
70
|
|
71
71
|
loop do
|
72
|
-
yield get_ruby_aux(
|
73
|
-
|
74
|
-
break if
|
72
|
+
yield get_ruby_aux(aux_ptr)
|
73
|
+
aux_ptr = LibHTS.bam_aux_next(@record.struct, aux_ptr)
|
74
|
+
break if aux_ptr.null?
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
78
|
def to_h
|
79
79
|
h = {}
|
80
|
-
|
81
|
-
return h if
|
80
|
+
aux_ptr = first_pointer
|
81
|
+
return h if aux_ptr.null?
|
82
82
|
|
83
83
|
loop do
|
84
|
-
key = FFI::Pointer.new(
|
85
|
-
h[key] = get_ruby_aux(
|
86
|
-
|
87
|
-
break if
|
84
|
+
key = FFI::Pointer.new(aux_ptr.address - 2).read_string(2)
|
85
|
+
h[key] = get_ruby_aux(aux_ptr)
|
86
|
+
aux_ptr = LibHTS.bam_aux_next(@record.struct, aux_ptr)
|
87
|
+
break if aux_ptr.null?
|
88
88
|
end
|
89
89
|
h
|
90
90
|
end
|
91
91
|
|
92
92
|
private
|
93
93
|
|
94
|
-
def
|
95
|
-
|
94
|
+
def first_pointer
|
95
|
+
LibHTS.bam_aux_first(@record.struct)
|
96
|
+
end
|
97
|
+
|
98
|
+
def get_ruby_aux(aux_ptr, type = nil)
|
99
|
+
type = type ? type.to_s : aux_ptr.read_string(1)
|
96
100
|
|
97
101
|
# A (character), B (general array),
|
98
102
|
# f (real number), H (hexadecimal array),
|
@@ -100,23 +104,23 @@ module HTS
|
|
100
104
|
|
101
105
|
case type
|
102
106
|
when "i", "I", "c", "C", "s", "S"
|
103
|
-
LibHTS.bam_aux2i(
|
107
|
+
LibHTS.bam_aux2i(aux_ptr)
|
104
108
|
when "f", "d"
|
105
|
-
LibHTS.bam_aux2f(
|
109
|
+
LibHTS.bam_aux2f(aux_ptr)
|
106
110
|
when "Z", "H"
|
107
|
-
LibHTS.bam_aux2Z(
|
111
|
+
LibHTS.bam_aux2Z(aux_ptr)
|
108
112
|
when "A" # char
|
109
|
-
LibHTS.bam_aux2A(
|
113
|
+
LibHTS.bam_aux2A(aux_ptr).chr
|
110
114
|
when "B" # array
|
111
|
-
t2 =
|
112
|
-
l = LibHTS.bam_auxB_len(
|
115
|
+
t2 = aux_ptr.read_string(2)[1] # just a little less efficient
|
116
|
+
l = LibHTS.bam_auxB_len(aux_ptr)
|
113
117
|
case t2
|
114
118
|
when "c", "C", "s", "S", "i", "I"
|
115
119
|
# FIXME : Not efficient.
|
116
|
-
Array.new(l) { |i| LibHTS.bam_auxB2i(
|
120
|
+
Array.new(l) { |i| LibHTS.bam_auxB2i(aux_ptr, i) }
|
117
121
|
when "f", "d"
|
118
122
|
# FIXME : Not efficient.
|
119
|
-
Array.new(l) { |i| LibHTS.bam_auxB2f(
|
123
|
+
Array.new(l) { |i| LibHTS.bam_auxB2f(aux_ptr, i) }
|
120
124
|
else
|
121
125
|
raise NotImplementedError, "type: #{type} #{t2}"
|
122
126
|
end
|
data/lib/hts/bam/flag.rb
CHANGED
@@ -69,27 +69,29 @@ module HTS
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def &(other)
|
72
|
-
|
72
|
+
self.class.new(@value & other.to_i)
|
73
73
|
end
|
74
74
|
|
75
75
|
def |(other)
|
76
|
-
|
76
|
+
self.class.new(@value | other.to_i)
|
77
77
|
end
|
78
78
|
|
79
79
|
def ^(other)
|
80
|
-
|
80
|
+
self.class.new(@value ^ other.to_i)
|
81
81
|
end
|
82
82
|
|
83
83
|
def ~
|
84
|
-
|
84
|
+
# FIXME: Only 12bits are used for flags
|
85
|
+
# The result is different from the Crystal version.
|
86
|
+
self.class.new(~@value)
|
85
87
|
end
|
86
88
|
|
87
89
|
def <<(f)
|
88
|
-
|
90
|
+
self.class.new(@value << f.to_i)
|
89
91
|
end
|
90
92
|
|
91
93
|
def >>(other)
|
92
|
-
|
94
|
+
self.class.new(@value >> other.to_i)
|
93
95
|
end
|
94
96
|
|
95
97
|
def to_i
|
data/lib/hts/bam/header.rb
CHANGED
@@ -6,8 +6,8 @@ module HTS
|
|
6
6
|
class Bam < Hts
|
7
7
|
# A class for working with alignment header.
|
8
8
|
class Header
|
9
|
-
def self.parse(
|
10
|
-
new(LibHTS.sam_hdr_parse(
|
9
|
+
def self.parse(text)
|
10
|
+
new(LibHTS.sam_hdr_parse(text.size, text))
|
11
11
|
end
|
12
12
|
|
13
13
|
def initialize(arg = nil)
|
@@ -21,6 +21,8 @@ module HTS
|
|
21
21
|
else
|
22
22
|
raise TypeError, "Invalid argument"
|
23
23
|
end
|
24
|
+
|
25
|
+
yield self if block_given?
|
24
26
|
end
|
25
27
|
|
26
28
|
def struct
|
@@ -31,11 +33,23 @@ module HTS
|
|
31
33
|
@sam_hdr.to_ptr
|
32
34
|
end
|
33
35
|
|
36
|
+
def targets
|
37
|
+
Array.new(target_count) do |i|
|
38
|
+
name = LibHTS.sam_hdr_tid2name(@sam_hdr, i)
|
39
|
+
len = LibHTS.sam_hdr_tid2len(@sam_hdr, i)
|
40
|
+
{ name:, len: }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
34
44
|
def target_count
|
35
45
|
# FIXME: sam_hdr_nref
|
36
46
|
@sam_hdr[:n_targets]
|
37
47
|
end
|
38
48
|
|
49
|
+
def target_name(tid)
|
50
|
+
tid2name(tid)
|
51
|
+
end
|
52
|
+
|
39
53
|
def target_names
|
40
54
|
Array.new(target_count) do |i|
|
41
55
|
LibHTS.sam_hdr_tid2name(@sam_hdr, i)
|
@@ -48,15 +62,20 @@ module HTS
|
|
48
62
|
end
|
49
63
|
end
|
50
64
|
|
51
|
-
|
52
|
-
|
53
|
-
LibHTS.sam_hdr_add_lines(@sam_hdr, str, 0)
|
65
|
+
def write(...)
|
66
|
+
add_lines(...)
|
54
67
|
end
|
55
68
|
|
56
69
|
# experimental
|
57
|
-
def
|
58
|
-
|
59
|
-
|
70
|
+
def <<(obj)
|
71
|
+
case obj
|
72
|
+
when Array, Hash
|
73
|
+
args = obj.flatten(-1).map { |i| i.to_a if i.is_a?(Hash) }
|
74
|
+
add_line(*args)
|
75
|
+
else
|
76
|
+
add_lines(obj.to_s)
|
77
|
+
end
|
78
|
+
self
|
60
79
|
end
|
61
80
|
|
62
81
|
# experimental
|
@@ -87,6 +106,13 @@ module HTS
|
|
87
106
|
LibHTS.sam_hdr_str(@sam_hdr)
|
88
107
|
end
|
89
108
|
|
109
|
+
# experimental
|
110
|
+
def get_tid(name)
|
111
|
+
name2tid(name)
|
112
|
+
end
|
113
|
+
|
114
|
+
private
|
115
|
+
|
90
116
|
def name2tid(name)
|
91
117
|
LibHTS.sam_hdr_name2tid(@sam_hdr, name)
|
92
118
|
end
|
@@ -95,7 +121,15 @@ module HTS
|
|
95
121
|
LibHTS.sam_hdr_tid2name(@sam_hdr, tid)
|
96
122
|
end
|
97
123
|
|
98
|
-
|
124
|
+
def add_lines(str)
|
125
|
+
LibHTS.sam_hdr_add_lines(@sam_hdr, str, 0)
|
126
|
+
end
|
127
|
+
|
128
|
+
def add_line(*args)
|
129
|
+
type = args.shift
|
130
|
+
args = args.flat_map { |arg| [:string, arg] }
|
131
|
+
LibHTS.sam_hdr_add_line(@sam_hdr, type, *args, :pointer, FFI::Pointer::NULL)
|
132
|
+
end
|
99
133
|
|
100
134
|
def initialize_copy(orig)
|
101
135
|
@sam_hdr = LibHTS.sam_hdr_dup(orig.struct)
|
data/lib/hts/bam/record.rb
CHANGED
@@ -12,9 +12,64 @@ module HTS
|
|
12
12
|
|
13
13
|
attr_reader :header
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
# Initialization API is experimental.
|
16
|
+
|
17
|
+
def initialize(
|
18
|
+
header,
|
19
|
+
bam1 = nil,
|
20
|
+
qname: nil,
|
21
|
+
flag: nil,
|
22
|
+
tid: nil,
|
23
|
+
pos: nil,
|
24
|
+
mapq: nil,
|
25
|
+
cigar: nil,
|
26
|
+
mtid: nil,
|
27
|
+
mpos: nil,
|
28
|
+
isize: nil,
|
29
|
+
seq: nil,
|
30
|
+
qual: nil,
|
31
|
+
l_aux: nil
|
32
|
+
)
|
33
|
+
@bam1 = bam1 || LibHTS.bam_init1
|
17
34
|
@header = header
|
35
|
+
|
36
|
+
params = [qname, flag, tid, pos, mapq, cigar, mtid, mpos, isize, seq, qual, l_aux]
|
37
|
+
return if params.all? { |x| x.nil? }
|
38
|
+
|
39
|
+
if params.all?
|
40
|
+
c = FFI::MemoryPointer.new(:pointer)
|
41
|
+
m = FFI::MemoryPointer.new(:size_t)
|
42
|
+
LibHTS.sam_parse_cigar(cigar, FFI::Pointer::NULL, c, m)
|
43
|
+
cigar_array = c.read_pointer.read_array_of_uint32(m.read(:size_t))
|
44
|
+
cigar_pointer = FFI::MemoryPointer.new(:uint32, cigar_array.length)
|
45
|
+
cigar_pointer.write_array_of_uint32(cigar_array)
|
46
|
+
if qual.is_a?(Array)
|
47
|
+
qual = qual.pack("C*")
|
48
|
+
elsif qual.is_a?(String)
|
49
|
+
raise "Which implementation is better? +33 or not? Please tell me."
|
50
|
+
end
|
51
|
+
r = LibHTS.bam_set1(
|
52
|
+
@bam1,
|
53
|
+
qname.length,
|
54
|
+
qname,
|
55
|
+
flag,
|
56
|
+
tid,
|
57
|
+
pos,
|
58
|
+
mapq,
|
59
|
+
cigar_array.length,
|
60
|
+
cigar_pointer,
|
61
|
+
mtid,
|
62
|
+
mpos,
|
63
|
+
isize,
|
64
|
+
seq.length,
|
65
|
+
seq,
|
66
|
+
qual,
|
67
|
+
l_aux
|
68
|
+
)
|
69
|
+
raise "bam_set1 failed: #{r}" if r < 0
|
70
|
+
else
|
71
|
+
warn "Ignore bam_set1 because some arguments are missing."
|
72
|
+
end
|
18
73
|
end
|
19
74
|
|
20
75
|
# Return the FFI::Struct object.
|
@@ -158,6 +213,17 @@ module HTS
|
|
158
213
|
Cigar.new(self)
|
159
214
|
end
|
160
215
|
|
216
|
+
def cigar=(str)
|
217
|
+
if cigar.is_a? Cigar
|
218
|
+
raise "Not implemented yet."
|
219
|
+
elsif cigar.is_a? String
|
220
|
+
r = LibHTS.bam_parse_cigar(str, FFI::Pointer::NULL, @bam1)
|
221
|
+
raise "bam_parse_cigar failed: #{r}" if r != 0
|
222
|
+
else
|
223
|
+
raise ArgumentError, "cigar must be a String or Bam::Cigar"
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
161
227
|
# Calculate query length from CIGAR.
|
162
228
|
# @return [Integer] query length
|
163
229
|
def qlen
|
data/lib/hts/bam.rb
CHANGED
@@ -194,7 +194,7 @@ module HTS
|
|
194
194
|
raise "Index file is required to call the query method." unless index_loaded?
|
195
195
|
|
196
196
|
if beg && end_
|
197
|
-
tid = header.
|
197
|
+
tid = header.get_tid(region)
|
198
198
|
queryi(tid, beg, end_, copy:, &block)
|
199
199
|
elsif beg.nil? && end_.nil?
|
200
200
|
querys(region, copy:, &block)
|
data/lib/hts/bcf/header.rb
CHANGED
data/lib/hts/bcf.rb
CHANGED
@@ -185,7 +185,7 @@ module HTS
|
|
185
185
|
|
186
186
|
def each_info(key)
|
187
187
|
check_closed
|
188
|
-
return to_enum(__method__, key) unless
|
188
|
+
return to_enum(__method__, key) unless block_given?
|
189
189
|
|
190
190
|
each do |r|
|
191
191
|
yield r.info(key)
|
@@ -194,7 +194,7 @@ module HTS
|
|
194
194
|
|
195
195
|
def each_format(key)
|
196
196
|
check_closed
|
197
|
-
return to_enum(__method__, key) unless
|
197
|
+
return to_enum(__method__, key) unless block_given?
|
198
198
|
|
199
199
|
each do |r|
|
200
200
|
yield r.format(key)
|
data/lib/hts/libhts/constants.rb
CHANGED
@@ -570,5 +570,18 @@ module HTS
|
|
570
570
|
:external, 4,
|
571
571
|
:core, 5
|
572
572
|
)
|
573
|
+
|
574
|
+
CramBlockMethod = enum(
|
575
|
+
:unknown, -1,
|
576
|
+
:raw, 0,
|
577
|
+
:gzip, 1,
|
578
|
+
:bzip2, 2,
|
579
|
+
:lzma, 3,
|
580
|
+
:rans4x8, 4,
|
581
|
+
:ransnx16, 5,
|
582
|
+
:arith, 6,
|
583
|
+
:fqz, 7,
|
584
|
+
:tok3, 8
|
585
|
+
)
|
573
586
|
end
|
574
587
|
end
|
data/lib/hts/libhts/cram.rb
CHANGED
@@ -79,12 +79,27 @@ module HTS
|
|
79
79
|
%i[cram_container int32 pointer],
|
80
80
|
:void
|
81
81
|
|
82
|
+
attach_function \
|
83
|
+
:cram_container_get_num_records,
|
84
|
+
[:cram_container],
|
85
|
+
:int32
|
86
|
+
|
87
|
+
attach_function \
|
88
|
+
:cram_container_get_num_bases,
|
89
|
+
[:cram_container],
|
90
|
+
:int32
|
91
|
+
|
92
|
+
# Returns true if the container is empty (EOF marker)
|
82
93
|
attach_function \
|
83
94
|
:cram_container_is_empty,
|
84
95
|
[:cram_fd],
|
85
96
|
:int
|
86
97
|
|
87
|
-
#
|
98
|
+
# Returns chromosome and start/span from container struct
|
99
|
+
attach_function \
|
100
|
+
:cram_container_get_coords,
|
101
|
+
%i[cram_container pointer pointer],
|
102
|
+
:void
|
88
103
|
|
89
104
|
attach_function \
|
90
105
|
:cram_block_get_content_id,
|
@@ -116,6 +131,16 @@ module HTS
|
|
116
131
|
[:cram_block],
|
117
132
|
CramContentType
|
118
133
|
|
134
|
+
attach_function \
|
135
|
+
:cram_block_get_method,
|
136
|
+
[:cram_block],
|
137
|
+
CramBlockMethod
|
138
|
+
|
139
|
+
attach_function \
|
140
|
+
:cram_expand_method,
|
141
|
+
[:pointer, :int32, CramBlockMethod],
|
142
|
+
:pointer
|
143
|
+
|
119
144
|
attach_function \
|
120
145
|
:cram_block_set_content_id,
|
121
146
|
%i[cram_block int32],
|
@@ -167,6 +192,18 @@ module HTS
|
|
167
192
|
[:cram_block],
|
168
193
|
:uint32
|
169
194
|
|
195
|
+
# Returns the Block Content ID values referred to by a cram_codec in ids[2].
|
196
|
+
attach_function \
|
197
|
+
:cram_codec_get_content_ids,
|
198
|
+
%i[pointer pointer],
|
199
|
+
:void
|
200
|
+
|
201
|
+
# Produces a human readable description of the codec parameters.
|
202
|
+
attach_function \
|
203
|
+
:cram_codec_describe,
|
204
|
+
[:pointer, KString.ptr],
|
205
|
+
:int
|
206
|
+
|
170
207
|
# Renumbers RG numbers in a cram compression header.
|
171
208
|
attach_function \
|
172
209
|
:cram_transcode_rg,
|
@@ -180,6 +217,51 @@ module HTS
|
|
180
217
|
%i[cram_fd cram_fd int32],
|
181
218
|
:int
|
182
219
|
|
220
|
+
# Copies a container, but filtering it down to a specific region (as
|
221
|
+
# already specified in 'in'
|
222
|
+
attach_function \
|
223
|
+
:cram_filter_container,
|
224
|
+
%i[cram_fd cram_fd cram_container pointer],
|
225
|
+
:int
|
226
|
+
|
227
|
+
# Decodes a CRAM block compression header.
|
228
|
+
attach_function \
|
229
|
+
:cram_decode_compression_header,
|
230
|
+
%i[cram_fd cram_block],
|
231
|
+
:pointer # cram_block_compression_hdr
|
232
|
+
|
233
|
+
# Frees a cram_block_compression_hdr structure.
|
234
|
+
attach_function \
|
235
|
+
:cram_free_compression_header,
|
236
|
+
[:pointer],
|
237
|
+
:void
|
238
|
+
|
239
|
+
# Map cram block numbers to data-series.
|
240
|
+
attach_function \
|
241
|
+
:cram_update_cid2ds_map,
|
242
|
+
%i[pointer pointer],
|
243
|
+
:pointer
|
244
|
+
|
245
|
+
# Return a list of data series observed as belonging to a block with
|
246
|
+
# the specified content_id.
|
247
|
+
attach_function \
|
248
|
+
:cram_cid2ds_query,
|
249
|
+
%i[pointer int pointer],
|
250
|
+
:int
|
251
|
+
|
252
|
+
# Frees a cram_cid2ds_t allocated by cram_update_cid2ds_map
|
253
|
+
attach_function \
|
254
|
+
:cram_cid2ds_free,
|
255
|
+
[:pointer],
|
256
|
+
:void
|
257
|
+
|
258
|
+
# Produces a description of the record and tag encodings held within
|
259
|
+
# a compression header and appends to 'ks'.
|
260
|
+
attach_function \
|
261
|
+
:cram_describe_encodings,
|
262
|
+
[:pointer, KString.ptr],
|
263
|
+
:int
|
264
|
+
|
183
265
|
# Returns the number of cram blocks within this slice.
|
184
266
|
attach_function \
|
185
267
|
:cram_slice_hdr_get_num_blocks,
|
@@ -360,5 +442,35 @@ module HTS
|
|
360
442
|
:cram_get_refs,
|
361
443
|
[HtsFile.by_ref],
|
362
444
|
:pointer # refs_t
|
445
|
+
|
446
|
+
# Returns the file offsets of CRAM slices covering a specific region query.
|
447
|
+
attach_function \
|
448
|
+
:cram_index_extents,
|
449
|
+
%i[cram_fd int hts_pos_t hts_pos_t pointer pointer],
|
450
|
+
:int
|
451
|
+
|
452
|
+
# Returns the total number of containers in the CRAM index.
|
453
|
+
attach_function \
|
454
|
+
:cram_num_containers,
|
455
|
+
[:cram_fd],
|
456
|
+
:int64
|
457
|
+
|
458
|
+
# Returns the number of containers in the CRAM index within given offsets.
|
459
|
+
attach_function \
|
460
|
+
:cram_num_containers_between,
|
461
|
+
%i[cram_fd off_t off_t pointer pointer],
|
462
|
+
:int64
|
463
|
+
|
464
|
+
# Returns the byte offset for the start of the n^th container.
|
465
|
+
attach_function \
|
466
|
+
:cram_container_num2offset,
|
467
|
+
%i[cram_fd int64],
|
468
|
+
:off_t
|
469
|
+
|
470
|
+
# Returns the container number for the first container at offset >= pos.
|
471
|
+
attach_function \
|
472
|
+
:cram_container_offset2num,
|
473
|
+
%i[cram_fd off_t],
|
474
|
+
:int64
|
363
475
|
end
|
364
476
|
end
|
data/lib/hts/libhts/hts.rb
CHANGED
@@ -447,7 +447,7 @@ module HTS
|
|
447
447
|
# Computes the final 128-bit MD5 hash from the given context
|
448
448
|
attach_function \
|
449
449
|
:hts_md5_final,
|
450
|
-
%i[pointer pointer], #
|
450
|
+
%i[pointer pointer], # unsigned char
|
451
451
|
:void
|
452
452
|
|
453
453
|
# Resets an md5_context to the initial state, as returned by hts_md5_init().
|
data/lib/hts/libhts/sam.rb
CHANGED
@@ -247,7 +247,7 @@ module HTS
|
|
247
247
|
:hts_pos_t,
|
248
248
|
:uint8,
|
249
249
|
:size_t,
|
250
|
-
:
|
250
|
+
:pointer,
|
251
251
|
:int32,
|
252
252
|
:hts_pos_t,
|
253
253
|
:hts_pos_t,
|
@@ -512,6 +512,12 @@ module HTS
|
|
512
512
|
[Bam1, :pointer],
|
513
513
|
:int
|
514
514
|
|
515
|
+
# Delete an aux field from a BAM record. Identical to @c bam_aux_del() apart from the return value
|
516
|
+
attach_function \
|
517
|
+
:bam_aux_remove,
|
518
|
+
[Bam1, :pointer],
|
519
|
+
:pointer
|
520
|
+
|
515
521
|
# Update or add a string-type tag
|
516
522
|
attach_function \
|
517
523
|
:bam_aux_update_str,
|
@@ -674,12 +680,18 @@ module HTS
|
|
674
680
|
[:pointer], # hts_base_mod_state
|
675
681
|
:void
|
676
682
|
|
677
|
-
# Parses the
|
683
|
+
# Parses the MM and ML tags out of a bam record.
|
678
684
|
attach_function \
|
679
685
|
:bam_parse_basemod,
|
680
686
|
[Bam1, :pointer],
|
681
687
|
:int
|
682
688
|
|
689
|
+
# Parses the MM and ML tags out of a bam record.
|
690
|
+
attach_function \
|
691
|
+
:bam_parse_basemod2,
|
692
|
+
[Bam1, :pointer, :uint32],
|
693
|
+
:int
|
694
|
+
|
683
695
|
# Returns modification status for the next base position in the query seq.
|
684
696
|
attach_function \
|
685
697
|
:bam_mods_at_next_pos,
|
@@ -704,6 +716,12 @@ module HTS
|
|
704
716
|
%i[pointer int pointer pointer string],
|
705
717
|
:int
|
706
718
|
|
719
|
+
# Returns data about the i^th modification type for the alignment record.
|
720
|
+
attach_function \
|
721
|
+
:bam_mods_queryi,
|
722
|
+
%i[pointer int pointer pointer string],
|
723
|
+
:int
|
724
|
+
|
707
725
|
# Returns the list of base modification codes provided for this
|
708
726
|
attach_function \
|
709
727
|
:bam_mods_recorded,
|
data/lib/hts/libhts/tbx.rb
CHANGED
@@ -2,6 +2,13 @@
|
|
2
2
|
|
3
3
|
module HTS
|
4
4
|
module LibHTS
|
5
|
+
attach_variable :tbx_conf_gff, TbxConf
|
6
|
+
attach_variable :tbx_conf_bed, TbxConf
|
7
|
+
attach_variable :tbx_conf_psltbl, TbxConf
|
8
|
+
attach_variable :tbx_conf_sam, TbxConf
|
9
|
+
attach_variable :tbx_conf_vcf, TbxConf
|
10
|
+
attach_variable :tbx_conf_gaf, TbxConf
|
11
|
+
|
5
12
|
attach_function \
|
6
13
|
:tbx_name2id,
|
7
14
|
[Tbx, :string],
|
data/lib/hts/libhts/tbx_funcs.rb
CHANGED
@@ -8,11 +8,16 @@ module HTS
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def tbx_itr_queryi(tbx, tid, beg, end_)
|
11
|
-
hts_itr_query(tbx[:idx], tid, beg, end_,
|
11
|
+
hts_itr_query(tbx[:idx], tid, beg, end_, @ffi_functions[:tbx_readrec])
|
12
|
+
end
|
13
|
+
|
14
|
+
@@tbx_name2id = proc do |tbx, ss|
|
15
|
+
LibHTS.tbx_name2id(tbx, ss)
|
12
16
|
end
|
13
17
|
|
14
18
|
def tbx_itr_querys(tbx, s)
|
15
|
-
hts_itr_querys(tbx[:idx], s, @@tbx_name2id, tbx,
|
19
|
+
hts_itr_querys(tbx[:idx], s, @@tbx_name2id, tbx, @ffi_functions[:hts_itr_query],
|
20
|
+
@ffi_functions[:tbx_readrec])
|
16
21
|
end
|
17
22
|
|
18
23
|
def tbx_itr_next(htsfp, tbx, itr, r)
|
data/lib/hts/libhts/vcf.rb
CHANGED
data/lib/hts/libhts/vcf_funcs.rb
CHANGED
@@ -272,7 +272,7 @@ module HTS
|
|
272
272
|
alias bcf_itr_destroy hts_itr_destroy
|
273
273
|
|
274
274
|
def bcf_itr_queryi(idx, tid, beg, _end)
|
275
|
-
hts_itr_query(idx, tid, beg, _end,
|
275
|
+
hts_itr_query(idx, tid, beg, _end, @ffi_functions[:bcf_readrec])
|
276
276
|
end
|
277
277
|
|
278
278
|
@@bcf_hdr_name2id = proc do |hdr, id|
|
@@ -280,7 +280,7 @@ module HTS
|
|
280
280
|
end
|
281
281
|
|
282
282
|
def bcf_itr_querys(idx, hdr, s)
|
283
|
-
hts_itr_querys(idx, s, @@bcf_hdr_name2id, hdr,
|
283
|
+
hts_itr_querys(idx, s, @@bcf_hdr_name2id, hdr, @ffi_functions[:hts_itr_query], @ffi_functions[:bcf_readrec])
|
284
284
|
end
|
285
285
|
|
286
286
|
# Load a BCF index
|
data/lib/hts/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: htslib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kojix2
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -52,76 +52,6 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: bundler
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: irb
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: minitest
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: rake
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: simplecov
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
125
55
|
description:
|
126
56
|
email:
|
127
57
|
- 2xijok@gmail.com
|
@@ -189,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
119
|
- !ruby/object:Gem::Version
|
190
120
|
version: '0'
|
191
121
|
requirements: []
|
192
|
-
rubygems_version: 3.
|
122
|
+
rubygems_version: 3.5.11
|
193
123
|
signing_key:
|
194
124
|
specification_version: 4
|
195
125
|
summary: HTSlib bindings for Ruby
|