htslib 0.0.5 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,430 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HTS
4
+ module LibHTS
5
+ attach_function \
6
+ :bcf_hdr_init,
7
+ [:string],
8
+ BcfHdr.by_ref
9
+
10
+ attach_function \
11
+ :bcf_hdr_destroy,
12
+ [BcfHdr],
13
+ :void
14
+
15
+ attach_function \
16
+ :bcf_init,
17
+ [],
18
+ Bcf1.by_ref
19
+
20
+ attach_function \
21
+ :bcf_destroy,
22
+ [Bcf1],
23
+ :void
24
+
25
+ attach_function \
26
+ :bcf_empty,
27
+ [Bcf1],
28
+ :void
29
+
30
+ attach_function \
31
+ :bcf_clear,
32
+ [Bcf1],
33
+ :void
34
+
35
+ attach_function \
36
+ :bcf_hdr_read,
37
+ [HtsFile],
38
+ BcfHdr.by_ref
39
+
40
+ attach_function \
41
+ :bcf_hdr_set_samples,
42
+ [BcfHdr, :string, :int],
43
+ :int
44
+
45
+ attach_function \
46
+ :bcf_subset_format,
47
+ [BcfHdr, Bcf1],
48
+ :int
49
+
50
+ attach_function \
51
+ :bcf_hdr_write,
52
+ [HtsFile, BcfHdr],
53
+ :int
54
+
55
+ attach_function \
56
+ :vcf_parse,
57
+ [KString, BcfHdr, Bcf1],
58
+ :int
59
+
60
+ attach_function \
61
+ :vcf_open_mode,
62
+ %i[string string string],
63
+ :int
64
+
65
+ attach_function \
66
+ :vcf_format,
67
+ [BcfHdr, Bcf1, KString],
68
+ :int
69
+
70
+ attach_function \
71
+ :bcf_read,
72
+ [HtsFile, BcfHdr, Bcf1],
73
+ :int
74
+
75
+ attach_function \
76
+ :bcf_unpack,
77
+ [Bcf1, :int],
78
+ :int
79
+
80
+ attach_function \
81
+ :bcf_dup,
82
+ [Bcf1],
83
+ Bcf1.by_ref
84
+
85
+ attach_function \
86
+ :bcf_copy,
87
+ [Bcf1, Bcf1],
88
+ Bcf1.by_ref
89
+
90
+ attach_function \
91
+ :bcf_write,
92
+ [HtsFile, BcfHdr, Bcf1],
93
+ :int
94
+
95
+ attach_function \
96
+ :vcf_hdr_read,
97
+ [HtsFile],
98
+ BcfHdr.by_ref
99
+
100
+ attach_function \
101
+ :vcf_hdr_write,
102
+ [HtsFile, BcfHdr],
103
+ :int
104
+
105
+ attach_function \
106
+ :vcf_read,
107
+ [HtsFile, BcfHdr, Bcf1],
108
+ :int
109
+
110
+ attach_function \
111
+ :vcf_write,
112
+ [HtsFile, BcfHdr, Bcf1],
113
+ :int
114
+
115
+ attach_function \
116
+ :bcf_readrec,
117
+ [BGZF, :pointer, :pointer, :pointer, :hts_pos_t, :hts_pos_t],
118
+ :int
119
+
120
+ attach_function \
121
+ :vcf_write_line,
122
+ [HtsFile, KString],
123
+ :int
124
+
125
+ attach_function \
126
+ :bcf_hdr_dup,
127
+ [BcfHdr],
128
+ BcfHdr.by_ref
129
+
130
+ attach_function \
131
+ :bcf_hdr_merge,
132
+ [BcfHdr, BcfHdr],
133
+ BcfHdr.by_ref
134
+
135
+ attach_function \
136
+ :bcf_hdr_add_sample,
137
+ [BcfHdr, :string],
138
+ :int
139
+
140
+ attach_function \
141
+ :bcf_hdr_set,
142
+ [BcfHdr, :string],
143
+ :int
144
+
145
+ attach_function \
146
+ :bcf_hdr_format,
147
+ [BcfHdr, :int, KString],
148
+ :int
149
+
150
+ attach_function \
151
+ :bcf_hdr_fmt_text,
152
+ [BcfHdr, :int, :pointer],
153
+ :string
154
+
155
+ attach_function \
156
+ :bcf_hdr_append,
157
+ [BcfHdr, :string],
158
+ :int
159
+
160
+ attach_function \
161
+ :bcf_hdr_printf,
162
+ [BcfHdr, :string, :varargs],
163
+ :int
164
+
165
+ attach_function \
166
+ :bcf_hdr_get_version,
167
+ [BcfHdr],
168
+ :string
169
+
170
+ attach_function \
171
+ :bcf_hdr_set_version,
172
+ [BcfHdr, :string],
173
+ :int
174
+
175
+ attach_function \
176
+ :bcf_hdr_remove,
177
+ [BcfHdr, :int, :string],
178
+ :void
179
+
180
+ attach_function \
181
+ :bcf_hdr_subset,
182
+ [BcfHdr, :int, :pointer, :pointer],
183
+ BcfHdr.by_ref
184
+
185
+ attach_function \
186
+ :bcf_hdr_seqnames,
187
+ [BcfHdr, :pointer],
188
+ :pointer
189
+
190
+ attach_function \
191
+ :bcf_hdr_parse,
192
+ [BcfHdr, :string],
193
+ :int
194
+
195
+ attach_function \
196
+ :bcf_hdr_sync,
197
+ [BcfHdr],
198
+ :int
199
+
200
+ attach_function \
201
+ :bcf_hdr_parse_line,
202
+ [BcfHdr, :string, :pointer],
203
+ BcfHrec.by_ref
204
+
205
+ attach_function \
206
+ :bcf_hrec_format,
207
+ [BcfHrec, KString],
208
+ :int
209
+
210
+ attach_function \
211
+ :bcf_hdr_add_hrec,
212
+ [BcfHdr, BcfHrec],
213
+ :int
214
+
215
+ attach_function \
216
+ :bcf_hdr_get_hrec,
217
+ [BcfHdr, :int, :string, :string, :string],
218
+ BcfHrec.by_ref
219
+
220
+ attach_function \
221
+ :bcf_hrec_dup,
222
+ [BcfHrec],
223
+ BcfHrec.by_ref
224
+
225
+ attach_function \
226
+ :bcf_hrec_add_key,
227
+ [BcfHrec, :string, :size_t],
228
+ :int
229
+
230
+ attach_function \
231
+ :bcf_hrec_set_val,
232
+ [BcfHrec, :int, :string, :size_t, :int],
233
+ :int
234
+
235
+ attach_function \
236
+ :bcf_hrec_find_key,
237
+ [BcfHrec, :string],
238
+ :int
239
+
240
+ attach_function \
241
+ :hrec_add_idx,
242
+ [BcfHrec, :int],
243
+ :int
244
+
245
+ attach_function \
246
+ :bcf_hrec_destroy,
247
+ [BcfHrec],
248
+ :void
249
+
250
+ attach_function \
251
+ :bcf_subset,
252
+ [BcfHdr, Bcf1, :int, :pointer],
253
+ :int
254
+
255
+ attach_function \
256
+ :bcf_translate,
257
+ [BcfHdr, BcfHdr, Bcf1],
258
+ :int
259
+
260
+ attach_function \
261
+ :bcf_get_variant_types,
262
+ [Bcf1],
263
+ :int
264
+
265
+ attach_function \
266
+ :bcf_get_variant_type,
267
+ [Bcf1, :int],
268
+ :int
269
+
270
+ attach_function \
271
+ :bcf_is_snp,
272
+ [Bcf1],
273
+ :int
274
+
275
+ attach_function \
276
+ :bcf_update_filter,
277
+ [BcfHdr, Bcf1, :pointer, :int],
278
+ :int
279
+
280
+ attach_function \
281
+ :bcf_add_filter,
282
+ [BcfHdr, Bcf1, :int],
283
+ :int
284
+
285
+ attach_function \
286
+ :bcf_remove_filter,
287
+ [BcfHdr, Bcf1, :int, :int],
288
+ :int
289
+
290
+ attach_function \
291
+ :bcf_has_filter,
292
+ [BcfHdr, Bcf1, :string],
293
+ :int
294
+
295
+ attach_function \
296
+ :bcf_update_alleles,
297
+ [BcfHdr, Bcf1, :pointer, :int],
298
+ :int
299
+
300
+ attach_function \
301
+ :bcf_update_alleles_str,
302
+ [BcfHdr, Bcf1, :string],
303
+ :int
304
+
305
+ attach_function \
306
+ :bcf_update_id,
307
+ [BcfHdr, Bcf1, :string],
308
+ :int
309
+
310
+ attach_function \
311
+ :bcf_add_id,
312
+ [BcfHdr, Bcf1, :string],
313
+ :int
314
+
315
+ attach_function \
316
+ :bcf_update_info,
317
+ [BcfHdr, Bcf1, :string, :pointer, :int, :int],
318
+ :int
319
+
320
+ attach_function \
321
+ :bcf_update_format_string,
322
+ [BcfHdr, Bcf1, :string, :pointer, :int],
323
+ :int
324
+
325
+ attach_function \
326
+ :bcf_update_format,
327
+ [BcfHdr, Bcf1, :string, :pointer, :int, :int],
328
+ :int
329
+
330
+ attach_function \
331
+ :bcf_get_fmt,
332
+ [BcfHdr, Bcf1, :string],
333
+ BcfFmt.by_ref
334
+
335
+ attach_function \
336
+ :bcf_get_info,
337
+ [BcfHdr, Bcf1, :string],
338
+ BcfInfo.by_ref
339
+
340
+ attach_function \
341
+ :bcf_get_fmt_id,
342
+ [Bcf1, :int],
343
+ BcfFmt.by_ref
344
+
345
+ attach_function \
346
+ :bcf_get_info_id,
347
+ [Bcf1, :int],
348
+ BcfInfo.by_ref
349
+
350
+ attach_function \
351
+ :bcf_get_info_values,
352
+ [BcfHdr, Bcf1, :string, :pointer, :pointer, :int],
353
+ :int
354
+
355
+ attach_function \
356
+ :bcf_get_format_string,
357
+ [BcfHdr, Bcf1, :string, :pointer, :pointer],
358
+ :int
359
+
360
+ attach_function \
361
+ :bcf_get_format_values,
362
+ [BcfHdr, Bcf1, :string, :pointer, :pointer, :int],
363
+ :int
364
+
365
+ attach_function \
366
+ :bcf_hdr_id2int,
367
+ [BcfHdr, :int, :string],
368
+ :int
369
+
370
+ attach_function \
371
+ :bcf_fmt_array,
372
+ [KString, :int, :int, :pointer],
373
+ :int
374
+
375
+ attach_function \
376
+ :bcf_fmt_sized_array,
377
+ [KString, :pointer],
378
+ :uint8_t
379
+
380
+ attach_function \
381
+ :bcf_enc_vchar,
382
+ [KString, :int, :string],
383
+ :int
384
+
385
+ attach_function \
386
+ :bcf_enc_vint,
387
+ [KString, :int, :pointer, :int],
388
+ :int
389
+
390
+ attach_function \
391
+ :bcf_enc_vfloat,
392
+ [KString, :int, :pointer],
393
+ :int
394
+
395
+ attach_function \
396
+ :bcf_index_load2,
397
+ %i[string string],
398
+ HtsIdx.by_ref
399
+
400
+ attach_function \
401
+ :bcf_index_load3,
402
+ %i[string string int],
403
+ HtsIdx.by_ref
404
+
405
+ attach_function \
406
+ :bcf_index_build,
407
+ %i[string int],
408
+ :int
409
+
410
+ attach_function \
411
+ :bcf_index_build2,
412
+ %i[string string int],
413
+ :int
414
+
415
+ attach_function \
416
+ :bcf_index_build3,
417
+ %i[string string int int],
418
+ :int
419
+
420
+ attach_function \
421
+ :bcf_idx_init,
422
+ [HtsFile, BcfHdr, :int, :string],
423
+ :int
424
+
425
+ attach_function \
426
+ :bcf_idx_save,
427
+ [HtsFile],
428
+ :int
429
+ end
430
+ end
data/lib/hts/libhts.rb CHANGED
@@ -23,11 +23,13 @@ end
23
23
  require_relative "libhts/constants"
