htslib 0.0.0.pre
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 +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +45 -0
- data/lib/hts/bam.rb +85 -0
- data/lib/hts/fai.rb +14 -0
- data/lib/hts/ffi.rb +31 -0
- data/lib/hts/ffi/bgzf.rb +192 -0
- data/lib/hts/ffi/faidx.rb +139 -0
- data/lib/hts/ffi/hfile.rb +81 -0
- data/lib/hts/ffi/hts.rb +324 -0
- data/lib/hts/ffi/kfunc.rb +36 -0
- data/lib/hts/ffi/sam.rb +648 -0
- data/lib/hts/ffi/struct.rb +12 -0
- data/lib/hts/ffi/tbx.rb +68 -0
- data/lib/hts/ffi_constants.rb +430 -0
- data/lib/hts/tbx.rb +12 -0
- data/lib/hts/vcf.rb +28 -0
- data/lib/hts/version.rb +5 -0
- data/lib/htslib.rb +18 -0
- metadata +145 -0
@@ -0,0 +1,81 @@
|
|
1
|
+
module HTS
|
2
|
+
module FFI
|
3
|
+
# Open the named file or URL as a stream
|
4
|
+
attach_function \
|
5
|
+
:hopen,
|
6
|
+
%i[string string varargs],
|
7
|
+
:HFILE
|
8
|
+
|
9
|
+
# Associate a stream with an existing open file descriptor
|
10
|
+
attach_function \
|
11
|
+
:hdopen,
|
12
|
+
%i[int string],
|
13
|
+
:HFILE
|
14
|
+
|
15
|
+
# Report whether the file name or URL denotes remote storage
|
16
|
+
attach_function \
|
17
|
+
:hisremote,
|
18
|
+
[:string],
|
19
|
+
:int
|
20
|
+
|
21
|
+
# Append an extension or replace an existing extension
|
22
|
+
attach_function \
|
23
|
+
:haddextension,
|
24
|
+
[Kstring, :string, :int, :string],
|
25
|
+
:string
|
26
|
+
|
27
|
+
# Flush (for output streams) and close the stream
|
28
|
+
attach_function \
|
29
|
+
:hclose,
|
30
|
+
[:HFILE],
|
31
|
+
:int
|
32
|
+
|
33
|
+
# Close the stream, without flushing or propagating errors
|
34
|
+
attach_function \
|
35
|
+
:hclose_abruptly,
|
36
|
+
[:HFILE],
|
37
|
+
:void
|
38
|
+
|
39
|
+
# Reposition the read/write stream offset
|
40
|
+
attach_function \
|
41
|
+
:hseek,
|
42
|
+
%i[HFILE off_t int],
|
43
|
+
:off_t
|
44
|
+
|
45
|
+
# Read from the stream until the delimiter, up to a maximum length
|
46
|
+
attach_function \
|
47
|
+
:hgetdelim,
|
48
|
+
%i[string size_t int HFILE],
|
49
|
+
:ssize_t
|
50
|
+
|
51
|
+
# Read a line from the stream, up to a maximum length
|
52
|
+
attach_function \
|
53
|
+
:hgets,
|
54
|
+
%i[string int HFILE],
|
55
|
+
:string
|
56
|
+
|
57
|
+
# Peek at characters to be read without removing them from buffers
|
58
|
+
attach_function \
|
59
|
+
:hpeek,
|
60
|
+
%i[HFILE pointer size_t],
|
61
|
+
:ssize_t
|
62
|
+
|
63
|
+
# For writing streams, flush buffered output to the underlying stream
|
64
|
+
attach_function \
|
65
|
+
:hflush,
|
66
|
+
[:HFILE],
|
67
|
+
:int
|
68
|
+
|
69
|
+
# For hfile_mem: get the internal buffer and it's size from a hfile
|
70
|
+
attach_function \
|
71
|
+
:hfile_mem_get_buffer,
|
72
|
+
%i[HFILE pointer],
|
73
|
+
:string
|
74
|
+
|
75
|
+
# For hfile_mem: get the internal buffer and it's size from a hfile.
|
76
|
+
attach_function \
|
77
|
+
:hfile_mem_steal_buffer,
|
78
|
+
%i[HFILE pointer],
|
79
|
+
:string
|
80
|
+
end
|
81
|
+
end
|
data/lib/hts/ffi/hts.rb
ADDED
@@ -0,0 +1,324 @@
|
|
1
|
+
module HTS
|
2
|
+
module FFI
|
3
|
+
# hts_expand
|
4
|
+
# hts_expand3
|
5
|
+
# hts_resize
|
6
|
+
|
7
|
+
attach_function \
|
8
|
+
:hts_lib_shutdown,
|
9
|
+
[:void],
|
10
|
+
:void
|
11
|
+
|
12
|
+
attach_function \
|
13
|
+
:hts_free,
|
14
|
+
[:pointer],
|
15
|
+
:void
|
16
|
+
|
17
|
+
# Parses arg and appends it to the option list.
|
18
|
+
attach_function \
|
19
|
+
:hts_opt_add,
|
20
|
+
%i[pointer string],
|
21
|
+
:int
|
22
|
+
|
23
|
+
# Applies an hts_opt option list to a given htsFile.
|
24
|
+
attach_function \
|
25
|
+
:hts_opt_apply,
|
26
|
+
[HtsFile, HtsOpt],
|
27
|
+
:int
|
28
|
+
|
29
|
+
# Frees an hts_opt list.
|
30
|
+
attach_function \
|
31
|
+
:hts_opt_free,
|
32
|
+
[HtsOpt],
|
33
|
+
:void
|
34
|
+
|
35
|
+
# Accepts a string file format (sam, bam, cram, vcf, bam)
|
36
|
+
attach_function \
|
37
|
+
:hts_parse_format,
|
38
|
+
[HtsFormat, :string],
|
39
|
+
:int
|
40
|
+
|
41
|
+
# Tokenise options as (key(=value)?,)*(key(=value)?)?
|
42
|
+
attach_function \
|
43
|
+
:hts_parse_opt_list,
|
44
|
+
[HtsFormat, :string],
|
45
|
+
:int
|
46
|
+
|
47
|
+
# Get the htslib version number
|
48
|
+
attach_function \
|
49
|
+
:hts_version,
|
50
|
+
[],
|
51
|
+
:string
|
52
|
+
|
53
|
+
# Determine format by peeking at the start of a file
|
54
|
+
attach_function \
|
55
|
+
:hts_detect_format,
|
56
|
+
[:HFILE, HtsFormat],
|
57
|
+
:int
|
58
|
+
|
59
|
+
# Get a human-readable description of the file format
|
60
|
+
attach_function \
|
61
|
+
:hts_format_description,
|
62
|
+
[HtsFormat],
|
63
|
+
:string
|
64
|
+
|
65
|
+
# Open a sequence data (SAM/BAM/CRAM) or variant data (VCF/BCF)
|
66
|
+
# or possibly-compressed textual line-orientated file
|
67
|
+
attach_function \
|
68
|
+
:hts_open,
|
69
|
+
%i[string string],
|
70
|
+
HtsFile.by_ref
|
71
|
+
|
72
|
+
# Open a SAM/BAM/CRAM/VCF/BCF/etc file
|
73
|
+
attach_function \
|
74
|
+
:hts_open_format,
|
75
|
+
[:string, :string, HtsFormat],
|
76
|
+
HtsFile.by_ref
|
77
|
+
|
78
|
+
# Open an existing stream as a SAM/BAM/CRAM/VCF/BCF/etc file
|
79
|
+
attach_function \
|
80
|
+
:hts_hopen,
|
81
|
+
%i[HFILE string string],
|
82
|
+
HtsFile.by_ref
|
83
|
+
|
84
|
+
# Close a file handle, flushing buffered data for output streams
|
85
|
+
attach_function \
|
86
|
+
:hts_close,
|
87
|
+
[HtsFile],
|
88
|
+
:int
|
89
|
+
|
90
|
+
# Returns the file's format information
|
91
|
+
attach_function \
|
92
|
+
:hts_get_format,
|
93
|
+
[HtsFile],
|
94
|
+
HtsFormat.by_ref
|
95
|
+
|
96
|
+
# Returns a string containing the file format extension.
|
97
|
+
attach_function \
|
98
|
+
:hts_format_file_extension,
|
99
|
+
[HtsFormat],
|
100
|
+
:string
|
101
|
+
|
102
|
+
# Sets a specified CRAM option on the open file handle.
|
103
|
+
attach_function \
|
104
|
+
:hts_set_opt,
|
105
|
+
[HtsFile, HtsFmtOption, :varargs],
|
106
|
+
:int
|
107
|
+
|
108
|
+
# Read a line (and its \n or \r\n terminator) from a file
|
109
|
+
attach_function \
|
110
|
+
:hts_getline,
|
111
|
+
[HtsFile, :int, Kstring],
|
112
|
+
:int
|
113
|
+
|
114
|
+
attach_function \
|
115
|
+
:hts_readlines,
|
116
|
+
%i[string pointer],
|
117
|
+
:pointer
|
118
|
+
|
119
|
+
# Parse comma-separated list or read list from a file
|
120
|
+
attach_function \
|
121
|
+
:hts_readlist,
|
122
|
+
%i[string int pointer],
|
123
|
+
:pointer
|
124
|
+
|
125
|
+
# Create extra threads to aid compress/decompression for this file
|
126
|
+
attach_function \
|
127
|
+
:hts_set_threads,
|
128
|
+
[HtsFile, :int],
|
129
|
+
:int
|
130
|
+
|
131
|
+
# Create extra threads to aid compress/decompression for this file
|
132
|
+
attach_function \
|
133
|
+
:hts_set_thread_pool,
|
134
|
+
[HtsFile, HtsThreadPool],
|
135
|
+
:int
|
136
|
+
|
137
|
+
# Adds a cache of decompressed blocks, potentially speeding up seeks.
|
138
|
+
attach_function \
|
139
|
+
:hts_set_cache_size,
|
140
|
+
[HtsFile, :int],
|
141
|
+
:void
|
142
|
+
|
143
|
+
# Set .fai filename for a file opened for reading
|
144
|
+
attach_function \
|
145
|
+
:hts_set_fai_filename,
|
146
|
+
[HtsFile, :string],
|
147
|
+
:int
|
148
|
+
|
149
|
+
# Determine whether a given htsFile contains a valid EOF block
|
150
|
+
attach_function \
|
151
|
+
:hts_check_EOF,
|
152
|
+
[HtsFile],
|
153
|
+
:int
|
154
|
+
|
155
|
+
# hts_pair_pos_t
|
156
|
+
# hts_pair64_t
|
157
|
+
# hts_pair4_max_t
|
158
|
+
# hts_reglist_t
|
159
|
+
# hts_readrec_func
|
160
|
+
# hts_seek_func
|
161
|
+
# hts_tell_func
|
162
|
+
|
163
|
+
# Create a BAI/CSI/TBI type index structure
|
164
|
+
attach_function \
|
165
|
+
:hts_idx_init,
|
166
|
+
%i[int int uint64 int int],
|
167
|
+
:pointer
|
168
|
+
|
169
|
+
# Free a BAI/CSI/TBI type index
|
170
|
+
attach_function \
|
171
|
+
:hts_idx_destroy,
|
172
|
+
[HtsIdx],
|
173
|
+
:void
|
174
|
+
|
175
|
+
# Push an index entry
|
176
|
+
attach_function \
|
177
|
+
:hts_idx_push,
|
178
|
+
[HtsIdx, :int, :int64, :int64, :uint64, :int],
|
179
|
+
:int
|
180
|
+
|
181
|
+
# Finish building an index
|
182
|
+
attach_function \
|
183
|
+
:hts_idx_finish,
|
184
|
+
[HtsIdx, :uint64],
|
185
|
+
:int
|
186
|
+
|
187
|
+
# Returns index format
|
188
|
+
attach_function \
|
189
|
+
:hts_idx_fmt,
|
190
|
+
[HtsIdx],
|
191
|
+
:int
|
192
|
+
|
193
|
+
# Add name to TBI index meta-data
|
194
|
+
attach_function \
|
195
|
+
:hts_idx_tbi_name,
|
196
|
+
[HtsIdx, :int, :string],
|
197
|
+
:int
|
198
|
+
|
199
|
+
# Save an index to a file
|
200
|
+
attach_function \
|
201
|
+
:hts_idx_save,
|
202
|
+
[HtsIdx, :string, :int],
|
203
|
+
:int
|
204
|
+
|
205
|
+
# Save an index to a specific file
|
206
|
+
attach_function \
|
207
|
+
:hts_idx_save_as,
|
208
|
+
[HtsIdx, :string, :string, :int],
|
209
|
+
:int
|
210
|
+
|
211
|
+
# Load an index file
|
212
|
+
attach_function \
|
213
|
+
:hts_idx_load,
|
214
|
+
%i[string int],
|
215
|
+
HtsIdx.by_ref
|
216
|
+
|
217
|
+
# Load a specific index file
|
218
|
+
attach_function \
|
219
|
+
:hts_idx_load2,
|
220
|
+
%i[string string],
|
221
|
+
HtsIdx.by_ref
|
222
|
+
|
223
|
+
# Load a specific index file
|
224
|
+
attach_function \
|
225
|
+
:hts_idx_load3,
|
226
|
+
%i[string string int int],
|
227
|
+
HtsIdx.by_ref
|
228
|
+
|
229
|
+
# Get extra index meta-data
|
230
|
+
attach_function \
|
231
|
+
:hts_idx_get_meta,
|
232
|
+
[HtsIdx, :pointer],
|
233
|
+
:uint8
|
234
|
+
|
235
|
+
# Set extra index meta-data
|
236
|
+
attach_function \
|
237
|
+
:hts_idx_set_meta,
|
238
|
+
[HtsIdx, :uint32, :pointer, :int],
|
239
|
+
:int
|
240
|
+
|
241
|
+
# Get number of mapped and unmapped reads from an index
|
242
|
+
attach_function \
|
243
|
+
:hts_idx_get_stat,
|
244
|
+
[HtsIdx, :int, :pointer, :pointer],
|
245
|
+
:int
|
246
|
+
|
247
|
+
# Return the number of unplaced reads from an index
|
248
|
+
attach_function \
|
249
|
+
:hts_idx_get_n_no_coor,
|
250
|
+
[HtsIdx],
|
251
|
+
:uint64
|
252
|
+
|
253
|
+
attach_function \
|
254
|
+
:hts_parse_decimal,
|
255
|
+
%i[string pointer int],
|
256
|
+
:long_long
|
257
|
+
|
258
|
+
# Parse a "CHR:START-END"-style region string
|
259
|
+
attach_function \
|
260
|
+
:hts_parse_reg64,
|
261
|
+
%i[string pointer pointer],
|
262
|
+
:string
|
263
|
+
|
264
|
+
# Parse a "CHR:START-END"-style region string
|
265
|
+
attach_function \
|
266
|
+
:hts_parse_reg,
|
267
|
+
%i[string pointer pointer],
|
268
|
+
:string
|
269
|
+
|
270
|
+
# Parse a "CHR:START-END"-style region string
|
271
|
+
attach_function \
|
272
|
+
:hts_parse_region,
|
273
|
+
%i[string pointer pointer pointer pointer pointer int],
|
274
|
+
:string
|
275
|
+
|
276
|
+
# Create a single-region iterator
|
277
|
+
attach_function \
|
278
|
+
:hts_itr_query,
|
279
|
+
[HtsIdx, :int, :hts_pos_t, :hts_pos_t, :pointer],
|
280
|
+
HtsItr.by_ref
|
281
|
+
|
282
|
+
# Free an iterator
|
283
|
+
attach_function \
|
284
|
+
:hts_itr_destroy,
|
285
|
+
[HtsItr],
|
286
|
+
:void
|
287
|
+
|
288
|
+
# Create a single-region iterator from a text region specification
|
289
|
+
attach_function \
|
290
|
+
:hts_itr_querys,
|
291
|
+
[HtsIdx, :string, :pointer, :pointer, :pointer, :pointer],
|
292
|
+
HtsItr.by_ref
|
293
|
+
|
294
|
+
# Return the next record from an iterator
|
295
|
+
attach_function \
|
296
|
+
:hts_itr_next,
|
297
|
+
[BGZF, HtsItr, :pointer, :pointer],
|
298
|
+
:int
|
299
|
+
|
300
|
+
attach_function \
|
301
|
+
:hts_idx_seqnames,
|
302
|
+
[HtsIdx, :pointer, :pointer, :pointer],
|
303
|
+
:pointer
|
304
|
+
|
305
|
+
# hts_itr_multi_bam
|
306
|
+
# hts_itr_multi_cram
|
307
|
+
# hts_itr_regions
|
308
|
+
# hts_itr_multi_next
|
309
|
+
# hts_reglist_create
|
310
|
+
# hts_reglist_free
|
311
|
+
# errmod_init
|
312
|
+
# errmod_destroy
|
313
|
+
# errmod_call
|
314
|
+
# proabln_glocal
|
315
|
+
# hts_md5_context
|
316
|
+
# hts_md5_update
|
317
|
+
# hts_md5_final
|
318
|
+
# hts_md5_reset
|
319
|
+
# hts_md5_hex
|
320
|
+
# hts_md5_destroy
|
321
|
+
|
322
|
+
# attach_function :sam_hdr_tid2name, [:pointer, :int], :string
|
323
|
+
end
|
324
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module HTS
|
2
|
+
module FFI
|
3
|
+
# Log gamma function
|
4
|
+
attach_function \
|
5
|
+
:kf_lgamma,
|
6
|
+
[:double],
|
7
|
+
:double
|
8
|
+
|
9
|
+
# complementary error function
|
10
|
+
attach_function \
|
11
|
+
:kf_erfc,
|
12
|
+
[:double],
|
13
|
+
:double
|
14
|
+
|
15
|
+
# The following computes regularized incomplete gamma functions.
|
16
|
+
attach_function \
|
17
|
+
:kf_gammap,
|
18
|
+
%i[double double],
|
19
|
+
:double
|
20
|
+
|
21
|
+
attach_function \
|
22
|
+
:kf_gammaq,
|
23
|
+
%i[double double],
|
24
|
+
:double
|
25
|
+
|
26
|
+
attach_function \
|
27
|
+
:kf_betai,
|
28
|
+
%i[double double double],
|
29
|
+
:double
|
30
|
+
|
31
|
+
attach_function \
|
32
|
+
:kt_fisher_exact,
|
33
|
+
%i[int int int int pointer pointer pointer],
|
34
|
+
:double
|
35
|
+
end
|
36
|
+
end
|
data/lib/hts/ffi/sam.rb
ADDED
@@ -0,0 +1,648 @@
|
|
1
|
+
module HTS
|
2
|
+
module FFI
|
3
|
+
# macros
|
4
|
+
class << self
|
5
|
+
def bam_cigar_op(c)
|
6
|
+
c & BAM_CIGAR_MASK
|
7
|
+
end
|
8
|
+
|
9
|
+
def bam_cigar_oplen(c)
|
10
|
+
c >> BAM_CIGAR_SHIFT
|
11
|
+
end
|
12
|
+
|
13
|
+
def bam_cigar_opchar(c)
|
14
|
+
_BAM_CIGAR_STR_PADDED[bam_cigar_op(c)]
|
15
|
+
end
|
16
|
+
|
17
|
+
def bam_cigar_gen(l, o)
|
18
|
+
l << BAM_CIGAR_SHIFT | o
|
19
|
+
end
|
20
|
+
|
21
|
+
def bam_cigar_type(o)
|
22
|
+
BAM_CIGAR_TYPE >> (o << 1) & 3
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# macros
|
27
|
+
# function-like macros
|
28
|
+
class << self
|
29
|
+
def bam_is_rev(b)
|
30
|
+
b[:core][:flag] & BAM_FREVERSE != 0
|
31
|
+
end
|
32
|
+
|
33
|
+
def bam_is_mrev(b)
|
34
|
+
b[:core][:flag] & BAM_FMREVERSE != 0
|
35
|
+
end
|
36
|
+
|
37
|
+
def bam_get_qname(b)
|
38
|
+
b[:data]
|
39
|
+
end
|
40
|
+
|
41
|
+
def bam_get_cigar(b)
|
42
|
+
b[:data] + b[:core][:l_qname]
|
43
|
+
end
|
44
|
+
|
45
|
+
def bam_get_seq(b)
|
46
|
+
b[:data] + (b[:core][:n_cigar] << 2) + b[:core][:l_qname]
|
47
|
+
end
|
48
|
+
|
49
|
+
def bam_get_qual(b)
|
50
|
+
b[:data] + (b[:core][:n_cigar] << 2) + b[:core][:l_qname] + ((b[:core][:l_qseq] + 1) >> 1)
|
51
|
+
end
|
52
|
+
|
53
|
+
def bam_get_aux(b)
|
54
|
+
b[:data] + (b[:core][:n_cigar] << 2) + b[:core][:l_qname] + ((b[:core][:l_qseq] + 1) >> 1) + b[:core][:l_qseq]
|
55
|
+
end
|
56
|
+
|
57
|
+
def bam_get_l_aux(b)
|
58
|
+
b[:l_data] - (b[:core][:n_cigar] << 2) - b[:core][:l_qname] - b[:core][:l_qseq] - ((b[:core][:l_qseq] + 1) >> 1)
|
59
|
+
end
|
60
|
+
|
61
|
+
# def bam_seqi(s, i)
|
62
|
+
|
63
|
+
# def bam_set_seqi(s, i, b)
|
64
|
+
end
|
65
|
+
|
66
|
+
# Generates a new unpopulated header structure.
|
67
|
+
attach_function \
|
68
|
+
:sam_hdr_init,
|
69
|
+
[],
|
70
|
+
SamHdr.by_ref
|
71
|
+
|
72
|
+
# Read the header from a BAM compressed file.
|
73
|
+
attach_function \
|
74
|
+
:bam_hdr_read,
|
75
|
+
[BGZF],
|
76
|
+
SamHdr.by_ref
|
77
|
+
|
78
|
+
# Writes the header to a BAM file.
|
79
|
+
attach_function \
|
80
|
+
:bam_hdr_write,
|
81
|
+
[BGZF, SamHdr],
|
82
|
+
:int
|
83
|
+
|
84
|
+
# Frees the resources associated with a header.
|
85
|
+
attach_function \
|
86
|
+
:sam_hdr_destroy,
|
87
|
+
[SamHdr],
|
88
|
+
:void
|
89
|
+
|
90
|
+
# Duplicate a header structure.
|
91
|
+
attach_function \
|
92
|
+
:sam_hdr_dup,
|
93
|
+
[SamHdr],
|
94
|
+
SamHdr.by_ref
|
95
|
+
|
96
|
+
# Create a header from existing text.
|
97
|
+
attach_function \
|
98
|
+
:sam_hdr_parse,
|
99
|
+
%i[size_t string],
|
100
|
+
SamHdr.by_ref
|
101
|
+
|
102
|
+
# Read a header from a SAM, BAM or CRAM file.
|
103
|
+
attach_function \
|
104
|
+
:sam_hdr_read,
|
105
|
+
[SamFile],
|
106
|
+
SamHdr.by_ref
|
107
|
+
|
108
|
+
# Write a header to a SAM, BAM or CRAM file.
|
109
|
+
attach_function \
|
110
|
+
:sam_hdr_write,
|
111
|
+
[SamFile, SamHdr],
|
112
|
+
:int
|
113
|
+
|
114
|
+
# Returns the current length of the header text.
|
115
|
+
attach_function \
|
116
|
+
:sam_hdr_length,
|
117
|
+
[SamHdr],
|
118
|
+
:size_t
|
119
|
+
|
120
|
+
# Returns the text representation of the header.
|
121
|
+
attach_function \
|
122
|
+
:sam_hdr_str,
|
123
|
+
[SamHdr],
|
124
|
+
:string
|
125
|
+
|
126
|
+
# Returns the number of references in the header.
|
127
|
+
attach_function \
|
128
|
+
:sam_hdr_nref,
|
129
|
+
[SamHdr],
|
130
|
+
:int
|
131
|
+
|
132
|
+
# Add formatted lines to an existing header.
|
133
|
+
attach_function \
|
134
|
+
:sam_hdr_add_lines,
|
135
|
+
[SamHdr, :string, :size_t],
|
136
|
+
:int
|
137
|
+
|
138
|
+
# Adds a single line to an existing header.
|
139
|
+
attach_function \
|
140
|
+
:sam_hdr_add_line,
|
141
|
+
[SamHdr, :string, :varargs],
|
142
|
+
:int
|
143
|
+
|
144
|
+
# Returns a complete line of formatted text for a given type and ID.
|
145
|
+
attach_function \
|
146
|
+
:sam_hdr_find_line_id,
|
147
|
+
[SamHdr, :string, :string, :string, Kstring],
|
148
|
+
:int
|
149
|
+
|
150
|
+
# Returns a complete line of formatted text for a given type and index.
|
151
|
+
attach_function \
|
152
|
+
:sam_hdr_find_line_pos,
|
153
|
+
[SamHdr, :string, :int, Kstring],
|
154
|
+
:int
|
155
|
+
|
156
|
+
# Remove a line with given type / id from a header
|
157
|
+
attach_function \
|
158
|
+
:sam_hdr_remove_line_id,
|
159
|
+
[SamHdr, :string, :string, :string],
|
160
|
+
:int
|
161
|
+
|
162
|
+
# Remove nth line of a given type from a header
|
163
|
+
attach_function \
|
164
|
+
:sam_hdr_remove_line_pos,
|
165
|
+
[SamHdr, :string, :int],
|
166
|
+
:int
|
167
|
+
|
168
|
+
# Add or update tag key,value pairs in a header line.
|
169
|
+
attach_function \
|
170
|
+
:sam_hdr_update_line,
|
171
|
+
[SamHdr, :string, :string, :string, :varargs],
|
172
|
+
:int
|
173
|
+
|
174
|
+
# Remove all lines of a given type from a header, except the one matching an ID
|
175
|
+
attach_function \
|
176
|
+
:sam_hdr_remove_except,
|
177
|
+
[SamHdr, :string, :string, :string],
|
178
|
+
:int
|
179
|
+
|
180
|
+
# Remove header lines of a given type, except those in a given ID set
|
181
|
+
attach_function \
|
182
|
+
:sam_hdr_remove_lines,
|
183
|
+
[SamHdr, :string, :string, :pointer],
|
184
|
+
:int
|
185
|
+
|
186
|
+
# Count the number of lines for a given header type
|
187
|
+
attach_function \
|
188
|
+
:sam_hdr_count_lines,
|
189
|
+
[SamHdr, :string],
|
190
|
+
:int
|
191
|
+
|
192
|
+
# Index of the line for the types that have dedicated look-up tables (SQ, RG, PG)
|
193
|
+
attach_function \
|
194
|
+
:sam_hdr_line_index,
|
195
|
+
[SamHdr, :string, :string],
|
196
|
+
:int
|
197
|
+
|
198
|
+
# Id key of the line for the types that have dedicated look-up tables (SQ, RG, PG)
|
199
|
+
attach_function \
|
200
|
+
:sam_hdr_line_name,
|
201
|
+
[SamHdr, :string, :int],
|
202
|
+
:string
|
203
|
+
|
204
|
+
# Return the value associated with a key for a header line identified by ID_key:ID_val
|
205
|
+
attach_function \
|
206
|
+
:sam_hdr_find_tag_id,
|
207
|
+
[SamHdr, :string, :string, :string, :string, Kstring],
|
208
|
+
:int
|
209
|
+
|
210
|
+
# Return the value associated with a key for a header line identified by position
|
211
|
+
attach_function \
|
212
|
+
:sam_hdr_find_tag_pos,
|
213
|
+
[SamHdr, :string, :int, :string, Kstring],
|
214
|
+
:int
|
215
|
+
|
216
|
+
# Remove the key from the line identified by type, ID_key and ID_value.
|
217
|
+
attach_function \
|
218
|
+
:sam_hdr_remove_tag_id,
|
219
|
+
[SamHdr, :string, :string, :string, :string],
|
220
|
+
:int
|
221
|
+
|
222
|
+
# Get the target id for a given reference sequence name
|
223
|
+
attach_function \
|
224
|
+
:sam_hdr_name2tid,
|
225
|
+
[SamHdr, :string],
|
226
|
+
:int
|
227
|
+
|
228
|
+
# Get the reference sequence name from a target index
|
229
|
+
attach_function \
|
230
|
+
:sam_hdr_tid2name,
|
231
|
+
[SamHdr, :int],
|
232
|
+
:string
|
233
|
+
|
234
|
+
# Get the reference sequence length from a target index
|
235
|
+
attach_function \
|
236
|
+
:sam_hdr_tid2len,
|
237
|
+
[SamHdr, :int],
|
238
|
+
:hts_pos_t
|
239
|
+
|
240
|
+
# Generate a unique \@PG ID: value
|
241
|
+
attach_function \
|
242
|
+
:sam_hdr_pg_id,
|
243
|
+
[SamHdr, :string],
|
244
|
+
:string
|
245
|
+
|
246
|
+
# Add an \@PG line.
|
247
|
+
attach_function \
|
248
|
+
:sam_hdr_add_pg,
|
249
|
+
[SamHdr, :string, :varargs],
|
250
|
+
:int
|
251
|
+
|
252
|
+
# A function to help with construction of CL tags in @PG records.
|
253
|
+
attach_function \
|
254
|
+
:stringify_argv,
|
255
|
+
%i[int pointer],
|
256
|
+
:string
|
257
|
+
|
258
|
+
# Increments the reference count on a header
|
259
|
+
attach_function \
|
260
|
+
:sam_hdr_incr_ref,
|
261
|
+
[SamHdr],
|
262
|
+
:void
|
263
|
+
|
264
|
+
# Create a new bam1_t alignment structure
|
265
|
+
attach_function \
|
266
|
+
:bam_init1,
|
267
|
+
[],
|
268
|
+
Bam1.by_ref
|
269
|
+
|
270
|
+
# Destroy a bam1_t structure
|
271
|
+
attach_function \
|
272
|
+
:bam_destroy1,
|
273
|
+
[Bam1],
|
274
|
+
:void
|
275
|
+
|
276
|
+
# Read a BAM format alignment record
|
277
|
+
attach_function \
|
278
|
+
:bam_read1,
|
279
|
+
[BGZF, Bam1],
|
280
|
+
:int
|
281
|
+
|
282
|
+
# Write a BAM format alignment record
|
283
|
+
attach_function \
|
284
|
+
:bam_write1,
|
285
|
+
[BGZF, Bam1],
|
286
|
+
:int
|
287
|
+
|
288
|
+
# Copy alignment record data
|
289
|
+
attach_function \
|
290
|
+
:bam_copy1,
|
291
|
+
[Bam1, Bam1],
|
292
|
+
Bam1.by_ref
|
293
|
+
|
294
|
+
# Create a duplicate alignment record
|
295
|
+
attach_function \
|
296
|
+
:bam_dup1,
|
297
|
+
[Bam1],
|
298
|
+
Bam1.by_ref
|
299
|
+
|
300
|
+
# Calculate query length from CIGAR data
|
301
|
+
attach_function \
|
302
|
+
:bam_cigar2qlen,
|
303
|
+
%i[int pointer],
|
304
|
+
:int64
|
305
|
+
|
306
|
+
# Calculate reference length from CIGAR data
|
307
|
+
attach_function \
|
308
|
+
:bam_cigar2rlen,
|
309
|
+
%i[int pointer],
|
310
|
+
:hts_pos_t
|
311
|
+
|
312
|
+
# Calculate the rightmost base position of an alignment on the reference genome.
|
313
|
+
attach_function \
|
314
|
+
:bam_endpos,
|
315
|
+
[Bam1],
|
316
|
+
:hts_pos_t
|
317
|
+
|
318
|
+
attach_function \
|
319
|
+
:bam_str2flag,
|
320
|
+
[:string],
|
321
|
+
:int
|
322
|
+
|
323
|
+
attach_function \
|
324
|
+
:bam_flag2str,
|
325
|
+
[:int],
|
326
|
+
:string
|
327
|
+
|
328
|
+
# Set the name of the query
|
329
|
+
attach_function \
|
330
|
+
:bam_set_qname,
|
331
|
+
[Bam1, :string],
|
332
|
+
:int
|
333
|
+
|
334
|
+
# Initialise fp->idx for the current format type for SAM, BAM and CRAM types .
|
335
|
+
attach_function \
|
336
|
+
:sam_idx_init,
|
337
|
+
[HtsFile, SamHdr, :int, :string],
|
338
|
+
:int
|
339
|
+
|
340
|
+
# Writes the index initialised with sam_idx_init to disk.
|
341
|
+
attach_function \
|
342
|
+
:sam_idx_save,
|
343
|
+
[HtsFile],
|
344
|
+
:int
|
345
|
+
|
346
|
+
# Load a BAM (.csi or .bai) or CRAM (.crai) index file
|
347
|
+
attach_function \
|
348
|
+
:sam_index_load,
|
349
|
+
[HtsFile, :string],
|
350
|
+
HtsIdx.by_ref
|
351
|
+
|
352
|
+
# Load a specific BAM (.csi or .bai) or CRAM (.crai) index file
|
353
|
+
attach_function \
|
354
|
+
:sam_index_load2,
|
355
|
+
[HtsFile, :string, :string],
|
356
|
+
HtsIdx.by_ref
|
357
|
+
|
358
|
+
# Load or stream a BAM (.csi or .bai) or CRAM (.crai) index file
|
359
|
+
attach_function \
|
360
|
+
:sam_index_load3,
|
361
|
+
[HtsFile, :string, :string, :int],
|
362
|
+
HtsIdx.by_ref
|
363
|
+
|
364
|
+
# Generate and save an index file
|
365
|
+
attach_function \
|
366
|
+
:sam_index_build,
|
367
|
+
%i[string int],
|
368
|
+
:int
|
369
|
+
|
370
|
+
# Generate and save an index to a specific file
|
371
|
+
attach_function \
|
372
|
+
:sam_index_build2,
|
373
|
+
%i[string string int],
|
374
|
+
:int
|
375
|
+
|
376
|
+
# Generate and save an index to a specific file
|
377
|
+
attach_function \
|
378
|
+
:sam_index_build3,
|
379
|
+
%i[string string int int],
|
380
|
+
:int
|
381
|
+
|
382
|
+
# Create a BAM/CRAM iterator
|
383
|
+
attach_function \
|
384
|
+
:sam_itr_queryi,
|
385
|
+
[HtsIdx, :int, :hts_pos_t, :hts_pos_t],
|
386
|
+
HtsItr.by_ref
|
387
|
+
|
388
|
+
# Create a SAM/BAM/CRAM iterator
|
389
|
+
attach_function \
|
390
|
+
:sam_itr_querys,
|
391
|
+
[HtsIdx, SamHdr, :string],
|
392
|
+
HtsItr.by_ref
|
393
|
+
|
394
|
+
# Create a multi-region iterator
|
395
|
+
attach_function \
|
396
|
+
:sam_itr_regions,
|
397
|
+
[HtsIdx, SamHdr, :pointer, :uint],
|
398
|
+
HtsItr.by_ref
|
399
|
+
|
400
|
+
# Create a multi-region iterator
|
401
|
+
attach_function \
|
402
|
+
:sam_itr_regarray,
|
403
|
+
[HtsIdx, SamHdr, :pointer, :uint],
|
404
|
+
HtsItr.by_ref
|
405
|
+
|
406
|
+
attach_function \
|
407
|
+
:sam_parse_region,
|
408
|
+
[SamHdr, :string, :pointer, :pointer, :pointer, :int],
|
409
|
+
:string
|
410
|
+
|
411
|
+
# SAM I/O
|
412
|
+
|
413
|
+
# macros (or alias)
|
414
|
+
# sam_open
|
415
|
+
# sam_open_format
|
416
|
+
# sam_close
|
417
|
+
|
418
|
+
attach_function \
|
419
|
+
:sam_open_mode,
|
420
|
+
%i[string string string],
|
421
|
+
:int
|
422
|
+
|
423
|
+
# A version of sam_open_mode that can handle ,key=value options.
|
424
|
+
attach_function \
|
425
|
+
:sam_open_mode_opts,
|
426
|
+
%i[string string string],
|
427
|
+
:string
|
428
|
+
|
429
|
+
attach_function \
|
430
|
+
:sam_hdr_change_HD,
|
431
|
+
[SamHdr, :string, :string],
|
432
|
+
:int
|
433
|
+
|
434
|
+
attach_function \
|
435
|
+
:sam_parse1,
|
436
|
+
[Kstring, SamHdr, Bam1],
|
437
|
+
:int
|
438
|
+
|
439
|
+
attach_function \
|
440
|
+
:sam_format1,
|
441
|
+
[SamHdr, Bam1, Kstring],
|
442
|
+
:int
|
443
|
+
|
444
|
+
# Read a record from a file
|
445
|
+
attach_function \
|
446
|
+
:sam_read1,
|
447
|
+
[HtsFile, SamHdr, Bam1],
|
448
|
+
:int
|
449
|
+
|
450
|
+
# Write a record to a file
|
451
|
+
attach_function \
|
452
|
+
:sam_write1,
|
453
|
+
[HtsFile, SamHdr, Bam1],
|
454
|
+
:int
|
455
|
+
|
456
|
+
# Return a pointer to an aux record
|
457
|
+
attach_function \
|
458
|
+
:bam_aux_get,
|
459
|
+
[Bam1, :string], # FIXME
|
460
|
+
:pointer
|
461
|
+
|
462
|
+
# Get an integer aux value
|
463
|
+
attach_function \
|
464
|
+
:bam_aux2i,
|
465
|
+
[:pointer],
|
466
|
+
:int64
|
467
|
+
|
468
|
+
# Get an integer aux value
|
469
|
+
attach_function \
|
470
|
+
:bam_aux2f,
|
471
|
+
[:pointer],
|
472
|
+
:double
|
473
|
+
|
474
|
+
# Get a character aux value
|
475
|
+
attach_function \
|
476
|
+
:bam_aux2A,
|
477
|
+
[:pointer],
|
478
|
+
:string
|
479
|
+
|
480
|
+
# Get a string aux value
|
481
|
+
attach_function \
|
482
|
+
:bam_aux2Z,
|
483
|
+
[:pointer],
|
484
|
+
:string
|
485
|
+
|
486
|
+
# Get the length of an array-type ('B') tag
|
487
|
+
attach_function \
|
488
|
+
:bam_auxB_len,
|
489
|
+
[:pointer],
|
490
|
+
:uint
|
491
|
+
|
492
|
+
# Get an integer value from an array-type tag
|
493
|
+
attach_function \
|
494
|
+
:bam_auxB2i,
|
495
|
+
%i[pointer uint],
|
496
|
+
:int64
|
497
|
+
|
498
|
+
# Get a floating-point value from an array-type tag
|
499
|
+
attach_function \
|
500
|
+
:bam_auxB2f,
|
501
|
+
%i[pointer uint],
|
502
|
+
:double
|
503
|
+
|
504
|
+
# Append tag data to a bam record
|
505
|
+
attach_function \
|
506
|
+
:bam_aux_append,
|
507
|
+
[Bam1, :string, :string, :int, :pointer],
|
508
|
+
:int
|
509
|
+
|
510
|
+
# Delete tag data from a bam record
|
511
|
+
attach_function \
|
512
|
+
:bam_aux_del,
|
513
|
+
[Bam1, :pointer],
|
514
|
+
:int
|
515
|
+
|
516
|
+
# Update or add a string-type tag
|
517
|
+
attach_function \
|
518
|
+
:bam_aux_update_str,
|
519
|
+
[Bam1, :string, :int, :string],
|
520
|
+
:int
|
521
|
+
|
522
|
+
# Update or add an integer tag
|
523
|
+
attach_function \
|
524
|
+
:bam_aux_update_int,
|
525
|
+
[Bam1, :string, :int64],
|
526
|
+
:int
|
527
|
+
|
528
|
+
# Update or add a floating-point tag
|
529
|
+
attach_function \
|
530
|
+
:bam_aux_update_float,
|
531
|
+
[Bam1, :string, :float],
|
532
|
+
:int
|
533
|
+
|
534
|
+
# Update or add an array tag
|
535
|
+
attach_function \
|
536
|
+
:bam_aux_update_array,
|
537
|
+
[Bam1, :string, :uint8, :uint32, :pointer],
|
538
|
+
:int
|
539
|
+
|
540
|
+
# sets an iterator over multiple
|
541
|
+
attach_function \
|
542
|
+
:bam_plp_init,
|
543
|
+
%i[bam_plp_auto_f pointer],
|
544
|
+
BamPlp
|
545
|
+
|
546
|
+
attach_function \
|
547
|
+
:bam_plp_destroy,
|
548
|
+
[BamPlp],
|
549
|
+
:void
|
550
|
+
|
551
|
+
attach_function \
|
552
|
+
:bam_plp_push,
|
553
|
+
[BamPlp, Bam1],
|
554
|
+
:int
|
555
|
+
|
556
|
+
attach_function \
|
557
|
+
:bam_plp_next,
|
558
|
+
[BamPlp, :pointer, :pointer, :pointer],
|
559
|
+
:pointer
|
560
|
+
|
561
|
+
attach_function \
|
562
|
+
:bam_plp_auto,
|
563
|
+
[BamPlp, :pointer, :pointer, :pointer],
|
564
|
+
:pointer
|
565
|
+
|
566
|
+
attach_function \
|
567
|
+
:bam_plp64_next,
|
568
|
+
[BamPlp, :pointer, :pointer, :pointer],
|
569
|
+
:pointer
|
570
|
+
|
571
|
+
attach_function \
|
572
|
+
:bam_plp64_auto,
|
573
|
+
[BamPlp, :pointer, :pointer, :pointer],
|
574
|
+
:pointer
|
575
|
+
|
576
|
+
attach_function \
|
577
|
+
:bam_plp_set_maxcnt,
|
578
|
+
[BamPlp, :int],
|
579
|
+
:void
|
580
|
+
|
581
|
+
attach_function \
|
582
|
+
:bam_plp_reset,
|
583
|
+
[BamPlp],
|
584
|
+
:void
|
585
|
+
|
586
|
+
# sets a callback to initialise any per-pileup1_t fields.
|
587
|
+
attach_function \
|
588
|
+
:bam_plp_insertion,
|
589
|
+
[:pointer, Kstring, :pointer],
|
590
|
+
:int
|
591
|
+
|
592
|
+
# sets a callback to initialise any per-pileup1_t fields.
|
593
|
+
# bam_plp_constructor
|
594
|
+
|
595
|
+
# bam_plp_destructor
|
596
|
+
|
597
|
+
# Get pileup padded insertion sequence
|
598
|
+
# bam_plp_insertion
|
599
|
+
|
600
|
+
attach_function \
|
601
|
+
:bam_mplp_init,
|
602
|
+
%i[int bam_plp_auto_f pointer],
|
603
|
+
BamMplp.by_ref
|
604
|
+
|
605
|
+
attach_function \
|
606
|
+
:bam_mplp_init_overlaps,
|
607
|
+
[BamMplp],
|
608
|
+
:int
|
609
|
+
|
610
|
+
attach_function \
|
611
|
+
:bam_mplp_destroy,
|
612
|
+
[BamMplp],
|
613
|
+
:void
|
614
|
+
|
615
|
+
attach_function \
|
616
|
+
:bam_mplp_set_maxcnt,
|
617
|
+
[BamMplp, :int],
|
618
|
+
:void
|
619
|
+
|
620
|
+
attach_function \
|
621
|
+
:bam_mplp_auto,
|
622
|
+
[BamMplp, :pointer, :pointer, :pointer, :pointer],
|
623
|
+
:int
|
624
|
+
|
625
|
+
attach_function \
|
626
|
+
:bam_mplp64_auto,
|
627
|
+
[BamMplp, :pointer, :pointer, :pointer, :pointer],
|
628
|
+
:int
|
629
|
+
|
630
|
+
attach_function \
|
631
|
+
:bam_mplp_reset,
|
632
|
+
[BamMplp],
|
633
|
+
:void
|
634
|
+
|
635
|
+
# bam_mplp_constructor
|
636
|
+
# bam_mplp_destructor
|
637
|
+
|
638
|
+
attach_function \
|
639
|
+
:sam_cap_mapq,
|
640
|
+
[Bam1, :string, :hts_pos_t, :int],
|
641
|
+
:int
|
642
|
+
|
643
|
+
attach_function \
|
644
|
+
:sam_prob_realn,
|
645
|
+
[Bam1, :string, :hts_pos_t, :int],
|
646
|
+
:int
|
647
|
+
end
|
648
|
+
end
|