htslib 0.4.0 → 0.4.2
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/lib/hts/bam/auxi.rb +21 -3
- data/lib/hts/bcf/header.rb +0 -1
- data/lib/hts/bcf.rb +2 -2
- data/lib/hts/libhts/hfile.rb +12 -0
- data/lib/hts/libhts/tbx.rb +15 -0
- data/lib/hts/libhts/tbx_funcs.rb +4 -0
- data/lib/hts/libhts/vcf.rb +10 -0
- data/lib/hts/libhts/vcf_funcs.rb +13 -0
- data/lib/hts/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 69e910e95cfe1bef250416f8bbe480a39a1bc54b53103435cf15811860f3b92d
|
|
4
|
+
data.tar.gz: 060c7e5af8127c496af3b5d5bec5eca5e7476cb34ccc86a75546fd1a80d6dd8a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 62adc672a3606265d231efa7f568232d55279634c8fb650190aee01c750b0dbac2421a1cf8fb2507bf5b21e16afbe4e4425354cd3dd2b1398d4df7b3f24e6655
|
|
7
|
+
data.tar.gz: 2a6bd47a73ff2695a515e934fa1919d8fcdf1108e10178404af31da769b4e7c40a8580f2382ab8f7e6ac8697261344fb32ecebc138807d5cd03724745457f4d4
|
data/lib/hts/bam/auxi.rb
CHANGED
|
@@ -248,10 +248,9 @@ module HTS
|
|
|
248
248
|
end
|
|
249
249
|
end
|
|
250
250
|
|
|
251
|
-
# Iterate auxiliary tags
|
|
251
|
+
# Iterate auxiliary tags as key-value pairs.
|
|
252
252
|
#
|
|
253
253
|
# @yieldparam tag [String] 2-byte AUX tag name
|
|
254
|
-
# @yieldparam type [String] AUX type, e.g. "i", "Z", or "B:C"
|
|
255
254
|
# @yieldparam value [Object] Ruby representation of the AUX value
|
|
256
255
|
def each
|
|
257
256
|
return enum_for(__method__) unless block_given?
|
|
@@ -261,7 +260,7 @@ module HTS
|
|
|
261
260
|
|
|
262
261
|
loop do
|
|
263
262
|
tag = FFI::Pointer.new(aux_ptr.address - 2).read_string(2)
|
|
264
|
-
yield tag,
|
|
263
|
+
yield tag, get_ruby_aux(aux_ptr)
|
|
265
264
|
aux_ptr = LibHTS.bam_aux_next(@record.struct, aux_ptr)
|
|
266
265
|
break if aux_ptr.null?
|
|
267
266
|
end
|
|
@@ -269,6 +268,25 @@ module HTS
|
|
|
269
268
|
|
|
270
269
|
alias each_pair each
|
|
271
270
|
|
|
271
|
+
# Iterate auxiliary tags with their SAM/BAM type.
|
|
272
|
+
#
|
|
273
|
+
# @yieldparam tag [String] 2-byte AUX tag name
|
|
274
|
+
# @yieldparam type [String] AUX type, e.g. "i", "Z", or "B:C"
|
|
275
|
+
# @yieldparam value [Object] Ruby representation of the AUX value
|
|
276
|
+
def each_with_type
|
|
277
|
+
return enum_for(__method__) unless block_given?
|
|
278
|
+
|
|
279
|
+
aux_ptr = first_pointer
|
|
280
|
+
return nil if aux_ptr.null?
|
|
281
|
+
|
|
282
|
+
loop do
|
|
283
|
+
tag = FFI::Pointer.new(aux_ptr.address - 2).read_string(2)
|
|
284
|
+
yield tag, aux_type(aux_ptr), get_ruby_aux(aux_ptr)
|
|
285
|
+
aux_ptr = LibHTS.bam_aux_next(@record.struct, aux_ptr)
|
|
286
|
+
break if aux_ptr.null?
|
|
287
|
+
end
|
|
288
|
+
end
|
|
289
|
+
|
|
272
290
|
def to_h
|
|
273
291
|
h = {}
|
|
274
292
|
aux_ptr = first_pointer
|
data/lib/hts/bcf/header.rb
CHANGED
|
@@ -104,7 +104,6 @@ module HTS
|
|
|
104
104
|
subset_samples = normalize_subset_samples(samples)
|
|
105
105
|
validate_subset_samples!(subset_samples)
|
|
106
106
|
|
|
107
|
-
nil
|
|
108
107
|
imap_pointer = nil
|
|
109
108
|
if subset_samples.empty?
|
|
110
109
|
subset_hdr = LibHTS.bcf_hdr_subset(@bcf_hdr, 0, ::FFI::Pointer::NULL, ::FFI::Pointer::NULL)
|
data/lib/hts/bcf.rb
CHANGED
|
@@ -322,7 +322,7 @@ module HTS
|
|
|
322
322
|
record = Record.new(header, bcf1)
|
|
323
323
|
begin
|
|
324
324
|
loop do
|
|
325
|
-
slen = LibHTS.
|
|
325
|
+
slen = LibHTS.bcf_itr_next(@hts_file, qiter, bcf1)
|
|
326
326
|
break if slen == -1
|
|
327
327
|
raise if slen < -1
|
|
328
328
|
|
|
@@ -371,7 +371,7 @@ module HTS
|
|
|
371
371
|
bcf1 = LibHTS.bcf_init
|
|
372
372
|
record = Record.new(header, bcf1)
|
|
373
373
|
loop do
|
|
374
|
-
slen = LibHTS.
|
|
374
|
+
slen = LibHTS.bcf_itr_next(@hts_file, qiter, bcf1)
|
|
375
375
|
break if slen == -1
|
|
376
376
|
raise if slen < -1
|
|
377
377
|
|
data/lib/hts/libhts/hfile.rb
CHANGED
|
@@ -64,6 +64,18 @@ module HTS
|
|
|
64
64
|
[:string, :int, HFile],
|
|
65
65
|
:string
|
|
66
66
|
|
|
67
|
+
# Read a line from a stream and append it to a kstring
|
|
68
|
+
attach_function \
|
|
69
|
+
:khgetline,
|
|
70
|
+
[KString, HFile],
|
|
71
|
+
:int
|
|
72
|
+
|
|
73
|
+
# Convenience function to call kgetline with a FILE *
|
|
74
|
+
attach_function \
|
|
75
|
+
:kfgetline,
|
|
76
|
+
[KString, :pointer],
|
|
77
|
+
:int
|
|
78
|
+
|
|
67
79
|
# Peek at characters to be read without removing them from buffers
|
|
68
80
|
attach_function \
|
|
69
81
|
:hpeek,
|
data/lib/hts/libhts/tbx.rb
CHANGED
|
@@ -14,6 +14,21 @@ module HTS
|
|
|
14
14
|
[Tbx, :string],
|
|
15
15
|
:int
|
|
16
16
|
|
|
17
|
+
attach_function \
|
|
18
|
+
:tbx_itr_querys1,
|
|
19
|
+
[Tbx, :string],
|
|
20
|
+
HtsItr.by_ref
|
|
21
|
+
|
|
22
|
+
attach_function \
|
|
23
|
+
:tbx_itr_regarray,
|
|
24
|
+
[Tbx, :pointer, :uint],
|
|
25
|
+
HtsItr.by_ref
|
|
26
|
+
|
|
27
|
+
attach_function \
|
|
28
|
+
:tbx_itr_next1,
|
|
29
|
+
[HtsFile, Tbx, HtsItr, :pointer],
|
|
30
|
+
:int
|
|
31
|
+
|
|
17
32
|
# Internal helper function used by tbx_itr_next()
|
|
18
33
|
attach_function \
|
|
19
34
|
:hts_get_bgzfp,
|
data/lib/hts/libhts/tbx_funcs.rb
CHANGED
|
@@ -16,11 +16,15 @@ module HTS
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def tbx_itr_querys(tbx, s)
|
|
19
|
+
return tbx_itr_querys1(tbx, s) if respond_to?(:tbx_itr_querys1)
|
|
20
|
+
|
|
19
21
|
hts_itr_querys(tbx[:idx], s, @@tbx_name2id, tbx, @ffi_functions[:hts_itr_query],
|
|
20
22
|
@ffi_functions[:tbx_readrec])
|
|
21
23
|
end
|
|
22
24
|
|
|
23
25
|
def tbx_itr_next(htsfp, tbx, itr, r)
|
|
26
|
+
return tbx_itr_next1(htsfp, tbx, itr, r) if respond_to?(:tbx_itr_next1)
|
|
27
|
+
|
|
24
28
|
hts_itr_next(hts_get_bgzfp(htsfp), itr, r, tbx)
|
|
25
29
|
end
|
|
26
30
|
|
data/lib/hts/libhts/vcf.rb
CHANGED
|
@@ -145,6 +145,16 @@ module HTS
|
|
|
145
145
|
[BGZF, :pointer, :pointer, :pointer, :hts_pos_t, :hts_pos_t],
|
|
146
146
|
:int
|
|
147
147
|
|
|
148
|
+
attach_function \
|
|
149
|
+
:bcf_itr_querys1,
|
|
150
|
+
[HtsIdx, BcfHdr, :string],
|
|
151
|
+
HtsItr.by_ref
|
|
152
|
+
|
|
153
|
+
attach_function \
|
|
154
|
+
:bcf_itr_regarray,
|
|
155
|
+
[HtsIdx, BcfHdr, :pointer, :uint],
|
|
156
|
+
HtsItr.by_ref
|
|
157
|
+
|
|
148
158
|
# Write a line to a VCF file
|
|
149
159
|
attach_function \
|
|
150
160
|
:vcf_write_line,
|
data/lib/hts/libhts/vcf_funcs.rb
CHANGED
|
@@ -309,9 +309,22 @@ module HTS
|
|
|
309
309
|
end
|
|
310
310
|
|
|
311
311
|
def bcf_itr_querys(idx, hdr, s)
|
|
312
|
+
return bcf_itr_querys1(idx, hdr, s) if respond_to?(:bcf_itr_querys1)
|
|
313
|
+
|
|
312
314
|
hts_itr_querys(idx, s, @@bcf_hdr_name2id, hdr, @ffi_functions[:hts_itr_query], @ffi_functions[:bcf_readrec])
|
|
313
315
|
end
|
|
314
316
|
|
|
317
|
+
# Ruby implementation of htslib's static inline bcf_itr_next().
|
|
318
|
+
def bcf_itr_next(htsfp, itr, r)
|
|
319
|
+
return -2 unless htsfp[:is_bgzf] == 1
|
|
320
|
+
|
|
321
|
+
if itr[:multi] == 1
|
|
322
|
+
hts_itr_multi_next(htsfp, itr, r)
|
|
323
|
+
else
|
|
324
|
+
hts_itr_next(htsfp[:fp][:bgzf], itr, r, FFI::Pointer::NULL)
|
|
325
|
+
end
|
|
326
|
+
end
|
|
327
|
+
|
|
315
328
|
# Load a BCF index
|
|
316
329
|
def bcf_index_load(fn)
|
|
317
330
|
hts_idx_load(fn, HTS_FMT_CSI)
|
data/lib/hts/version.rb
CHANGED