htslib 0.0.5 → 0.0.10

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.
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "sam_funcs"
4
+
3
5
  module HTS
4
6
  module LibHTS
5
7
  # constants
@@ -96,595 +98,5 @@ module HTS
96
98
 
97
99
  # def bam_set_seqi(s, i, b)
98
100
  end
99
-
100
- # Generates a new unpopulated header structure.
101
- attach_function \
102
- :sam_hdr_init,
103
- [],
104
- SamHdr.by_ref
105
-
106
- # Read the header from a BAM compressed file.
107
- attach_function \
108
- :bam_hdr_read,
109
- [BGZF],
110
- SamHdr.by_ref
111
-
112
- # Writes the header to a BAM file.
113
- attach_function \
114
- :bam_hdr_write,
115
- [BGZF, SamHdr],
116
- :int
117
-
118
- # Frees the resources associated with a header.
119
- attach_function \
120
- :sam_hdr_destroy,
121
- [SamHdr],
122
- :void
123
-
124
- # Duplicate a header structure.
125
- attach_function \
126
- :sam_hdr_dup,
127
- [SamHdr],
128
- SamHdr.by_ref
129
-
130
- # Create a header from existing text.
131
- attach_function \
132
- :sam_hdr_parse,
133
- %i[size_t string],
134
- SamHdr.by_ref
135
-
136
- # Read a header from a SAM, BAM or CRAM file.
137
- attach_function \
138
- :sam_hdr_read,
139
- [SamFile],
140
- SamHdr.by_ref
141
-
142
- # Write a header to a SAM, BAM or CRAM file.
143
- attach_function \
144
- :sam_hdr_write,
145
- [SamFile, SamHdr],
146
- :int
147
-
148
- # Returns the current length of the header text.
149
- attach_function \
150
- :sam_hdr_length,
151
- [SamHdr],
152
- :size_t
153
-
154
- # Returns the text representation of the header.
155
- attach_function \
156
- :sam_hdr_str,
157
- [SamHdr],
158
- :string
159
-
160
- # Returns the number of references in the header.
161
- attach_function \
162
- :sam_hdr_nref,
163
- [SamHdr],
164
- :int
165
-
166
- # Add formatted lines to an existing header.
167
- attach_function \
168
- :sam_hdr_add_lines,
169
- [SamHdr, :string, :size_t],
170
- :int
171
-
172
- # Adds a single line to an existing header.
173
- attach_function \
174
- :sam_hdr_add_line,
175
- [SamHdr, :string, :varargs],
176
- :int
177
-
178
- # Returns a complete line of formatted text for a given type and ID.
179
- attach_function \
180
- :sam_hdr_find_line_id,
181
- [SamHdr, :string, :string, :string, KString],
182
- :int
183
-
184
- # Returns a complete line of formatted text for a given type and index.
185
- attach_function \
186
- :sam_hdr_find_line_pos,
187
- [SamHdr, :string, :int, KString],
188
- :int
189
-
190
- # Remove a line with given type / id from a header
191
- attach_function \
192
- :sam_hdr_remove_line_id,
193
- [SamHdr, :string, :string, :string],
194
- :int
195
-
196
- # Remove nth line of a given type from a header
197
- attach_function \
198
- :sam_hdr_remove_line_pos,
199
- [SamHdr, :string, :int],
200
- :int
201
-
202
- # Add or update tag key,value pairs in a header line.
203
- attach_function \
204
- :sam_hdr_update_line,
205
- [SamHdr, :string, :string, :string, :varargs],
206
- :int
207
-
208
- # Remove all lines of a given type from a header, except the one matching an ID
209
- attach_function \
210
- :sam_hdr_remove_except,
211
- [SamHdr, :string, :string, :string],
212
- :int
213
-
214
- # Remove header lines of a given type, except those in a given ID set
215
- attach_function \
216
- :sam_hdr_remove_lines,
217
- [SamHdr, :string, :string, :pointer],
218
- :int
219
-
220
- # Count the number of lines for a given header type
221
- attach_function \
222
- :sam_hdr_count_lines,
223
- [SamHdr, :string],
224
- :int
225
-
226
- # Index of the line for the types that have dedicated look-up tables (SQ, RG, PG)
227
- attach_function \
228
- :sam_hdr_line_index,
229
- [SamHdr, :string, :string],
230
- :int
231
-
232
- # Id key of the line for the types that have dedicated look-up tables (SQ, RG, PG)
233
- attach_function \
234
- :sam_hdr_line_name,
235
- [SamHdr, :string, :int],
236
- :string
237
-
238
- # Return the value associated with a key for a header line identified by ID_key:ID_val
239
- attach_function \
240
- :sam_hdr_find_tag_id,
241
- [SamHdr, :string, :string, :string, :string, KString],
242
- :int
243
-
244
- # Return the value associated with a key for a header line identified by position
245
- attach_function \
246
- :sam_hdr_find_tag_pos,
247
- [SamHdr, :string, :int, :string, KString],
248
- :int
249
-
250
- # Remove the key from the line identified by type, ID_key and ID_value.
251
- attach_function \
252
- :sam_hdr_remove_tag_id,
253
- [SamHdr, :string, :string, :string, :string],
254
- :int
255
-
256
- # Get the target id for a given reference sequence name
257
- attach_function \
258
- :sam_hdr_name2tid,
259
- [SamHdr, :string],
260
- :int
261
-
262
- # Get the reference sequence name from a target index
263
- attach_function \
264
- :sam_hdr_tid2name,
265
- [SamHdr, :int],
266
- :string
267
-
268
- # Get the reference sequence length from a target index
269
- attach_function \
270
- :sam_hdr_tid2len,
271
- [SamHdr, :int],
272
- :hts_pos_t
273
-
274
- # Generate a unique \@PG ID: value
275
- attach_function \
276
- :sam_hdr_pg_id,
277
- [SamHdr, :string],
278
- :string
279
-
280
- # Add an \@PG line.
281
- attach_function \
282
- :sam_hdr_add_pg,
283
- [SamHdr, :string, :varargs],
284
- :int
285
-
286
- # A function to help with construction of CL tags in @PG records.
287
- attach_function \
288
- :stringify_argv,
289
- %i[int pointer],
290
- :string
291
-
292
- # Increments the reference count on a header
293
- attach_function \
294
- :sam_hdr_incr_ref,
295
- [SamHdr],
296
- :void
297
-
298
- # Create a new bam1_t alignment structure
299
- attach_function \
300
- :bam_init1,
301
- [],
302
- Bam1.by_ref
303
-
304
- # Destroy a bam1_t structure
305
- attach_function \
306
- :bam_destroy1,
307
- [Bam1],
308
- :void
309
-
310
- # Read a BAM format alignment record
311
- attach_function \
312
- :bam_read1,
313
- [BGZF, Bam1],
314
- :int
315
-
316
- # Write a BAM format alignment record
317
- attach_function \
318
- :bam_write1,
319
- [BGZF, Bam1],
320
- :int
321
-
322
- # Copy alignment record data
323
- attach_function \
324
- :bam_copy1,
325
- [Bam1, Bam1],
326
- Bam1.by_ref
327
-
328
- # Create a duplicate alignment record
329
- attach_function \
330
- :bam_dup1,
331
- [Bam1],
332
- Bam1.by_ref
333
-
334
- # Calculate query length from CIGAR data
335
- attach_function \
336
- :bam_cigar2qlen,
337
- %i[int pointer],
338
- :int64
339
-
340
- # Calculate reference length from CIGAR data
341
- attach_function \
342
- :bam_cigar2rlen,
343
- %i[int pointer],
344
- :hts_pos_t
345
-
346
- # Calculate the rightmost base position of an alignment on the reference genome.
347
- attach_function \
348
- :bam_endpos,
349
- [Bam1],
350
- :hts_pos_t
351
-
352
- attach_function \
353
- :bam_str2flag,
354
- [:string],
355
- :int
356
-
357
- attach_function \
358
- :bam_flag2str,
359
- [:int],
360
- :string
361
-
362
- # Set the name of the query
363
- attach_function \
364
- :bam_set_qname,
365
- [Bam1, :string],
366
- :int
367
-
368
- # Initialise fp->idx for the current format type for SAM, BAM and CRAM types .
369
- attach_function \
370
- :sam_idx_init,
371
- [HtsFile, SamHdr, :int, :string],
372
- :int
373
-
374
- # Writes the index initialised with sam_idx_init to disk.
375
- attach_function \
376
- :sam_idx_save,
377
- [HtsFile],
378
- :int
379
-
380
- # Load a BAM (.csi or .bai) or CRAM (.crai) index file
381
- attach_function \
382
- :sam_index_load,
383
- [HtsFile, :string],
384
- HtsIdx.by_ref
385
-
386
- # Load a specific BAM (.csi or .bai) or CRAM (.crai) index file
387
- attach_function \
388
- :sam_index_load2,
389
- [HtsFile, :string, :string],
390
- HtsIdx.by_ref
391
-
392
- # Load or stream a BAM (.csi or .bai) or CRAM (.crai) index file
393
- attach_function \
394
- :sam_index_load3,
395
- [HtsFile, :string, :string, :int],
396
- HtsIdx.by_ref
397
-
398
- # Generate and save an index file
399
- attach_function \
400
- :sam_index_build,
401
- %i[string int],
402
- :int
403
-
404
- # Generate and save an index to a specific file
405
- attach_function \
406
- :sam_index_build2,
407
- %i[string string int],
408
- :int
409
-
410
- # Generate and save an index to a specific file
411
- attach_function \
412
- :sam_index_build3,
413
- %i[string string int int],
414
- :int
415
-
416
- # Create a BAM/CRAM iterator
417
- attach_function \
418
- :sam_itr_queryi,
419
- [HtsIdx, :int, :hts_pos_t, :hts_pos_t],
420
- HtsItr.by_ref
421
-
422
- # Create a SAM/BAM/CRAM iterator
423
- attach_function \
424
- :sam_itr_querys,
425
- [HtsIdx, SamHdr, :string],
426
- HtsItr.by_ref
427
-
428
- # Create a multi-region iterator
429
- attach_function \
430
- :sam_itr_regions,
431
- [HtsIdx, SamHdr, :pointer, :uint],
432
- HtsItr.by_ref
433
-
434
- # Create a multi-region iterator
435
- attach_function \
436
- :sam_itr_regarray,
437
- [HtsIdx, SamHdr, :pointer, :uint],
438
- HtsItr.by_ref
439
-
440
- # Get the next read from a SAM/BAM/CRAM iterator
441
- def self.sam_itr_next(htsfp, itr, r)
442
- # FIXME: check if htsfp is compressed BGZF
443
- hts_log_error("Null iterator") if itr.null?
444
- # FIXME: check multi
445
- hts_itr_next(htsfp[:fp][:bgzf], itr, r, htsfp)
446
- end
447
-
448
- attach_function \
449
- :sam_parse_region,
450
- [SamHdr, :string, :pointer, :pointer, :pointer, :int],
451
- :string
452
-
453
- # SAM I/O
454
-
455
- # macros (or alias)
456
- # sam_open
457
- # sam_open_format
458
- # sam_close
459
-
460
- attach_function \
461
- :sam_open_mode,
462
- %i[string string string],
463
- :int
464
-
465
- # A version of sam_open_mode that can handle ,key=value options.
466
- attach_function \
467
- :sam_open_mode_opts,
468
- %i[string string string],
469
- :string
470
-
471
- attach_function \
472
- :sam_hdr_change_HD,
473
- [SamHdr, :string, :string],
474
- :int
475
-
476
- attach_function \
477
- :sam_parse1,
478
- [KString, SamHdr, Bam1],
479
- :int
480
-
481
- attach_function \
482
- :sam_format1,
483
- [SamHdr, Bam1, KString],
484
- :int
485
-
486
- # Read a record from a file
487
- attach_function \
488
- :sam_read1,
489
- [HtsFile, SamHdr, Bam1],
490
- :int
491
-
492
- # Write a record to a file
493
- attach_function \
494
- :sam_write1,
495
- [HtsFile, SamHdr, Bam1],
496
- :int
497
-
498
- # Return a pointer to an aux record
499
- attach_function \
500
- :bam_aux_get,
501
- [Bam1, :string], # FIXME
502
- :pointer
503
-
504
- # Get an integer aux value
505
- attach_function \
506
- :bam_aux2i,
507
- [:pointer],
508
- :int64
509
-
510
- # Get an integer aux value
511
- attach_function \
512
- :bam_aux2f,
513
- [:pointer],
514
- :double
515
-
516
- # Get a character aux value
517
- attach_function \
518
- :bam_aux2A,
519
- [:pointer],
520
- :string
521
-
522
- # Get a string aux value
523
- attach_function \
524
- :bam_aux2Z,
525
- [:pointer],
526
- :string
527
-
528
- # Get the length of an array-type ('B') tag
529
- attach_function \
530
- :bam_auxB_len,
531
- [:pointer],
532
- :uint
533
-
534
- # Get an integer value from an array-type tag
535
- attach_function \
536
- :bam_auxB2i,
537
- %i[pointer uint],
538
- :int64
539
-
540
- # Get a floating-point value from an array-type tag
541
- attach_function \
542
- :bam_auxB2f,
543
- %i[pointer uint],
544
- :double
545
-
546
- # Append tag data to a bam record
547
- attach_function \
548
- :bam_aux_append,
549
- [Bam1, :string, :string, :int, :pointer],
550
- :int
551
-
552
- # Delete tag data from a bam record
553
- attach_function \
554
- :bam_aux_del,
555
- [Bam1, :pointer],
556
- :int
557
-
558
- # Update or add a string-type tag
559
- attach_function \
560
- :bam_aux_update_str,
561
- [Bam1, :string, :int, :string],
562
- :int
563
-
564
- # Update or add an integer tag
565
- attach_function \
566
- :bam_aux_update_int,
567
- [Bam1, :string, :int64],
568
- :int
569
-
570
- # Update or add a floating-point tag
571
- attach_function \
572
- :bam_aux_update_float,
573
- [Bam1, :string, :float],
574
- :int
575
-
576
- # Update or add an array tag
577
- attach_function \
578
- :bam_aux_update_array,
579
- [Bam1, :string, :uint8, :uint32, :pointer],
580
- :int
581
-
582
- # sets an iterator over multiple
583
- attach_function \
584
- :bam_plp_init,
585
- %i[bam_plp_auto_f pointer],
586
- :bam_plp
587
-
588
- attach_function \
589
- :bam_plp_destroy,
590
- [:bam_plp],
591
- :void
592
-
593
- attach_function \
594
- :bam_plp_push,
595
- [:bam_plp, Bam1],
596
- :int
597
-
598
- attach_function \
599
- :bam_plp_next,
600
- %i[bam_plp pointer pointer pointer],
601
- BamPileup1.by_ref
602
-
603
- attach_function \
604
- :bam_plp_auto,
605
- %i[bam_plp pointer pointer pointer],
606
- BamPileup1.by_ref
607
-
608
- attach_function \
609
- :bam_plp64_next,
610
- %i[bam_plp pointer pointer pointer],
611
- BamPileup1.by_ref
612
-
613
- attach_function \
614
- :bam_plp64_auto,
615
- %i[bam_plp pointer pointer pointer],
616
- BamPileup1.by_ref
617
-
618
- attach_function \
619
- :bam_plp_set_maxcnt,
620
- %i[bam_plp int],
621
- :void
622
-
623
- attach_function \
624
- :bam_plp_reset,
625
- [:bam_plp],
626
- :void
627
-
628
- # sets a callback to initialise any per-pileup1_t fields.
629
- attach_function \
630
- :bam_plp_insertion,
631
- [BamPileup1, KString, :pointer],
632
- :int
633
-
634
- # sets a callback to initialise any per-pileup1_t fields.
635
- # bam_plp_constructor
636
-
637
- # bam_plp_destructor
638
-
639
- # Get pileup padded insertion sequence
640
- # bam_plp_insertion
641
-
642
- attach_function \
643
- :bam_mplp_init,
644
- %i[int bam_plp_auto_f pointer],
645
- :bam_mplp
646
-
647
- attach_function \
648
- :bam_mplp_init_overlaps,
649
- [:bam_mplp],
650
- :int
651
-
652
- attach_function \
653
- :bam_mplp_destroy,
654
- [:bam_mplp],
655
- :void
656
-
657
- attach_function \
658
- :bam_mplp_set_maxcnt,
659
- %i[bam_mplp int],
660
- :void
661
-
662
- attach_function \
663
- :bam_mplp_auto,
664
- %i[bam_mplp pointer pointer pointer pointer], # BamPileup1T
665
- :int
666
-
667
- attach_function \
668
- :bam_mplp64_auto,
669
- %i[bam_mplp pointer pointer pointer pointer], # BamPileup1T
670
- :int
671
-
672
- attach_function \
673
- :bam_mplp_reset,
674
- [:bam_mplp],
675
- :void
676
-
677
- # bam_mplp_constructor
678
- # bam_mplp_destructor
679
-
680
- attach_function \
681
- :sam_cap_mapq,
682
- [Bam1, :string, :hts_pos_t, :int],
683
- :int
684
-
685
- attach_function \
686
- :sam_prob_realn,
687
- [Bam1, :string, :hts_pos_t, :int],
688
- :int
689
101
  end
690
102
  end