htslib 0.4.1 → 0.5.0

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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +79 -49
  3. data/TUTORIAL.md +9 -20
  4. data/ext/htslib_native/extconf.rb +41 -0
  5. data/ext/htslib_native/htslib_native.h +11 -0
  6. data/ext/htslib_native/htslib_native_ext.c +48 -0
  7. data/ext/htslib_native/native_bam.c +1108 -0
  8. data/ext/htslib_native/native_bcf.c +369 -0
  9. data/ext/htslib_native/native_faidx.c +155 -0
  10. data/ext/htslib_native/native_tabix.c +246 -0
  11. data/lib/hts/bam/auxi.rb +87 -342
  12. data/lib/hts/bam/base_mod.rb +37 -73
  13. data/lib/hts/bam/cigar.rb +9 -55
  14. data/lib/hts/bam/flag.rb +19 -27
  15. data/lib/hts/bam/header.rb +29 -56
  16. data/lib/hts/bam/mpileup.rb +158 -132
  17. data/lib/hts/bam/pileup.rb +120 -145
  18. data/lib/hts/bam/record.rb +233 -270
  19. data/lib/hts/bam.rb +102 -42
  20. data/lib/hts/bcf/errors.rb +1 -0
  21. data/lib/hts/bcf/format.rb +278 -379
  22. data/lib/hts/bcf/header.rb +38 -123
  23. data/lib/hts/bcf/header_record.rb +9 -35
  24. data/lib/hts/bcf/info.rb +72 -320
  25. data/lib/hts/bcf/record.rb +61 -102
  26. data/lib/hts/bcf.rb +149 -323
  27. data/lib/hts/faidx.rb +28 -87
  28. data/lib/hts/hts.rb +6 -94
  29. data/lib/hts/native.rb +13 -0
  30. data/lib/hts/tabix.rb +93 -48
  31. data/lib/hts/version.rb +1 -1
  32. data/lib/htslib.rb +6 -52
  33. metadata +13 -64
  34. data/lib/hts/ffi_ext/README.md +0 -8
  35. data/lib/hts/ffi_ext/pointer.rb +0 -18
  36. data/lib/hts/ffi_ext/struct.rb +0 -45
  37. data/lib/hts/libhts/bgzf.rb +0 -199
  38. data/lib/hts/libhts/constants.rb +0 -658
  39. data/lib/hts/libhts/cram.rb +0 -471
  40. data/lib/hts/libhts/fai.rb +0 -146
  41. data/lib/hts/libhts/hfile.rb +0 -109
  42. data/lib/hts/libhts/hts.rb +0 -477
  43. data/lib/hts/libhts/kfunc.rb +0 -38
  44. data/lib/hts/libhts/sam.rb +0 -760
  45. data/lib/hts/libhts/sam_funcs.rb +0 -155
  46. data/lib/hts/libhts/tbx.rb +0 -79
  47. data/lib/hts/libhts/tbx_funcs.rb +0 -32
  48. data/lib/hts/libhts/thread_pool.rb +0 -139
  49. data/lib/hts/libhts/vcf.rb +0 -557
  50. data/lib/hts/libhts/vcf_funcs.rb +0 -353
  51. data/lib/hts/libhts.rb +0 -47
