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.
- checksums.yaml +4 -4
- data/README.md +79 -49
- data/TUTORIAL.md +9 -20
- data/ext/htslib_native/extconf.rb +41 -0
- data/ext/htslib_native/htslib_native.h +11 -0
- data/ext/htslib_native/htslib_native_ext.c +48 -0
- data/ext/htslib_native/native_bam.c +1108 -0
- data/ext/htslib_native/native_bcf.c +369 -0
- data/ext/htslib_native/native_faidx.c +155 -0
- data/ext/htslib_native/native_tabix.c +246 -0
- data/lib/hts/bam/auxi.rb +87 -342
- data/lib/hts/bam/base_mod.rb +37 -73
- data/lib/hts/bam/cigar.rb +9 -55
- data/lib/hts/bam/flag.rb +19 -27
- data/lib/hts/bam/header.rb +29 -56
- data/lib/hts/bam/mpileup.rb +158 -132
- data/lib/hts/bam/pileup.rb +120 -145
- data/lib/hts/bam/record.rb +233 -270
- data/lib/hts/bam.rb +102 -42
- data/lib/hts/bcf/errors.rb +1 -0
- data/lib/hts/bcf/format.rb +278 -379
- data/lib/hts/bcf/header.rb +38 -123
- data/lib/hts/bcf/header_record.rb +9 -35
- data/lib/hts/bcf/info.rb +72 -320
- data/lib/hts/bcf/record.rb +61 -102
- data/lib/hts/bcf.rb +149 -323
- data/lib/hts/faidx.rb +28 -87
- data/lib/hts/hts.rb +6 -94
- data/lib/hts/native.rb +13 -0
- data/lib/hts/tabix.rb +93 -48
- data/lib/hts/version.rb +1 -1
- data/lib/htslib.rb +6 -52
- metadata +13 -64
- data/lib/hts/ffi_ext/README.md +0 -8
- data/lib/hts/ffi_ext/pointer.rb +0 -18
- data/lib/hts/ffi_ext/struct.rb +0 -45
- data/lib/hts/libhts/bgzf.rb +0 -199
- data/lib/hts/libhts/constants.rb +0 -658
- data/lib/hts/libhts/cram.rb +0 -471
- data/lib/hts/libhts/fai.rb +0 -146
- data/lib/hts/libhts/hfile.rb +0 -109
- data/lib/hts/libhts/hts.rb +0 -477
- data/lib/hts/libhts/kfunc.rb +0 -38
- data/lib/hts/libhts/sam.rb +0 -760
- data/lib/hts/libhts/sam_funcs.rb +0 -155
- data/lib/hts/libhts/tbx.rb +0 -79
- data/lib/hts/libhts/tbx_funcs.rb +0 -32
- data/lib/hts/libhts/thread_pool.rb +0 -139
- data/lib/hts/libhts/vcf.rb +0 -557
- data/lib/hts/libhts/vcf_funcs.rb +0 -353
- data/lib/hts/libhts.rb +0 -47
data/lib/hts/libhts/sam.rb
DELETED
|
@@ -1,760 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module HTS
|
|
4
|
-
module LibHTS
|
|
5
|
-
# Callback type for bam_plp_auto_f: int (*)(void *data, bam1_t *b)
|
|
6
|
-
# Use raw pointer for bam1_t to avoid creating ManagedStruct wrappers (which would double-free)
|
|
7
|
-
callback :bam_plp_auto_f, %i[pointer pointer], :int
|
|
8
|
-
# callback :bam_plp_auto_f, [:pointer, Bam1.by_ref], :int
|
|
9
|
-
|
|
10
|
-
# Generates a new unpopulated header structure.
|
|
11
|
-
attach_function \
|
|
12
|
-
:sam_hdr_init,
|
|
13
|
-
[],
|
|
14
|
-
SamHdr.by_ref
|
|
15
|
-
|
|
16
|
-
# Read the header from a BAM compressed file.
|
|
17
|
-
attach_function \
|
|
18
|
-
:bam_hdr_read,
|
|
19
|
-
[BGZF],
|
|
20
|
-
SamHdr.by_ref
|
|
21
|
-
|
|
22
|
-
# Writes the header to a BAM file.
|
|
23
|
-
attach_function \
|
|
24
|
-
:bam_hdr_write,
|
|
25
|
-
[BGZF, SamHdr],
|
|
26
|
-
:int
|
|
27
|
-
|
|
28
|
-
# Frees the resources associated with a header.
|
|
29
|
-
attach_function \
|
|
30
|
-
:sam_hdr_destroy,
|
|
31
|
-
[SamHdr],
|
|
32
|
-
:void
|
|
33
|
-
|
|
34
|
-
# Duplicate a header structure.
|
|
35
|
-
attach_function \
|
|
36
|
-
:sam_hdr_dup,
|
|
37
|
-
[SamHdr],
|
|
38
|
-
SamHdr.by_ref
|
|
39
|
-
|
|
40
|
-
# Create a header from existing text.
|
|
41
|
-
attach_function \
|
|
42
|
-
:sam_hdr_parse,
|
|
43
|
-
%i[size_t string],
|
|
44
|
-
SamHdr.by_ref
|
|
45
|
-
|
|
46
|
-
# Read a header from a SAM, BAM or CRAM file.
|
|
47
|
-
attach_function \
|
|
48
|
-
:sam_hdr_read,
|
|
49
|
-
[SamFile],
|
|
50
|
-
SamHdr.by_ref
|
|
51
|
-
|
|
52
|
-
# Write a header to a SAM, BAM or CRAM file.
|
|
53
|
-
attach_function \
|
|
54
|
-
:sam_hdr_write,
|
|
55
|
-
[SamFile, SamHdr],
|
|
56
|
-
:int
|
|
57
|
-
|
|
58
|
-
# Returns the current length of the header text.
|
|
59
|
-
attach_function \
|
|
60
|
-
:sam_hdr_length,
|
|
61
|
-
[SamHdr],
|
|
62
|
-
:size_t
|
|
63
|
-
|
|
64
|
-
# Returns the text representation of the header.
|
|
65
|
-
attach_function \
|
|
66
|
-
:sam_hdr_str,
|
|
67
|
-
[SamHdr],
|
|
68
|
-
:string
|
|
69
|
-
|
|
70
|
-
# Returns the number of references in the header.
|
|
71
|
-
attach_function \
|
|
72
|
-
:sam_hdr_nref,
|
|
73
|
-
[SamHdr],
|
|
74
|
-
:int
|
|
75
|
-
|
|
76
|
-
# Add formatted lines to an existing header.
|
|
77
|
-
attach_function \
|
|
78
|
-
:sam_hdr_add_lines,
|
|
79
|
-
[SamHdr, :string, :size_t],
|
|
80
|
-
:int
|
|
81
|
-
|
|
82
|
-
# Adds a single line to an existing header.
|
|
83
|
-
attach_function \
|
|
84
|
-
:sam_hdr_add_line,
|
|
85
|
-
[SamHdr, :string, :varargs],
|
|
86
|
-
:int
|
|
87
|
-
|
|
88
|
-
# Returns a complete line of formatted text for a given type and ID.
|
|
89
|
-
attach_function \
|
|
90
|
-
:sam_hdr_find_line_id,
|
|
91
|
-
[SamHdr, :string, :string, :string, KString],
|
|
92
|
-
:int
|
|
93
|
-
|
|
94
|
-
# Returns a complete line of formatted text for a given type and index.
|
|
95
|
-
attach_function \
|
|
96
|
-
:sam_hdr_find_line_pos,
|
|
97
|
-
[SamHdr, :string, :int, KString],
|
|
98
|
-
:int
|
|
99
|
-
|
|
100
|
-
# Remove a line with given type / id from a header
|
|
101
|
-
attach_function \
|
|
102
|
-
:sam_hdr_remove_line_id,
|
|
103
|
-
[SamHdr, :string, :string, :string],
|
|
104
|
-
:int
|
|
105
|
-
|
|
106
|
-
# Remove nth line of a given type from a header
|
|
107
|
-
attach_function \
|
|
108
|
-
:sam_hdr_remove_line_pos,
|
|
109
|
-
[SamHdr, :string, :int],
|
|
110
|
-
:int
|
|
111
|
-
|
|
112
|
-
# Add or update tag key,value pairs in a header line.
|
|
113
|
-
attach_function \
|
|
114
|
-
:sam_hdr_update_line,
|
|
115
|
-
[SamHdr, :string, :string, :string, :varargs],
|
|
116
|
-
:int
|
|
117
|
-
|
|
118
|
-
# Remove all lines of a given type from a header, except the one matching an ID
|
|
119
|
-
attach_function \
|
|
120
|
-
:sam_hdr_remove_except,
|
|
121
|
-
[SamHdr, :string, :string, :string],
|
|
122
|
-
:int
|
|
123
|
-
|
|
124
|
-
# Remove header lines of a given type, except those in a given ID set
|
|
125
|
-
attach_function \
|
|
126
|
-
:sam_hdr_remove_lines,
|
|
127
|
-
[SamHdr, :string, :string, :pointer],
|
|
128
|
-
:int
|
|
129
|
-
|
|
130
|
-
# Count the number of lines for a given header type
|
|
131
|
-
attach_function \
|
|
132
|
-
:sam_hdr_count_lines,
|
|
133
|
-
[SamHdr, :string],
|
|
134
|
-
:int
|
|
135
|
-
|
|
136
|
-
# Index of the line for the types that have dedicated look-up tables (SQ, RG, PG)
|
|
137
|
-
attach_function \
|
|
138
|
-
:sam_hdr_line_index,
|
|
139
|
-
[SamHdr, :string, :string],
|
|
140
|
-
:int
|
|
141
|
-
|
|
142
|
-
# Id key of the line for the types that have dedicated look-up tables (SQ, RG, PG)
|
|
143
|
-
attach_function \
|
|
144
|
-
:sam_hdr_line_name,
|
|
145
|
-
[SamHdr, :string, :int],
|
|
146
|
-
:string
|
|
147
|
-
|
|
148
|
-
# Return the value associated with a key for a header line identified by ID_key:ID_val
|
|
149
|
-
attach_function \
|
|
150
|
-
:sam_hdr_find_tag_id,
|
|
151
|
-
[SamHdr, :string, :string, :string, :string, KString],
|
|
152
|
-
:int
|
|
153
|
-
|
|
154
|
-
# Return the value associated with a key for a header line identified by position
|
|
155
|
-
attach_function \
|
|
156
|
-
:sam_hdr_find_tag_pos,
|
|
157
|
-
[SamHdr, :string, :int, :string, KString],
|
|
158
|
-
:int
|
|
159
|
-
|
|
160
|
-
# Remove the key from the line identified by type, ID_key and ID_value.
|
|
161
|
-
attach_function \
|
|
162
|
-
:sam_hdr_remove_tag_id,
|
|
163
|
-
[SamHdr, :string, :string, :string, :string],
|
|
164
|
-
:int
|
|
165
|
-
|
|
166
|
-
# Get the target id for a given reference sequence name
|
|
167
|
-
attach_function \
|
|
168
|
-
:sam_hdr_name2tid,
|
|
169
|
-
[SamHdr, :string],
|
|
170
|
-
:int
|
|
171
|
-
|
|
172
|
-
# Get the reference sequence name from a target index
|
|
173
|
-
attach_function \
|
|
174
|
-
:sam_hdr_tid2name,
|
|
175
|
-
[SamHdr, :int],
|
|
176
|
-
:string
|
|
177
|
-
|
|
178
|
-
# Get the reference sequence length from a target index
|
|
179
|
-
attach_function \
|
|
180
|
-
:sam_hdr_tid2len,
|
|
181
|
-
[SamHdr, :int],
|
|
182
|
-
:hts_pos_t
|
|
183
|
-
|
|
184
|
-
# Generate a unique \@PG ID: value
|
|
185
|
-
attach_function \
|
|
186
|
-
:sam_hdr_pg_id,
|
|
187
|
-
[SamHdr, :string],
|
|
188
|
-
:string
|
|
189
|
-
|
|
190
|
-
# Add an \@PG line.
|
|
191
|
-
attach_function \
|
|
192
|
-
:sam_hdr_add_pg,
|
|
193
|
-
[SamHdr, :string, :varargs],
|
|
194
|
-
:int
|
|
195
|
-
|
|
196
|
-
# A function to help with construction of CL tags in @PG records.
|
|
197
|
-
attach_function \
|
|
198
|
-
:stringify_argv,
|
|
199
|
-
%i[int pointer],
|
|
200
|
-
:string
|
|
201
|
-
|
|
202
|
-
# Increments the reference count on a header
|
|
203
|
-
attach_function \
|
|
204
|
-
:sam_hdr_incr_ref,
|
|
205
|
-
[SamHdr],
|
|
206
|
-
:void
|
|
207
|
-
|
|
208
|
-
# Create a new bam1_t alignment structure
|
|
209
|
-
attach_function \
|
|
210
|
-
:bam_init1,
|
|
211
|
-
[],
|
|
212
|
-
Bam1.by_ref
|
|
213
|
-
|
|
214
|
-
# Destroy a bam1_t structure
|
|
215
|
-
attach_function \
|
|
216
|
-
:bam_destroy1,
|
|
217
|
-
[Bam1],
|
|
218
|
-
:void
|
|
219
|
-
|
|
220
|
-
# Read a BAM format alignment record
|
|
221
|
-
attach_function \
|
|
222
|
-
:bam_read1,
|
|
223
|
-
[BGZF, Bam1],
|
|
224
|
-
:int
|
|
225
|
-
|
|
226
|
-
# Write a BAM format alignment record
|
|
227
|
-
attach_function \
|
|
228
|
-
:bam_write1,
|
|
229
|
-
[BGZF, Bam1],
|
|
230
|
-
:int
|
|
231
|
-
|
|
232
|
-
# Copy alignment record data
|
|
233
|
-
attach_function \
|
|
234
|
-
:bam_copy1,
|
|
235
|
-
[Bam1, Bam1],
|
|
236
|
-
Bam1.by_ref
|
|
237
|
-
|
|
238
|
-
# Create a duplicate alignment record
|
|
239
|
-
attach_function \
|
|
240
|
-
:bam_dup1,
|
|
241
|
-
[Bam1],
|
|
242
|
-
Bam1.by_ref
|
|
243
|
-
|
|
244
|
-
# Set all components of an alignment structure
|
|
245
|
-
attach_function \
|
|
246
|
-
:bam_set1,
|
|
247
|
-
[Bam1,
|
|
248
|
-
:size_t,
|
|
249
|
-
:string,
|
|
250
|
-
:uint16,
|
|
251
|
-
:int32,
|
|
252
|
-
:hts_pos_t,
|
|
253
|
-
:uint8,
|
|
254
|
-
:size_t,
|
|
255
|
-
:pointer,
|
|
256
|
-
:int32,
|
|
257
|
-
:hts_pos_t,
|
|
258
|
-
:hts_pos_t,
|
|
259
|
-
:size_t,
|
|
260
|
-
:string,
|
|
261
|
-
:string,
|
|
262
|
-
:size_t],
|
|
263
|
-
:int
|
|
264
|
-
|
|
265
|
-
# Calculate query length from CIGAR data
|
|
266
|
-
attach_function \
|
|
267
|
-
:bam_cigar2qlen,
|
|
268
|
-
%i[int pointer],
|
|
269
|
-
:int64
|
|
270
|
-
|
|
271
|
-
# Calculate reference length from CIGAR data
|
|
272
|
-
attach_function \
|
|
273
|
-
:bam_cigar2rlen,
|
|
274
|
-
%i[int pointer],
|
|
275
|
-
:hts_pos_t
|
|
276
|
-
|
|
277
|
-
# Calculate the rightmost base position of an alignment on the reference genome.
|
|
278
|
-
attach_function \
|
|
279
|
-
:bam_endpos,
|
|
280
|
-
[Bam1],
|
|
281
|
-
:hts_pos_t
|
|
282
|
-
|
|
283
|
-
attach_function \
|
|
284
|
-
:bam_str2flag,
|
|
285
|
-
[:string],
|
|
286
|
-
:int
|
|
287
|
-
|
|
288
|
-
attach_function \
|
|
289
|
-
:bam_flag2str,
|
|
290
|
-
[:int],
|
|
291
|
-
:string
|
|
292
|
-
|
|
293
|
-
# Set the name of the query
|
|
294
|
-
attach_function \
|
|
295
|
-
:bam_set_qname,
|
|
296
|
-
[Bam1, :string],
|
|
297
|
-
:int
|
|
298
|
-
|
|
299
|
-
# Parse a CIGAR string into a uint32_t array
|
|
300
|
-
attach_function \
|
|
301
|
-
:sam_parse_cigar,
|
|
302
|
-
%i[string pointer pointer pointer],
|
|
303
|
-
:ssize_t
|
|
304
|
-
|
|
305
|
-
# Parse a CIGAR string into a bam1_t struct
|
|
306
|
-
attach_function \
|
|
307
|
-
:bam_parse_cigar,
|
|
308
|
-
[:string, :pointer, Bam1],
|
|
309
|
-
:ssize_t
|
|
310
|
-
|
|
311
|
-
# Initialise fp->idx for the current format type for SAM, BAM and CRAM types .
|
|
312
|
-
attach_function \
|
|
313
|
-
:sam_idx_init,
|
|
314
|
-
[HtsFile, SamHdr, :int, :string],
|
|
315
|
-
:int
|
|
316
|
-
|
|
317
|
-
# Writes the index initialised with sam_idx_init to disk.
|
|
318
|
-
attach_function \
|
|
319
|
-
:sam_idx_save,
|
|
320
|
-
[HtsFile],
|
|
321
|
-
:int
|
|
322
|
-
|
|
323
|
-
# Load a BAM (.csi or .bai) or CRAM (.crai) index file
|
|
324
|
-
attach_function \
|
|
325
|
-
:sam_index_load,
|
|
326
|
-
[HtsFile, :string],
|
|
327
|
-
HtsIdx.by_ref
|
|
328
|
-
|
|
329
|
-
# Load a specific BAM (.csi or .bai) or CRAM (.crai) index file
|
|
330
|
-
attach_function \
|
|
331
|
-
:sam_index_load2,
|
|
332
|
-
[HtsFile, :string, :string],
|
|
333
|
-
HtsIdx.by_ref
|
|
334
|
-
|
|
335
|
-
# Load or stream a BAM (.csi or .bai) or CRAM (.crai) index file
|
|
336
|
-
attach_function \
|
|
337
|
-
:sam_index_load3,
|
|
338
|
-
[HtsFile, :string, :string, :int],
|
|
339
|
-
HtsIdx.by_ref
|
|
340
|
-
|
|
341
|
-
# Generate and save an index file
|
|
342
|
-
attach_function \
|
|
343
|
-
:sam_index_build,
|
|
344
|
-
%i[string int],
|
|
345
|
-
:int
|
|
346
|
-
|
|
347
|
-
# Generate and save an index to a specific file
|
|
348
|
-
attach_function \
|
|
349
|
-
:sam_index_build2,
|
|
350
|
-
%i[string string int],
|
|
351
|
-
:int
|
|
352
|
-
|
|
353
|
-
# Generate and save an index to a specific file
|
|
354
|
-
attach_function \
|
|
355
|
-
:sam_index_build3,
|
|
356
|
-
%i[string string int int],
|
|
357
|
-
:int
|
|
358
|
-
|
|
359
|
-
# Create a BAM/CRAM iterator
|
|
360
|
-
attach_function \
|
|
361
|
-
:sam_itr_queryi,
|
|
362
|
-
[HtsIdx, :int, :hts_pos_t, :hts_pos_t],
|
|
363
|
-
HtsItr.by_ref
|
|
364
|
-
|
|
365
|
-
# Create a SAM/BAM/CRAM iterator
|
|
366
|
-
attach_function \
|
|
367
|
-
:sam_itr_querys,
|
|
368
|
-
[HtsIdx, SamHdr, :string],
|
|
369
|
-
HtsItr.by_ref
|
|
370
|
-
|
|
371
|
-
# Create a multi-region iterator
|
|
372
|
-
attach_function \
|
|
373
|
-
:sam_itr_regions,
|
|
374
|
-
[HtsIdx, SamHdr, HtsReglist, :uint],
|
|
375
|
-
HtsItr.by_ref
|
|
376
|
-
|
|
377
|
-
# Create a multi-region iterator
|
|
378
|
-
attach_function \
|
|
379
|
-
:sam_itr_regarray,
|
|
380
|
-
[HtsIdx, SamHdr, :pointer, :uint],
|
|
381
|
-
HtsItr.by_ref
|
|
382
|
-
|
|
383
|
-
# Get the next read from a SAM/BAM/CRAM iterator
|
|
384
|
-
def self.sam_itr_next(htsfp, itr, r)
|
|
385
|
-
raise("#{htsfp[:fn] || 'File'} not BGZF compressed") unless htsfp[:is_bgzf] == 1 || htsfp[:is_cram] == 1
|
|
386
|
-
raise("Null iterator") if itr.null?
|
|
387
|
-
|
|
388
|
-
if itr[:multi] == 1
|
|
389
|
-
hts_itr_multi_next(htsfp, itr, r)
|
|
390
|
-
else
|
|
391
|
-
bgzf = htsfp[:is_bgzf] == 1 ? htsfp[:fp][:bgzf] : FFI::Pointer::NULL
|
|
392
|
-
hts_itr_next(bgzf, itr, r, htsfp)
|
|
393
|
-
end
|
|
394
|
-
end
|
|
395
|
-
|
|
396
|
-
attach_function \
|
|
397
|
-
:sam_parse_region,
|
|
398
|
-
[SamHdr, :string, :pointer, :pointer, :pointer, :int],
|
|
399
|
-
:string
|
|
400
|
-
|
|
401
|
-
# SAM I/O
|
|
402
|
-
|
|
403
|
-
# macros (or alias)
|
|
404
|
-
# sam_open
|
|
405
|
-
# sam_open_format
|
|
406
|
-
# sam_close
|
|
407
|
-
|
|
408
|
-
attach_function \
|
|
409
|
-
:sam_open_mode,
|
|
410
|
-
%i[string string string],
|
|
411
|
-
:int
|
|
412
|
-
|
|
413
|
-
# A version of sam_open_mode that can handle ,key=value options.
|
|
414
|
-
attach_function \
|
|
415
|
-
:sam_open_mode_opts,
|
|
416
|
-
%i[string string string],
|
|
417
|
-
:string
|
|
418
|
-
|
|
419
|
-
attach_function \
|
|
420
|
-
:sam_hdr_change_HD,
|
|
421
|
-
[SamHdr, :string, :string],
|
|
422
|
-
:int
|
|
423
|
-
|
|
424
|
-
attach_function \
|
|
425
|
-
:sam_parse1,
|
|
426
|
-
[KString, SamHdr, :pointer], # [KString, SamHdr, (Bam1 | Bam1View)]
|
|
427
|
-
:int
|
|
428
|
-
|
|
429
|
-
attach_function \
|
|
430
|
-
:sam_format1,
|
|
431
|
-
[SamHdr, :pointer, KString], # [SamHdr, (Bam1 | Bam1View), KString]
|
|
432
|
-
:int
|
|
433
|
-
|
|
434
|
-
# Read a record from a file
|
|
435
|
-
attach_function \
|
|
436
|
-
:sam_read1,
|
|
437
|
-
[HtsFile, SamHdr, :pointer], # [HtsFile, SamHdr, (Bam1 | Bam1View)]
|
|
438
|
-
:int
|
|
439
|
-
|
|
440
|
-
# Write a record to a file
|
|
441
|
-
attach_function \
|
|
442
|
-
:sam_write1,
|
|
443
|
-
[HtsFile, SamHdr, :pointer], # [HtsFile, SamHdr, (Bam1 | Bam1View)]
|
|
444
|
-
:int
|
|
445
|
-
|
|
446
|
-
# Checks whether a record passes an hts_filter.
|
|
447
|
-
attach_function \
|
|
448
|
-
:sam_passes_filter,
|
|
449
|
-
[SamHdr, Bam1, :pointer], # hts_filter_t
|
|
450
|
-
:int
|
|
451
|
-
|
|
452
|
-
# Return a pointer to a BAM record's first aux field
|
|
453
|
-
attach_function \
|
|
454
|
-
:bam_aux_first,
|
|
455
|
-
[Bam1],
|
|
456
|
-
:pointer
|
|
457
|
-
|
|
458
|
-
# Return a pointer to a BAM record's next aux field
|
|
459
|
-
attach_function \
|
|
460
|
-
:bam_aux_next,
|
|
461
|
-
[Bam1, :pointer],
|
|
462
|
-
:pointer
|
|
463
|
-
|
|
464
|
-
# Return a pointer to an aux record
|
|
465
|
-
attach_function \
|
|
466
|
-
:bam_aux_get,
|
|
467
|
-
[Bam1, :string], # const char tag[2]
|
|
468
|
-
:pointer
|
|
469
|
-
|
|
470
|
-
# Get an integer aux value
|
|
471
|
-
attach_function \
|
|
472
|
-
:bam_aux2i,
|
|
473
|
-
[:pointer],
|
|
474
|
-
:int64
|
|
475
|
-
|
|
476
|
-
# Get an integer aux value
|
|
477
|
-
attach_function \
|
|
478
|
-
:bam_aux2f,
|
|
479
|
-
[:pointer],
|
|
480
|
-
:double
|
|
481
|
-
|
|
482
|
-
# Get a character aux value
|
|
483
|
-
attach_function \
|
|
484
|
-
:bam_aux2A,
|
|
485
|
-
[:pointer],
|
|
486
|
-
:char
|
|
487
|
-
|
|
488
|
-
# Get a string aux value
|
|
489
|
-
attach_function \
|
|
490
|
-
:bam_aux2Z,
|
|
491
|
-
[:pointer],
|
|
492
|
-
:string
|
|
493
|
-
|
|
494
|
-
# Get the length of an array-type ('B') tag
|
|
495
|
-
attach_function \
|
|
496
|
-
:bam_auxB_len,
|
|
497
|
-
[:pointer],
|
|
498
|
-
:uint
|
|
499
|
-
|
|
500
|
-
# Get an integer value from an array-type tag
|
|
501
|
-
attach_function \
|
|
502
|
-
:bam_auxB2i,
|
|
503
|
-
%i[pointer uint],
|
|
504
|
-
:int64
|
|
505
|
-
|
|
506
|
-
# Get a floating-point value from an array-type tag
|
|
507
|
-
attach_function \
|
|
508
|
-
:bam_auxB2f,
|
|
509
|
-
%i[pointer uint],
|
|
510
|
-
:double
|
|
511
|
-
|
|
512
|
-
# Append tag data to a bam record
|
|
513
|
-
attach_function \
|
|
514
|
-
:bam_aux_append,
|
|
515
|
-
[Bam1, :string, :char, :int, :pointer],
|
|
516
|
-
:int
|
|
517
|
-
|
|
518
|
-
# Delete tag data from a bam record
|
|
519
|
-
attach_function \
|
|
520
|
-
:bam_aux_del,
|
|
521
|
-
[Bam1, :pointer],
|
|
522
|
-
:int
|
|
523
|
-
|
|
524
|
-
# Delete an aux field from a BAM record. Identical to @c bam_aux_del() apart from the return value
|
|
525
|
-
attach_function \
|
|
526
|
-
:bam_aux_remove,
|
|
527
|
-
[Bam1, :pointer],
|
|
528
|
-
:pointer
|
|
529
|
-
|
|
530
|
-
# Update or add a string-type tag
|
|
531
|
-
attach_function \
|
|
532
|
-
:bam_aux_update_str,
|
|
533
|
-
[Bam1, :string, :int, :string],
|
|
534
|
-
:int
|
|
535
|
-
|
|
536
|
-
# Update or add an integer tag
|
|
537
|
-
attach_function \
|
|
538
|
-
:bam_aux_update_int,
|
|
539
|
-
[Bam1, :string, :int64],
|
|
540
|
-
:int
|
|
541
|
-
|
|
542
|
-
# Update or add a floating-point tag
|
|
543
|
-
attach_function \
|
|
544
|
-
:bam_aux_update_float,
|
|
545
|
-
[Bam1, :string, :float],
|
|
546
|
-
:int
|
|
547
|
-
|
|
548
|
-
# Update or add an array tag
|
|
549
|
-
attach_function \
|
|
550
|
-
:bam_aux_update_array,
|
|
551
|
-
[Bam1, :string, :uint8, :uint32, :pointer],
|
|
552
|
-
:int
|
|
553
|
-
|
|
554
|
-
# sets an iterator over multiple
|
|
555
|
-
attach_function \
|
|
556
|
-
:bam_plp_init,
|
|
557
|
-
%i[bam_plp_auto_f pointer],
|
|
558
|
-
:bam_plp
|
|
559
|
-
|
|
560
|
-
attach_function \
|
|
561
|
-
:bam_plp_destroy,
|
|
562
|
-
[:bam_plp],
|
|
563
|
-
:void
|
|
564
|
-
|
|
565
|
-
attach_function \
|
|
566
|
-
:bam_plp_push,
|
|
567
|
-
[:bam_plp, Bam1.by_ref],
|
|
568
|
-
:int
|
|
569
|
-
|
|
570
|
-
attach_function \
|
|
571
|
-
:bam_plp_next,
|
|
572
|
-
%i[bam_plp pointer pointer pointer],
|
|
573
|
-
:pointer # BamPileup1.by_ref
|
|
574
|
-
|
|
575
|
-
attach_function \
|
|
576
|
-
:bam_plp_auto,
|
|
577
|
-
%i[bam_plp pointer pointer pointer],
|
|
578
|
-
:pointer # BamPileup1.by_ref
|
|
579
|
-
|
|
580
|
-
attach_function \
|
|
581
|
-
:bam_plp64_next,
|
|
582
|
-
%i[bam_plp pointer pointer pointer],
|
|
583
|
-
:pointer # BamPileup1.by_ref
|
|
584
|
-
|
|
585
|
-
attach_function \
|
|
586
|
-
:bam_plp64_auto,
|
|
587
|
-
%i[bam_plp pointer pointer pointer],
|
|
588
|
-
:pointer # BamPileup1.by_ref
|
|
589
|
-
|
|
590
|
-
attach_function \
|
|
591
|
-
:bam_plp_set_maxcnt,
|
|
592
|
-
%i[bam_plp int],
|
|
593
|
-
:void
|
|
594
|
-
|
|
595
|
-
attach_function \
|
|
596
|
-
:bam_plp_reset,
|
|
597
|
-
[:bam_plp],
|
|
598
|
-
:void
|
|
599
|
-
|
|
600
|
-
# Callback type for constructor/destructor: int (*)(void *data, const bam1_t *b, bam_pileup_cd *cd)
|
|
601
|
-
callback :bam_plp_callback_function, [:pointer, :pointer, BamPileupCd.by_ref], :int
|
|
602
|
-
# callback :bam_plp_callback_function, [:pointer, Bam1.by_ref, BamPileupCd.by_ref], :int
|
|
603
|
-
|
|
604
|
-
# sets a callback to initialise any per-pileup1_t fields.
|
|
605
|
-
attach_function \
|
|
606
|
-
:bam_plp_constructor,
|
|
607
|
-
%i[bam_plp bam_plp_callback_function],
|
|
608
|
-
:void
|
|
609
|
-
|
|
610
|
-
attach_function \
|
|
611
|
-
:bam_plp_destructor,
|
|
612
|
-
%i[bam_plp bam_plp_callback_function],
|
|
613
|
-
:void
|
|
614
|
-
|
|
615
|
-
# Get pileup padded insertion sequence
|
|
616
|
-
# Make pointer passing explicit by using by_ref for structs
|
|
617
|
-
attach_function \
|
|
618
|
-
:bam_plp_insertion,
|
|
619
|
-
[BamPileup1.by_ref, KString.by_ref, :pointer],
|
|
620
|
-
:int
|
|
621
|
-
|
|
622
|
-
# Get pileup padded insertion sequence, including base modifications
|
|
623
|
-
attach_function \
|
|
624
|
-
:bam_plp_insertion_mod,
|
|
625
|
-
[BamPileup1.by_ref, HtsBaseModState, KString.by_ref, :pointer],
|
|
626
|
-
:int
|
|
627
|
-
|
|
628
|
-
# NOTE: There is no bam_plp_init_overlaps in HTSlib (only bam_mplp_init_overlaps exists).
|
|
629
|
-
# The incorrect binding is removed to avoid undefined symbol errors.
|
|
630
|
-
|
|
631
|
-
attach_function \
|
|
632
|
-
:bam_mplp_init,
|
|
633
|
-
%i[int bam_plp_auto_f pointer],
|
|
634
|
-
:bam_mplp
|
|
635
|
-
|
|
636
|
-
attach_function \
|
|
637
|
-
:bam_mplp_init_overlaps,
|
|
638
|
-
[:bam_mplp],
|
|
639
|
-
:int
|
|
640
|
-
|
|
641
|
-
attach_function \
|
|
642
|
-
:bam_mplp_destroy,
|
|
643
|
-
[:bam_mplp],
|
|
644
|
-
:void
|
|
645
|
-
|
|
646
|
-
attach_function \
|
|
647
|
-
:bam_mplp_set_maxcnt,
|
|
648
|
-
%i[bam_mplp int],
|
|
649
|
-
:void
|
|
650
|
-
|
|
651
|
-
attach_function \
|
|
652
|
-
:bam_mplp_auto,
|
|
653
|
-
%i[bam_mplp pointer pointer pointer pointer], # BamPileup1T
|
|
654
|
-
:int
|
|
655
|
-
|
|
656
|
-
attach_function \
|
|
657
|
-
:bam_mplp64_auto,
|
|
658
|
-
%i[bam_mplp pointer pointer pointer pointer], # BamPileup1T
|
|
659
|
-
:int
|
|
660
|
-
|
|
661
|
-
attach_function \
|
|
662
|
-
:bam_mplp_reset,
|
|
663
|
-
[:bam_mplp],
|
|
664
|
-
:void
|
|
665
|
-
|
|
666
|
-
attach_function \
|
|
667
|
-
:bam_mplp_constructor,
|
|
668
|
-
%i[bam_mplp bam_plp_callback_function],
|
|
669
|
-
:void
|
|
670
|
-
|
|
671
|
-
attach_function \
|
|
672
|
-
:bam_mplp_destructor,
|
|
673
|
-
%i[bam_mplp bam_plp_callback_function],
|
|
674
|
-
:void
|
|
675
|
-
|
|
676
|
-
attach_function \
|
|
677
|
-
:sam_cap_mapq,
|
|
678
|
-
[Bam1, :string, :hts_pos_t, :int],
|
|
679
|
-
:int
|
|
680
|
-
|
|
681
|
-
attach_function \
|
|
682
|
-
:sam_prob_realn,
|
|
683
|
-
[Bam1, :string, :hts_pos_t, :int],
|
|
684
|
-
:int
|
|
685
|
-
|
|
686
|
-
# Allocates an hts_base_mode_state.
|
|
687
|
-
attach_function \
|
|
688
|
-
:hts_base_mod_state_alloc,
|
|
689
|
-
[],
|
|
690
|
-
HtsBaseModState
|
|
691
|
-
|
|
692
|
-
# Destroys an hts_base_mode_state.
|
|
693
|
-
attach_function \
|
|
694
|
-
:hts_base_mod_state_free,
|
|
695
|
-
[HtsBaseModState],
|
|
696
|
-
:void
|
|
697
|
-
|
|
698
|
-
# Parses the MM and ML tags out of a bam record.
|
|
699
|
-
attach_function \
|
|
700
|
-
:bam_parse_basemod,
|
|
701
|
-
[Bam1, HtsBaseModState],
|
|
702
|
-
:int
|
|
703
|
-
|
|
704
|
-
# Parses the MM and ML tags out of a bam record.
|
|
705
|
-
attach_function \
|
|
706
|
-
:bam_parse_basemod2,
|
|
707
|
-
[Bam1, HtsBaseModState, :uint32],
|
|
708
|
-
:int
|
|
709
|
-
|
|
710
|
-
# Returns modification status for the next base position in the query seq.
|
|
711
|
-
attach_function \
|
|
712
|
-
:bam_mods_at_next_pos,
|
|
713
|
-
[Bam1, HtsBaseModState, :pointer, :int],
|
|
714
|
-
:int
|
|
715
|
-
|
|
716
|
-
# Finds the next location containing base modifications and returns them
|
|
717
|
-
attach_function \
|
|
718
|
-
:bam_next_basemod,
|
|
719
|
-
[Bam1, HtsBaseModState, :pointer, :int, :pointer],
|
|
720
|
-
:int
|
|
721
|
-
|
|
722
|
-
# Returns modification status for a specific query position.
|
|
723
|
-
attach_function \
|
|
724
|
-
:bam_mods_at_qpos,
|
|
725
|
-
[Bam1, :int, HtsBaseModState, :pointer, :int],
|
|
726
|
-
:int
|
|
727
|
-
|
|
728
|
-
# Returns data about a specific modification type for the alignment record.
|
|
729
|
-
attach_function \
|
|
730
|
-
:bam_mods_query_type,
|
|
731
|
-
[HtsBaseModState, :int, :pointer, :pointer, :pointer],
|
|
732
|
-
:int
|
|
733
|
-
|
|
734
|
-
# Returns data about the i^th modification type for the alignment record.
|
|
735
|
-
attach_function \
|
|
736
|
-
:bam_mods_queryi,
|
|
737
|
-
[HtsBaseModState, :int, :pointer, :pointer, :pointer],
|
|
738
|
-
:int
|
|
739
|
-
|
|
740
|
-
# Returns the list of base modification codes provided for this
|
|
741
|
-
attach_function \
|
|
742
|
-
:bam_mods_recorded,
|
|
743
|
-
[HtsBaseModState, :pointer],
|
|
744
|
-
:pointer
|
|
745
|
-
|
|
746
|
-
# Sets the header to the file
|
|
747
|
-
attach_function \
|
|
748
|
-
:sam_hdr_set,
|
|
749
|
-
[HtsFile, SamHdr, :int],
|
|
750
|
-
:int
|
|
751
|
-
|
|
752
|
-
# Get the header from the file pointer
|
|
753
|
-
attach_function \
|
|
754
|
-
:sam_hdr_get,
|
|
755
|
-
[HtsFile],
|
|
756
|
-
SamHdr
|
|
757
|
-
end
|
|
758
|
-
end
|
|
759
|
-
|
|
760
|
-
require_relative "sam_funcs"
|