24
24
 
25
25
  # This is alphabetical order.
26
+ require_relative "libhts/kfunc"
26
27
  require_relative "libhts/bgzf"
27
- require_relative "libhts/faidx"
28
28
  require_relative "libhts/hfile"
29
29
  require_relative "libhts/hts"
30
30
  require_relative "libhts/sam"
31
- require_relative "libhts/kfunc"
32
- require_relative "libhts/tbx"
31
+ require_relative "libhts/cram"
33
32
  require_relative "libhts/vcf"
33
+ require_relative "libhts/tbx"
34
+ require_relative "libhts/faidx"
35
+ require_relative "libhts/thread_pool"
data/lib/hts/tabix.rb CHANGED
@@ -1,28 +1,53 @@
1
- # frozen_string_literal: true
1
+ require_relative "../htslib"
2
2
 
3
- # Based on hts-python
4
- # https://github.com/quinlan-lab/hts-python
3
+ require_relative "hts"
5
4
 
6
5
  module HTS
7
- class Tabix
8
- class << self
9
- alias open new
6
+ class Tabix < Hts
7
+ include Enumerable
8
+
9
+ attr_reader :file_name
10
+
11
+ def self.open(*args, **kw)
12
+ file = new(*args, **kw) # do not yield
13
+ return file unless block_given?
14
+
15
+ begin
16
+ yield file
17
+ ensure
18
+ file.close
19
+ end
20
+ file
10
21
  end