@@ -1,477 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module HTS
4
- module LibHTS
5
- # hts_expand
6
- # hts_expand3
7
- # hts_resize
8
-
9
- # Sets the selected log level.
10
- attach_function \
11
- :hts_set_log_level,
12
- [HtsLogLevel],
13
- :void
14
-
15
- # Gets the selected log level.
16
- attach_function \
17
- :hts_get_log_level,
18
- [],
19
- HtsLogLevel
20
-
21
- attach_function \
22
- :hts_lib_shutdown,
23
- [],
24
- :void
25
-
26
- attach_function \
27
- :hts_free,
28
- [:pointer],
29
- :void
30
-
31
- # Parses arg and appends it to the option list.
32
- attach_function \
33
- :hts_opt_add,
34
- %i[pointer string],
35
- :int
36
-
37
- # Applies an hts_opt option list to a given htsFile.
38
- attach_function \
39
- :hts_opt_apply,
40
- [HtsFile, HtsOpt],
41
- :int
42
-
43
- # Frees an hts_opt list.
44
- attach_function \
45
- :hts_opt_free,
46
- [HtsOpt],
47
- :void
48
-
49
- # Accepts a string file format (sam, bam, cram, vcf, bam)
50
- attach_function \
51
- :hts_parse_format,
52
- [HtsFormat, :string],
53
- :int
54
-
55
- # Tokenise options as (key(=value)?,)*(key(=value)?)?
56
- attach_function \
57
- :hts_parse_opt_list,
58
- [HtsFormat, :string],
59
- :int
60
-
61
- # Get the htslib version number
62
- attach_function \
63
- :hts_version,
64
- [],
65
- :string
66
-
67
- # Introspection on the features enabled in htslib
68
- attach_function \
69
- :hts_features,
70
- [],
71
- :uint
72
-
73
- attach_function \
74
- :hts_test_feature,
75
- [:uint],
76
- :string
77
-
78
- # Introspection on the features enabled in htslib, string form
79
- attach_function \
80
- :hts_feature_string,
81
- [],
82
- :string
83
-
84
- # Determine format by peeking at the start of a file
85
- attach_function \
86
- :hts_detect_format,
87
- [HFile, HtsFormat],
88
- :int
89
-
90
- # Determine format primarily by peeking at the start of a file
91
- attach_function \
92
- :hts_detect_format2,
93
- [HFile, :string, HtsFormat],
94
- :int
95
-
96
- # Get a human-readable description of the file format
97
- attach_function \
98
- :hts_format_description,
99
- [HtsFormat],
100
- :string
101
-
102
- # Open a sequence data (SAM/BAM/CRAM) or variant data (VCF/BCF)
103
- # or possibly-compressed textual line-orientated file
104
- attach_function \
105
- :hts_open,
106
- %i[string string],
107
- HtsFile.by_ref
108
-
109
- # Open a SAM/BAM/CRAM/VCF/BCF/etc file
110
- attach_function \
111
- :hts_open_format,
112
- [:string, :string, HtsFormat],
113
- HtsFile.by_ref
114
-
115
- # Open an existing stream as a SAM/BAM/CRAM/VCF/BCF/etc file
116
- attach_function \
117
- :hts_hopen,
118
- [HFile, :string, :string],
119
- HtsFile.by_ref
120
-
121
- # For output streams, flush any buffered data
122
- attach_function \
123
- :hts_flush,
124
- [HtsFile],
125
- :int
126
-
127
- # Close a file handle, flushing buffered data for output streams
128
- attach_function \
129
- :hts_close,
130
- [HtsFile],
131
- :int
132
-
133
- # Returns the file's format information
134
- attach_function \
135
- :hts_get_format,
136
- [HtsFile],
137
- HtsFormat.by_ref
138
-
139
- # Returns a string containing the file format extension.
140
- attach_function \
141
- :hts_format_file_extension,
142
- [HtsFormat],
143
- :string
144
-
145
- # Sets a specified CRAM option on the open file handle.
146
- attach_function \
147
- :hts_set_opt,
148
- [HtsFile, HtsFmtOption, :varargs],
149
- :int
150
-
151
- # Read a line (and its \n or \r\n terminator) from a file
152
- attach_function \
153
- :hts_getline,
154
- [HtsFile, :int, KString],
155
- :int
156
-
157
- attach_function \
158
- :hts_readlines,
159
- %i[string pointer],
160
- :pointer
161
-
162
- # Parse comma-separated list or read list from a file
163
- attach_function \
164
- :hts_readlist,
165
- %i[string int pointer],
166
- :pointer
167
-
168
- # Create extra threads to aid compress/decompression for this file
169
- attach_function \
170
- :hts_set_threads,
171
- [HtsFile, :int],
172
- :int
173
-
174
- # Create extra threads to aid compress/decompression for this file
175
- attach_function \
176
- :hts_set_thread_pool,
177
- [HtsFile, HtsTpool],
178
- :int
179
-
180
- # Adds a cache of decompressed blocks, potentially speeding up seeks.
181
- attach_function \
182
- :hts_set_cache_size,
183
- [HtsFile, :int],
184
- :void
185
-
186
- # Set .fai filename for a file opened for reading
187
- attach_function \
188
- :hts_set_fai_filename,
189
- [HtsFile, :string],
190
- :int
191
-
192
- # Sets a filter expression
193
- attach_function \
194
- :hts_set_filter_expression,
195
- [HtsFile, :string],
196
- :int
197
-
198
- # Determine whether a given htsFile contains a valid EOF block
199
- attach_function \
200
- :hts_check_EOF,
201
- [HtsFile],
202
- :int
203
-
204
- # hts_pair_pos_t
205
- # hts_pair64_t
206
- # hts_pair4_max_t
207
- # hts_reglist_t
208
- # hts_readrec_func
209
- # hts_seek_func
210
- # hts_tell_func
211
-
212
- # Create a BAI/CSI/TBI type index structure
213
- attach_function \
214
- :hts_idx_init,
215
- %i[int int uint64 int int],
216
- :pointer
217
-
218
- # Free a BAI/CSI/TBI type index
219
- attach_function \
220
- :hts_idx_destroy,
221
- [HtsIdx],
222
- :void
223
-
224
- # Push an index entry
225
- attach_function \
226
- :hts_idx_push,
227
- [HtsIdx, :int, :int64, :int64, :uint64, :int],
228
- :int
229
-
230
- # Finish building an index
231
- attach_function \
232
- :hts_idx_finish,
233
- [HtsIdx, :uint64],
234
- :int
235
-
236
- # Returns index format
237
- attach_function \
238
- :hts_idx_fmt,
239
- [HtsIdx],
240
- :int
241
-
242
- # Add name to TBI index meta-data
243
- attach_function \
244
- :hts_idx_tbi_name,
245
- [HtsIdx, :int, :string],
246
- :int
247
-
248
- # Save an index to a file
249
- attach_function \
250
- :hts_idx_save,
251
- [HtsIdx, :string, :int],
252
- :int
253
-
254
- # Save an index to a specific file
255
- attach_function \
256
- :hts_idx_save_as,
257
- [HtsIdx, :string, :string, :int],
258
- :int
259
-
260
- # Load an index file
261
- attach_function \
262
- :hts_idx_load,
263
- %i[string int],
264
- HtsIdx.by_ref
265
-
266
- # Load a specific index file
267
- attach_function \
268
- :hts_idx_load2,
269
- %i[string string],
270
- HtsIdx.by_ref
271
-
272
- # Load a specific index file
273
- attach_function \
274
- :hts_idx_load3,
275
- %i[string string int int],
276
- HtsIdx.by_ref
277
-
278
- # Get extra index meta-data
279
- attach_function \
280
- :hts_idx_get_meta,
281
- [HtsIdx, :pointer],
282
- :uint8
283
-
284
- # Set extra index meta-data
285
- attach_function \
286
- :hts_idx_set_meta,
287
- [HtsIdx, :uint32, :pointer, :int],
288
- :int
289
-
290
- # Get number of mapped and unmapped reads from an index
291
- attach_function \
292
- :hts_idx_get_stat,
293
- [HtsIdx, :int, :pointer, :pointer],
294
- :int
295
-
296
- # Return the number of unplaced reads from an index
297
- attach_function \
298
- :hts_idx_get_n_no_coor,
299
- [HtsIdx],
300
- :uint64
301
-
302
- # Return a list of target names from an index
303
- attach_function \
304
- :hts_idx_seqnames,
305
- [HtsIdx, :pointer, :pointer, :pointer],
306
- :pointer
307
-
308
- # Return the number of targets from an index
309
- attach_function \
310
- :hts_idx_nseq,
311
- [HtsIdx],
312
- :int
313
-
314
- # Parse a numeric string
315
- attach_function \
316
- :hts_parse_decimal,
317
- %i[string pointer int],
318
- :long_long
319
-
320
- callback :hts_name2id_f, %i[pointer string], :int
321
-
322
- # Parse a "CHR:START-END"-style region string
323
- attach_function \
324
- :hts_parse_reg64,
325
- %i[string pointer pointer],
326
- :string
327
-
328
- # Parse a "CHR:START-END"-style region string
329
- attach_function \
330
- :hts_parse_reg,
331
- %i[string pointer pointer],
332
- :string
333
-
334
- # Parse a "CHR:START-END"-style region string
335
- attach_function \
336
- :hts_parse_region,
337
- %i[string pointer pointer pointer hts_name2id_f pointer int],
338
- :string
339
-
340
- # Create a single-region iterator
341
- attach_function \
342
- :hts_itr_query,
343
- [HtsIdx, :int, :hts_pos_t, :hts_pos_t, :pointer],
344
- HtsItr.by_ref
345
-
346
- # Free an iterator
347
- attach_function \
348
- :hts_itr_destroy,
349
- [HtsItr],
350
- :void
351
-
352
- # Create a single-region iterator from a text region specification
353
- attach_function \
354
- :hts_itr_querys,
355
- [HtsIdx, :string, :hts_name2id_f, :pointer, :pointer, :pointer],
356
- HtsItr.by_ref
357
-
358
- # Return the next record from an iterator
359
- attach_function \
360
- :hts_itr_next,
361
- [BGZF, HtsItr, :pointer, :pointer],
362
- :int
363
-
364
- attach_function \
365
- :hts_itr_multi_bam,
366
- [HtsIdx, HtsItr],
367
- :int
368
-
369
- attach_function \
370
- :hts_itr_multi_cram,
371
- [HtsIdx, HtsItr],
372
- :int
373
-
374
- # Create a multi-region iterator from a region list
375
- attach_function \
376
- :hts_itr_regions,
377
- [HtsIdx,
378
- :pointer, # hts_reglist_t *
379
- :int,
380
- :hts_name2id_f,
381
- :pointer,
382
- :pointer, # hts_itr_multi_query_func
383
- :pointer, # hts_readrec_func
384
- :pointer, # hts_seek_func
385
- :pointer # hts_tell_func
386
- ],
387
- HtsItr.by_ref
388
-
389
- # Return the next record from an iterator
390
- attach_function \
391
- :hts_itr_multi_next,
392
- [HtsFile, HtsItr, :pointer],
393
- :int
394
-
395
- # Create a region list from a char array
396
- attach_function \
397
- :hts_reglist_create,
398
- %i[pointer int pointer pointer hts_name2id_f],
399
- HtsReglist.by_ref
400
-
401
- # Free a region list
402
- attach_function \
403
- :hts_reglist_free,
404
- [HtsReglist, :int],
405
- :void
406
-
407
- # Deprecated
408
- # Convenience function to determine file type
409
- # attach_function \
410
- # :hts_file_type,
411
- # [:string],
412
- # :int
413
-
414
- attach_function \
415
- :errmod_init,
416
- [:double],
417
- :pointer
418
-
419
- attach_function \
420
- :errmod_destroy,
421
- [:pointer],
422
- :void
423
-
424
- attach_function \
425
- :errmod_cal,
426
- %i[pointer int int pointer pointer],
427
- :int
428
-
429
- # Perform probabilistic banded glocal alignment
430
- attach_function \
431
- :probaln_glocal,
432
- %i[pointer int pointer int pointer pointer pointer pointer],
433
- :int
434
-
435
- # Initialises an MD5 context.
436
- attach_function \
437
- :hts_md5_init,
438
- [],
439
- :pointer # hts_md5_context
440
-
441
- # Updates the context with the MD5 of the data.
442
- attach_function \
443
- :hts_md5_update,
444
- %i[pointer pointer ulong],
445
- :void
446
-
447
- # Computes the final 128-bit MD5 hash from the given context
448
- attach_function \
449
- :hts_md5_final,
450
- %i[pointer pointer], # unsigned char
451
- :void
452
-
453
- # Resets an md5_context to the initial state, as returned by hts_md5_init().
454
- attach_function \
455
- :hts_md5_reset,
456
- [:pointer],
457
- :void
458
-
459
- # Converts a 128-bit MD5 hash into a 33-byte nul-termninated by string.
460
- attach_function \
461
- :hts_md5_hex,
462
- %i[string pointer],
463
- :void
464
-
465
- # Deallocates any memory allocated by hts_md5_init.
466
- attach_function \
467
- :hts_md5_destroy,
468
- [:pointer],
469
- :void
470
-
471
- # Computes CRC32 for a buffer with an initial crc value
472
- attach_function \
473
- :hts_crc32,
474
- %i[uint32 pointer size_t],
475
- :uint32
476
- end
477
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module HTS
4
- module LibHTS
5
- # Log gamma function
6
- attach_function \
7
- :kf_lgamma,
8
- [:double],
9
- :double
10
-
11
- # complementary error function
12
- attach_function \
13
- :kf_erfc,
14
- [:double],
15
- :double
16
-
17
- # The following computes regularized incomplete gamma functions.
18
- attach_function \
19
- :kf_gammap,
20
- %i[double double],
21
- :double
22
-
23
- attach_function \
24
- :kf_gammaq,
25
- %i[double double],
26
- :double
27
-
28
- attach_function \
29
- :kf_betai,
30
- %i[double double double],
31
- :double
32
-
33
- attach_function \
34
- :kt_fisher_exact,
35
- %i[int int int int pointer pointer pointer],
36
- :double
37
- end
38
- end