htslib 0.4.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86838244ad390e04fb293d3db9fd639c837dcd7b2309cc0c83da0b5925e7185c
4
- data.tar.gz: 547063279b934706efcf919d287217f4231fe76d2e8fb3ae6df8e4dd7b6040ad
3
+ metadata.gz: 69e910e95cfe1bef250416f8bbe480a39a1bc54b53103435cf15811860f3b92d
4
+ data.tar.gz: 060c7e5af8127c496af3b5d5bec5eca5e7476cb34ccc86a75546fd1a80d6dd8a
5
5
  SHA512:
6
- metadata.gz: 787f9167abef88ddbd758d3155f1f3568bb99d8a5a340086a1cc677be46e0e77ec5a0ef56d201610f06143d0f54a20a1f2563ae3e080996564b5b5545e3e8a2a
7
- data.tar.gz: d07ae5e437c9729a39e32adb12ff694560eaa33e44094679199bc8b742ccaab4c5a111c7e6391a314a8b6a19fae82acea549123b57497690678e1b2b1746f2c7
6
+ metadata.gz: 62adc672a3606265d231efa7f568232d55279634c8fb650190aee01c750b0dbac2421a1cf8fb2507bf5b21e16afbe4e4425354cd3dd2b1398d4df7b3f24e6655
7
+ data.tar.gz: 2a6bd47a73ff2695a515e934fa1919d8fcdf1108e10178404af31da769b4e7c40a8580f2382ab8f7e6ac8697261344fb32ecebc138807d5cd03724745457f4d4
@@ -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.hts_itr_next(@hts_file[:fp][:bgzf], qiter, bcf1, ::FFI::Pointer::NULL)
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.hts_itr_next(@hts_file[:fp][:bgzf], qiter, bcf1, ::FFI::Pointer::NULL)
374
+ slen = LibHTS.bcf_itr_next(@hts_file, qiter, bcf1)
375
375
  break if slen == -1
376
376
  raise if slen < -1
377
377
 
@@ -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,
@@ -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,
@@ -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
 
@@ -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,
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HTS
4
- VERSION = "0.4.1"
4
+ VERSION = "0.4.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: htslib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - kojix2