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,557 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module HTS
4
- module LibHTS
5
- # Get error description for bcf error code
6
- attach_function \
7
- :bcf_strerror,
8
- %i[int pointer size_t],
9
- :string
10
-
11
- # Create an empty BCF header.
12
- attach_function \
13
- :bcf_hdr_init,
14
- [:string],
15
- BcfHdr.by_ref
16
-
17
- # Destroy a BCF header struct
18
- attach_function \
19
- :bcf_hdr_destroy,
20
- [BcfHdr],
21
- :void
22
-
23
- # Allocate and initialize a bcf1_t object.
24
- attach_function \
25
- :bcf_init,
26
- [],
27
- Bcf1.by_ref
28
-
29
- # Deallocate a bcf1_t object
30
- attach_function \
31
- :bcf_destroy,
32
- [Bcf1],
33
- :void
34
-
35
- # Same as bcf_destroy() but frees only the memory allocated by bcf1_t,
36
- # not the bcf1_t object itself.
37
- attach_function \
38
- :bcf_empty,
39
- [Bcf1],
40
- :void
41
-
42
- # Make the bcf1_t object ready for next read.
43
- attach_function \
44
- :bcf_clear,
45
- [Bcf1],
46
- :void
47
-
48
- # Read a VCF or BCF header
49
- attach_function \
50
- :bcf_hdr_read,
51
- [HtsFile],
52
- BcfHdr.by_ref
53
-
54
- # for more efficient VCF parsing when only one/few samples are needed
55
- attach_function \
56
- :bcf_hdr_set_samples,
57
- [BcfHdr, :string, :int],
58
- :int
59
-
60
- attach_function \
61
- :bcf_subset_format,
62
- [BcfHdr, Bcf1],
63
- :int
64
-
65
- # Write a VCF or BCF header
66
- attach_function \
67
- :bcf_hdr_write,
68
- [HtsFile, BcfHdr],
69
- :int
70
-
71
- # Parse VCF line contained in kstring and populate the bcf1_t struct
72
- attach_function \
73
- :vcf_parse,
74
- [KString, BcfHdr, Bcf1],
75
- :int
76
-
77
- # Complete the file opening mode, according to its extension.
78
- attach_function \
79
- :vcf_open_mode,
80
- %i[string string string],
81
- :int
82
-
83
- # The opposite of vcf_parse.
84
- attach_function \
85
- :vcf_format,
86
- [BcfHdr, Bcf1, KString],
87
- :int
88
-
89
- # Read next VCF or BCF record
90
- attach_function \
91
- :bcf_read,
92
- [HtsFile, BcfHdr, Bcf1],
93
- :int
94
-
95
- # unpack/decode a BCF record (fills the bcf1_t::d field)
96
- attach_function \
97
- :bcf_unpack,
98
- [Bcf1, :int],
99
- :int
100
-
101
- # Create a copy of BCF record.
102
- attach_function \
103
- :bcf_dup,
104
- [Bcf1],
105
- Bcf1.by_ref
106
-
107
- attach_function \
108
- :bcf_copy,
109
- [Bcf1, Bcf1],
110
- Bcf1.by_ref
111
-
112
- # Write one VCF or BCF record.
113
- attach_function \
114
- :bcf_write,
115
- [HtsFile, BcfHdr, Bcf1],
116
- :int
117
-
118
- # Read a VCF format header
119
- attach_function \
120
- :vcf_hdr_read,
121
- [HtsFile],
122
- BcfHdr.by_ref
123
-
124
- # Write a VCF format header
125
- attach_function \
126
- :vcf_hdr_write,
127
- [HtsFile, BcfHdr],
128
- :int
129
-
130
- # Read a record from a VCF file
131
- attach_function \
132
- :vcf_read,
133
- [HtsFile, BcfHdr, Bcf1],
134
- :int
135
-
136
- # Write a record to a VCF file
137
- attach_function \
138
- :vcf_write,
139
- [HtsFile, BcfHdr, Bcf1],
140
- :int
141
-
142
- # Helper function for the bcf_itr_next() macro
143
- attach_function \
144
- :bcf_readrec,
145
- [BGZF, :pointer, :pointer, :pointer, :hts_pos_t, :hts_pos_t],
146
- :int
147
-
148
- # Write a line to a VCF file
149
- attach_function \
150
- :vcf_write_line,
151
- [HtsFile, KString],
152
- :int
153
-
154
- # Header querying and manipulation routines
155
-
156
- # Create a new header using the supplied template
157
- attach_function \
158
- :bcf_hdr_dup,
159
- [BcfHdr],
160
- BcfHdr.by_ref
161
-
162
- # DEPRECATED please use bcf_hdr_merge instead
163
- #
164
- # attach_function \
165
- # :bcf_hdr_combine,
166
- # [BcfHdr, BcfHdr],
167
- # :int
168
-
169
- # Copy header lines from src to dst, see also bcf_translate()
170
- attach_function \
171
- :bcf_hdr_merge,
172
- [BcfHdr, BcfHdr],
173
- BcfHdr.by_ref
174
-
175
- # Add a new sample.
176
- attach_function \
177
- :bcf_hdr_add_sample,
178
- [BcfHdr, :string],
179
- :int
180
-
181
- # Read VCF header from a file and update the header
182
- attach_function \
183
- :bcf_hdr_set,
184
- [BcfHdr, :string],
185
- :int
186
-
187
- # Appends formatted header text to _str_.
188
- attach_function \
189
- :bcf_hdr_format,
190
- [BcfHdr, :int, KString],
191
- :int
192
-
193
- # DEPRECATED use bcf_hdr_format() instead
194
- #
195
- # attach_function \
196
- # :bcf_hdr_fmt_text,
197
- # [BcfHdr, :int, :pointer],
198
- # :string
199
-
200
- # Append new VCF header line
201
- attach_function \
202
- :bcf_hdr_append,
203
- [BcfHdr, :string],
204
- :int
205
-
206
- attach_function \
207
- :bcf_hdr_printf,
208
- [BcfHdr, :string, :varargs],
209
- :int
210
-
211
- # VCF version, e.g. VCFv4.2
212
- attach_function \
213
- :bcf_hdr_get_version,
214
- [BcfHdr],
215
- :string
216
-
217
- # Set version in bcf header
218
- attach_function \
219
- :bcf_hdr_set_version,
220
- [BcfHdr, :string],
221
- :int
222
-
223
- # Remove VCF header tag
224
- attach_function \
225
- :bcf_hdr_remove,
226
- [BcfHdr, :int, :string],
227
- :void
228
-
229
- # Creates a new copy of the header removing unwanted samples
230
- attach_function \
231
- :bcf_hdr_subset,
232
- [BcfHdr, :int, :pointer, :pointer],
233
- BcfHdr.by_ref
234
-
235
- # Creates a list of sequence names.
236
- attach_function \
237
- :bcf_hdr_seqnames,
238
- [BcfHdr, :pointer],
239
- :pointer
240
-
241
- attach_function \
242
- :bcf_hdr_parse,
243
- [BcfHdr, :string],
244
- :int
245
-
246
- # Synchronize internal header structures
247
- attach_function \
248
- :bcf_hdr_sync,
249
- [BcfHdr],
250
- :int
251
-
252
- # parse a single line of VCF textual header
253
- attach_function \
254
- :bcf_hdr_parse_line,
255
- [BcfHdr, :string, :pointer],
256
- BcfHrec.by_ref
257
-
258
- # Convert a bcf header record to string form
259
- attach_function \
260
- :bcf_hrec_format,
261
- [BcfHrec, KString],
262
- :int
263
-
264
- attach_function \
265
- :bcf_hdr_add_hrec,
266
- [BcfHdr, BcfHrec],
267
- :int
268
-
269
- # Get header line info
270
- attach_function \
271
- :bcf_hdr_get_hrec,
272
- [BcfHdr, :int, :string, :string, :string],
273
- :pointer
274
-
275
- # Duplicate a header record
276
- attach_function \
277
- :bcf_hrec_dup,
278
- [:pointer],
279
- BcfHrec.by_ref
280
-
281
- # Add a new header record key
282
- attach_function \
283
- :bcf_hrec_add_key,
284
- [BcfHrec, :string, :size_t],
285
- :int
286
-
287
- # Set a header record value
288
- attach_function \
289
- :bcf_hrec_set_val,
290
- [BcfHrec, :int, :string, :size_t, :int],
291
- :int
292
-
293
- attach_function \
294
- :bcf_hrec_find_key,
295
- [BcfHrec, :string],
296
- :int
297
-
298
- # Add an IDX header record
299
- attach_function \
300
- :hrec_add_idx,
301
- [BcfHrec, :int],
302
- :int
303
-
304
- # Free up a header record and associated structures
305
- attach_function \
306
- :bcf_hrec_destroy,
307
- [:pointer],
308
- :void
309
-
310
- # Individual record querying and manipulation routines
311
-
312
- # See the description of bcf_hdr_subset()
313
- attach_function \
314
- :bcf_subset,
315
- [BcfHdr, Bcf1, :int, :pointer],
316
- :int
317
-
318
- # Translate tags ids to be consistent with different header.
319
- attach_function \
320
- :bcf_translate,
321
- [BcfHdr, BcfHdr, Bcf1],
322
- :int
323
-
324
- # Get variant types in a BCF record
325
- attach_function \
326
- :bcf_get_variant_types,
327
- [Bcf1],
328
- :int
329
-
330
- # Get variant type in a BCF record, for a given allele
331
- attach_function \
332
- :bcf_get_variant_type,
333
- [Bcf1, :int],
334
- :int
335
-
336
- # Check for presence of variant types in a BCF record
337
- attach_function \
338
- :bcf_has_variant_types,
339
- [Bcf1, :uint32, :int],
340
- :int
341
-
342
- # Check for presence of variant types in a BCF record, for a given allele
343
- attach_function \
344
- :bcf_has_variant_type,
345
- [Bcf1, :int, :uint32],
346
- :int
347
-
348
- # Return the number of bases affected by a variant, for a given allele
349
- attach_function \
350
- :bcf_variant_length,
351
- [Bcf1, :int],
352
- :int
353
-
354
- attach_function \
355
- :bcf_is_snp,
356
- [Bcf1],
357
- :int
358
-
359
- # Sets the FILTER column
360
- attach_function \
361
- :bcf_update_filter,
362
- [BcfHdr, Bcf1, :pointer, :int],
363
- :int
364
-
365
- # Adds to the FILTER column
366
- attach_function \
367
- :bcf_add_filter,
368
- [BcfHdr, Bcf1, :int],
369
- :int
370
-
371
- # Removes from the FILTER column
372
- attach_function \
373
- :bcf_remove_filter,
374
- [BcfHdr, Bcf1, :int, :int],
375
- :int
376
-
377
- # Returns 1 if present, 0 if absent, or -1 if filter does not exist.
378
- # "PASS" and "." can be used interchangeably.
379
- attach_function \
380
- :bcf_has_filter,
381
- [BcfHdr, Bcf1, :string],
382
- :int
383
-
384
- # Update REF and ALT column
385
- attach_function \
386
- :bcf_update_alleles,
387
- [BcfHdr, Bcf1, :pointer, :int],
388
- :int
389
-
390
- attach_function \
391
- :bcf_update_alleles_str,
392
- [BcfHdr, Bcf1, :string],
393
- :int
394
-
395
- # Sets new ID string
396
- attach_function \
397
- :bcf_update_id,
398
- [BcfHdr, Bcf1, :string],
399
- :int
400
-
401
- attach_function \
402
- :bcf_add_id,
403
- [BcfHdr, Bcf1, :string],
404
- :int
405
-
406
- # Functions for updating INFO fields
407
- attach_function \
408
- :bcf_update_info,
409
- [BcfHdr, Bcf1, :string, :pointer, :int, :int],
410
- :int
411
-
412
- attach_function \
413
- :bcf_update_format_string,
414
- [BcfHdr, Bcf1, :string, :pointer, :int],
415
- :int
416
-
417
- # Functions for updating FORMAT fields
418
- attach_function \
419
- :bcf_update_format,
420
- [BcfHdr, Bcf1, :string, :pointer, :int, :int],
421
- :int
422
-
423
- # Returns pointer to FORMAT's field data
424
- attach_function \
425
- :bcf_get_fmt,
426
- [BcfHdr, Bcf1, :string],
427
- BcfFmt.by_ref
428
-
429
- attach_function \
430
- :bcf_get_info,
431
- [BcfHdr, Bcf1, :string],
432
- BcfInfo.by_ref
433
-
434
- # Returns pointer to FORMAT/INFO field data given the header index instead of the string ID
435
- attach_function \
436
- :bcf_get_fmt_id,
437
- [Bcf1, :int],
438
- BcfFmt.by_ref
439
-
440
- attach_function \
441
- :bcf_get_info_id,
442
- [Bcf1, :int],
443
- BcfInfo.by_ref
444
-
445
- # get INFO values
446
- attach_function \
447
- :bcf_get_info_values,
448
- [BcfHdr, Bcf1, :string, :pointer, :pointer, :int],
449
- :int
450
-
451
- attach_function \
452
- :bcf_get_format_string,
453
- [BcfHdr, Bcf1, :string, :pointer, :pointer],
454
- :int
455
-
456
- attach_function \
457
- :bcf_get_format_values,
458
- [BcfHdr, Bcf1, :string, :pointer, :pointer, :int],
459
- :int
460
-
461
- # Helper functions
462
-
463
- # Translates string into numeric ID
464
- attach_function \
465
- :bcf_hdr_id2int,
466
- [BcfHdr, :int, :string],
467
- :int
468
-
469
- # Convert BCF FORMAT data to string form
470
- attach_function \
471
- :bcf_fmt_array,
472
- [KString, :int, :int, :pointer],
473
- :int
474
-
475
- attach_function \
476
- :bcf_fmt_sized_array,
477
- [KString, :pointer],
478
- :uint8
479
-
480
- # Encode a variable-length char array in BCF format
481
- attach_function \
482
- :bcf_enc_vchar,
483
- [KString, :int, :string],
484
- :int
485
-
486
- # Encode a variable-length integer array in BCF format
487
- attach_function \
488
- :bcf_enc_vint,
489
- [KString, :int, :pointer, :int],
490
- :int
491
-
492
- # Encode a variable-length float array in BCF format
493
- attach_function \
494
- :bcf_enc_vfloat,
495
- [KString, :int, :pointer],
496
- :int
497
-
498
- # BCF index
499
-
500
- # Load a BCF index from a given index file name
501
- attach_function \
502
- :bcf_index_load2,
503
- %i[string string],
504
- HtsIdx.by_ref
505
-
506
- # Load a BCF index from a given index file name
507
- attach_function \
508
- :bcf_index_load3,
509
- %i[string string int],
510
- HtsIdx.by_ref
511
-
512
- # Generate and save an index file
513
- attach_function \
514
- :bcf_index_build,
515
- %i[string int],
516
- :int
517
-
518
- # Generate and save an index to a specific file
519
- attach_function \
520
- :bcf_index_build2,
521
- %i[string string int],
522
- :int
523
-
524
- # Generate and save an index to a specific file
525
- attach_function \
526
- :bcf_index_build3,
527
- %i[string string int int],
528
- :int
529
-
530
- # Initialise fp->idx for the current format type, for VCF and BCF files.
531
- attach_function \
532
- :bcf_idx_init,
533
- [HtsFile, BcfHdr, :int, :string],
534
- :int
535
-
536
- # Writes the index initialised with bcf_idx_init to disk.
537
- attach_function \
538
- :bcf_idx_save,
539
- [HtsFile],
540
- :int
541
-
542
- attach_variable \
543
- :bcf_float_vector_end,
544
- :uint32
545
-
546
- attach_variable \
547
- :bcf_float_missing,
548
- :uint32
549
-
550
- attach_function \
551
- :bcf_format_gt_v2,
552
- [BcfHdr, BcfFmt, :int, KString],
553
- :int
554
- end
555
- end
556
-
557
- require_relative "vcf_funcs"