11
- def initialize
12
- # IO like API
22
+
23
+ def initialize(file_name, threads: nil)
13
24
  if block_given?
14
- begin
15
- yield self
16
- ensure
17
- close
18
- end
25
+ message = "HTS::Tabix.new() dose not take block; Please use HTS::Tabix.open() instead"
26
+ raise message
19
27
  end
20
- end
21
28
 
22
- def build; end
29
+ @file_name = file_name
30
+
31
+ # NOTE: Do not check for the existence of local files, since file_names may be remote URIs.
23
32
 
24
- def sequences; end
33
+ @mode = "r"
34
+ @hts_file = LibHTS.hts_open(@file_name, @mode)
25
35
 
26
- # def __call__\
36
+ raise Errno::ENOENT, "Failed to open #{@file_name}" if @hts_file.null?
37
+
38
+ if threads&.> 0
39
+ r = LibHTS.hts_set_threads(@hts_file, threads)
40
+ raise "Failed to set number of threads: #{threads}" if r < 0
41
+ end
42
+ 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
27
52
  end
28
53
  end
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.0.5"
4
+ VERSION = "0.0.10"
5
5
  end
data/lib/htslib.rb CHANGED
@@ -37,9 +37,9 @@ module HTS
37
37
  # You can change the path of the shared library with `HTS.lib_path=`
