htslib 0.0.10 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -16
- data/lib/hts/bam/aux.rb +39 -0
- data/lib/hts/bam/cigar.rb +0 -3
- data/lib/hts/bam/flag.rb +21 -57
- data/lib/hts/bam/header.rb +1 -4
- data/lib/hts/bam/record.rb +91 -47
- data/lib/hts/bam.rb +14 -15
- data/lib/hts/bcf/format.rb +82 -11
- data/lib/hts/bcf/info.rb +56 -31
- data/lib/hts/bcf/record.rb +43 -16
- data/lib/hts/bcf.rb +40 -15
- data/lib/hts/faidx.rb +0 -3
- data/lib/hts/ffi_ext/pointer.rb +18 -0
- data/lib/hts/hts.rb +22 -4
- data/lib/hts/libhts/constants.rb +3 -3
- data/lib/hts/libhts/cram.rb +287 -292
- data/lib/hts/libhts/vcf.rb +14 -0
- data/lib/hts/libhts.rb +4 -0
- data/lib/hts/{tabix.rb → tbx.rb} +4 -11
- data/lib/hts/version.rb +1 -1
- data/lib/htslib.rb +1 -1
- metadata +5 -3
data/lib/hts/libhts/cram.rb
CHANGED
@@ -2,296 +2,291 @@
|
|
2
2
|
|
3
3
|
module HTS
|
4
4
|
module LibHTS
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
attach_function \
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
:cram_get_refs,
|
292
|
-
[HtsFile],
|
293
|
-
RefsT # what is RefsT
|
294
|
-
|
295
|
-
=end
|
5
|
+
#
|
6
|
+
# attach_function \
|
7
|
+
# :cram_fd_get_header,
|
8
|
+
# [CramFd],
|
9
|
+
# SamHdr.by_ref
|
10
|
+
#
|
11
|
+
# attach_function \
|
12
|
+
# :cram_fd_set_header,
|
13
|
+
# [CramFd, SamHdr.by_ref],
|
14
|
+
# :void
|
15
|
+
#
|
16
|
+
# attach_function \
|
17
|
+
# :cram_fd_get_version,
|
18
|
+
# [CramFd],
|
19
|
+
# :int
|
20
|
+
#
|
21
|
+
# attach_function \
|
22
|
+
# :cram_fd_set_version,
|
23
|
+
# [CramFd, :int],
|
24
|
+
# :void
|
25
|
+
#
|
26
|
+
# attach_function \
|
27
|
+
# :cram_major_vers,
|
28
|
+
# [CramFd],
|
29
|
+
# :int
|
30
|
+
#
|
31
|
+
# attach_function \
|
32
|
+
# :cram_minor_vers,
|
33
|
+
# [CramFd],
|
34
|
+
# :int
|
35
|
+
#
|
36
|
+
# attach_function \
|
37
|
+
# :cram_fd_get_fp,
|
38
|
+
# [CramFd],
|
39
|
+
# HFile.by_ref
|
40
|
+
#
|
41
|
+
# attach_function \
|
42
|
+
# :cram_fd_set_fp,
|
43
|
+
# [CramFd, HFile],
|
44
|
+
# :void
|
45
|
+
#
|
46
|
+
# attach_function \
|
47
|
+
# :cram_container_get_length,
|
48
|
+
# [CramContainer],
|
49
|
+
# :int32
|
50
|
+
#
|
51
|
+
# attach_function \
|
52
|
+
# :cram_container_set_length,
|
53
|
+
# [CramContainer, :int32],
|
54
|
+
# :void
|
55
|
+
#
|
56
|
+
# attach_function \
|
57
|
+
# :cram_container_get_num_blocks,
|
58
|
+
# [CramContainer],
|
59
|
+
# :int32
|
60
|
+
#
|
61
|
+
# attach_function \
|
62
|
+
# :cram_container_set_num_blocks,
|
63
|
+
# [CramContainer, :int32],
|
64
|
+
# :void
|
65
|
+
#
|
66
|
+
# attach_function \
|
67
|
+
# :cram_container_get_landmarks,
|
68
|
+
# [CramContainer, :int32],
|
69
|
+
# :pointer
|
70
|
+
#
|
71
|
+
# attach_function \
|
72
|
+
# :cram_container_set_landmarks,
|
73
|
+
# [CramContainer, :Int32, :pointer],
|
74
|
+
# :void
|
75
|
+
#
|
76
|
+
# attach_function \
|
77
|
+
# :cram_container_is_empty,
|
78
|
+
# [CramFd],
|
79
|
+
# :int
|
80
|
+
#
|
81
|
+
# attach_function \
|
82
|
+
# :cram_block_get_content_id,
|
83
|
+
# [CramBlock],
|
84
|
+
# :int32
|
85
|
+
#
|
86
|
+
# attach_function \
|
87
|
+
# :cram_block_get_comp_size,
|
88
|
+
# [CramBlock],
|
89
|
+
# :int32
|
90
|
+
#
|
91
|
+
# attach_function \
|
92
|
+
# :cram_block_get_uncomp_size,
|
93
|
+
# [CramBlock],
|
94
|
+
# :int32
|
95
|
+
#
|
96
|
+
# attach_function \
|
97
|
+
# :cram_block_get_crc32,
|
98
|
+
# [CramBlock],
|
99
|
+
# :int32
|
100
|
+
#
|
101
|
+
# attach_function \
|
102
|
+
# :cram_block_get_data,
|
103
|
+
# [CramBlock],
|
104
|
+
# :pointer
|
105
|
+
#
|
106
|
+
# attach_function \
|
107
|
+
# :cram_block_get_content_type,
|
108
|
+
# [CramBlock],
|
109
|
+
# CramContentType # ?
|
110
|
+
#
|
111
|
+
# attach_function \
|
112
|
+
# :cram_block_set_content_id,
|
113
|
+
# [CramBlock, :int32],
|
114
|
+
# :void
|
115
|
+
#
|
116
|
+
# attach_function \
|
117
|
+
# :cram_block_set_comp_size,
|
118
|
+
# [CramBlock, :int32],
|
119
|
+
# :void
|
120
|
+
#
|
121
|
+
# attach_function \
|
122
|
+
# :cram_block_set_uncomp_size,
|
123
|
+
# [CramBlock, :int32],
|
124
|
+
# :void
|
125
|
+
#
|
126
|
+
# attach_function \
|
127
|
+
# :cram_block_set_crc32,
|
128
|
+
# [CramBlock, :int32],
|
129
|
+
# :void
|
130
|
+
#
|
131
|
+
# attach_function \
|
132
|
+
# :cram_block_set_data,
|
133
|
+
# [CramBlock, :pointer],
|
134
|
+
# :void
|
135
|
+
#
|
136
|
+
# attach_function \
|
137
|
+
# :cram_block_append,
|
138
|
+
# [CramBlock, :pointer, :int],
|
139
|
+
# :int
|
140
|
+
#
|
141
|
+
# attach_function \
|
142
|
+
# :cram_block_update_size,
|
143
|
+
# [CramBlock],
|
144
|
+
# :void
|
145
|
+
#
|
146
|
+
# attach_function \
|
147
|
+
# :cram_block_get_offset,
|
148
|
+
# [CramBlock],
|
149
|
+
# :size_t
|
150
|
+
#
|
151
|
+
# attach_function \
|
152
|
+
# :cram_block_set_offset,
|
153
|
+
# [CramBlock, :size_t],
|
154
|
+
# :void
|
155
|
+
#
|
156
|
+
# attach_function \
|
157
|
+
# :cram_block_size,
|
158
|
+
# [CramBlock],
|
159
|
+
# :uint32
|
160
|
+
#
|
161
|
+
# attach_function \
|
162
|
+
# :cram_transcode_rg,
|
163
|
+
# [CramFd, CramFd, CramContainer, :int, :pointer, :pointer],
|
164
|
+
# :int
|
165
|
+
#
|
166
|
+
# attach_function \
|
167
|
+
# :cram_copy_slice,
|
168
|
+
# [CramFd, CramFd, :int32],
|
169
|
+
# :int
|
170
|
+
#
|
171
|
+
# attach_function \
|
172
|
+
# :cram_new_block,
|
173
|
+
# [CramContentType, :int],
|
174
|
+
# CramBlock
|
175
|
+
#
|
176
|
+
# attach_function \
|
177
|
+
# :cram_read_block,
|
178
|
+
# [CramFd],
|
179
|
+
# CramBlock
|
180
|
+
#
|
181
|
+
# attach_function \
|
182
|
+
# :cram_write_block,
|
183
|
+
# [CramFd, CramBlock],
|
184
|
+
# :int
|
185
|
+
#
|
186
|
+
# attach_function \
|
187
|
+
# :cram_free_block,
|
188
|
+
# [CramBlock],
|
189
|
+
# :void
|
190
|
+
#
|
191
|
+
# attach_function \
|
192
|
+
# :cram_uncompress_block,
|
193
|
+
# [CramBlock],
|
194
|
+
# :int
|
195
|
+
#
|
196
|
+
# attach_function \
|
197
|
+
# :cram_compress_block,
|
198
|
+
# [CramFd, CramBlock, CramMetrics, :int, :int],
|
199
|
+
# :int
|
200
|
+
#
|
201
|
+
# attach_function \
|
202
|
+
# :cram_compress_block2,
|
203
|
+
# [CramFd, CramSlice, CramBlock, CramMetrics, :int, :int],
|
204
|
+
# :int
|
205
|
+
#
|
206
|
+
# attach_function \
|
207
|
+
# :cram_new_container,
|
208
|
+
# [:int, :int],
|
209
|
+
# CramContainer
|
210
|
+
#
|
211
|
+
# attach_function \
|
212
|
+
# :cram_free_container,
|
213
|
+
# [CramContainer],
|
214
|
+
# :void
|
215
|
+
#
|
216
|
+
# attach_function \
|
217
|
+
# :cram_read_container,
|
218
|
+
# [CramFd],
|
219
|
+
# CramContainer
|
220
|
+
#
|
221
|
+
# attach_function \
|
222
|
+
# :cram_write_container,
|
223
|
+
# [CramFd, CramContainer],
|
224
|
+
# :int
|
225
|
+
#
|
226
|
+
# attach_function \
|
227
|
+
# :cram_store_container,
|
228
|
+
# [CramFd, CramContainer, :string, :pointer],
|
229
|
+
# :int
|
230
|
+
#
|
231
|
+
# attach_function \
|
232
|
+
# :cram_container_size,
|
233
|
+
# [CramContainer],
|
234
|
+
# :int
|
235
|
+
#
|
236
|
+
# attach_function \
|
237
|
+
# :cram_open,
|
238
|
+
# [:string, :string],
|
239
|
+
# CramFd
|
240
|
+
#
|
241
|
+
# attach_function \
|
242
|
+
# :cram_dopen,
|
243
|
+
# [:pointer, :string, :string],
|
244
|
+
# CramFd
|
245
|
+
#
|
246
|
+
# attach_function \
|
247
|
+
# :cram_close,
|
248
|
+
# [CramFd],
|
249
|
+
# :int
|
250
|
+
#
|
251
|
+
|
252
|
+
attach_function \
|
253
|
+
:cram_seek,
|
254
|
+
%i[pointer off_t int], :int # FIXME: pointer should be CramFd
|
255
|
+
|
256
|
+
#
|
257
|
+
# attach_function \
|
258
|
+
# :cram_flush,
|
259
|
+
# [CramFd],
|
260
|
+
# :int
|
261
|
+
#
|
262
|
+
# attach_function \
|
263
|
+
# :cram_eof,
|
264
|
+
# [CramFd],
|
265
|
+
# :int
|
266
|
+
#
|
267
|
+
# attach_function \
|
268
|
+
# :cram_set_option,
|
269
|
+
# [CramFd, HtsFmtOption, ...], # vararg!
|
270
|
+
# :int
|
271
|
+
#
|
272
|
+
# attach_function \
|
273
|
+
# :cram_set_voption,
|
274
|
+
# [CramFd, HtsFmtOption, VaList],
|
275
|
+
# :int
|
276
|
+
#
|
277
|
+
# attach_function \
|
278
|
+
# :cram_set_header,
|
279
|
+
# [CramFd, SamHdr.by_ref],
|
280
|
+
# :int
|
281
|
+
#
|
282
|
+
# attach_function \
|
283
|
+
# :cram_check_eof = :cram_check_EOF,
|
284
|
+
# [CramFd], :int
|
285
|
+
#
|
286
|
+
# attach_function \
|
287
|
+
# :cram_get_refs,
|
288
|
+
# [HtsFile],
|
289
|
+
# RefsT # what is RefsT
|
290
|
+
#
|
296
291
|
end
|
297
|
-
end
|
292
|
+
end
|
data/lib/hts/libhts/vcf.rb
CHANGED
@@ -221,6 +221,20 @@ module HTS
|
|
221
221
|
LibHTS::BcfIdpair.size * int_id # offset
|
222
222
|
)[:val][:info][type] >> 12
|
223
223
|
end
|
224
|
+
|
225
|
+
def bcf_hdr_id2type(hdr, type, int_id)
|
226
|
+
LibHTS::BcfIdpair.new(
|
227
|
+
hdr[:id][LibHTS::BCF_DT_ID].to_ptr +
|
228
|
+
LibHTS::BcfIdpair.size * int_id # offset
|
229
|
+
)[:val][:info][type] >> 4 & 0xf
|
230
|
+
end
|
231
|
+
|
232
|
+
def bcf_hdr_id2coltype(hdr, type, int_id)
|
233
|
+
LibHTS::BcfIdpair.new(
|
234
|
+
hdr[:id][LibHTS::BCF_DT_ID].to_ptr +
|
235
|
+
LibHTS::BcfIdpair.size * int_id # offset
|
236
|
+
)[:val][:info][type] & 0xf
|
237
|
+
end
|
224
238
|
end
|
225
239
|
end
|
226
240
|
end
|
data/lib/hts/libhts.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "ffi_ext/struct"
|
4
|
+
require_relative "ffi_ext/pointer"
|
4
5
|
|
5
6
|
module HTS
|
6
7
|
module LibHTS
|
@@ -12,6 +13,9 @@ module HTS
|
|
12
13
|
raise LoadError, "#{e}\nCould not find #{HTS.lib_path}"
|
13
14
|
end
|
14
15
|
|
16
|
+
# @!macro attach_function
|
17
|
+
# @!method $1(${2--2})
|
18
|
+
# @return [${-1}] the return value of $0
|
15
19
|
def self.attach_function(*)
|
16
20
|
super
|
17
21
|
rescue FFI::NotFoundError => e
|
data/lib/hts/{tabix.rb → tbx.rb}
RENAMED
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative "../htslib"
|
2
4
|
|
3
5
|
require_relative "hts"
|
4
6
|
|
5
7
|
module HTS
|
6
|
-
class
|
8
|
+
class Tbx < Hts
|
7
9
|
include Enumerable
|
8
10
|
|
9
11
|
attr_reader :file_name
|
@@ -22,7 +24,7 @@ module HTS
|
|
22
24
|
|
23
25
|
def initialize(file_name, threads: nil)
|
24
26
|
if block_given?
|
25
|
-
message = "HTS::
|
27
|
+
message = "HTS::Tbx.new() dose not take block; Please use HTS::Tbx.open() instead"
|
26
28
|
raise message
|
27
29
|
end
|
28
30
|
|
@@ -40,14 +42,5 @@ module HTS
|
|
40
42
|
raise "Failed to set number of threads: #{threads}" if r < 0
|
41
43
|
end
|
42
44
|
end
|
43
|
-
|
44
|
-
def close
|
45
|
-
LibHTS.hts_close(@hts_file)
|
46
|
-
@hts_file = nil
|
47
|
-
end
|
48
|
-
|
49
|
-
def closed?
|
50
|
-
@hts_file.nil?
|
51
|
-
end
|
52
45
|
end
|
53
46
|
end
|
data/lib/hts/version.rb
CHANGED