38
38
  # before calling the LibHTS module.
39
39
  autoload :LibHTS, "hts/libhts"
40
- end
41
40
 
42
- require_relative "hts/bam"
43
- require_relative "hts/faidx"
44
- require_relative "hts/tabix"
45
- require_relative "hts/bcf"
41
+ autoload :Bam, "hts/bam"
42
+ autoload :Bcf, "hts/bcf"
43
+ autoload :Tabix, "hts/tabix"
44
+ autoload :Faidx, "hts/faidx"
45
+ end
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.0.5
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - kojix2
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-26 00:00:00.000000000 Z
11
+ date: 2022-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -144,16 +144,21 @@ files:
144
144
  - lib/hts/faidx.rb
145
145
  - lib/hts/ffi_ext/README.md
146
146
  - lib/hts/ffi_ext/struct.rb
147
+ - lib/hts/hts.rb
147
148
  - lib/hts/libhts.rb
148
149
  - lib/hts/libhts/bgzf.rb
149
150
  - lib/hts/libhts/constants.rb
151
+ - lib/hts/libhts/cram.rb
150
152
  - lib/hts/libhts/faidx.rb
151
153
  - lib/hts/libhts/hfile.rb
152
154
  - lib/hts/libhts/hts.rb
153
155
  - lib/hts/libhts/kfunc.rb
154
156
  - lib/hts/libhts/sam.rb
157
+ - lib/hts/libhts/sam_funcs.rb
155
158
  - lib/hts/libhts/tbx.rb
159
+ - lib/hts/libhts/thread_pool.rb
156
160
  - lib/hts/libhts/vcf.rb
161
+ - lib/hts/libhts/vcf_funcs.rb
157
162
  - lib/hts/tabix.rb
158
163
  - lib/hts/version.rb
159
164
  - lib/htslib.rb
@@ -176,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
181
  - !ruby/object:Gem::Version
177
182
  version: '0'
178
183
  requirements: []
179
- rubygems_version: 3.3.3
184
+ rubygems_version: 3.3.7
180
185
  signing_key:
181
186
  specification_version: 4
182
187
  summary: HTSlib bindings for Ruby