htslib 0.0.10 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,296 +2,291 @@
2
2
 
3
3
  module HTS
4
4
  module LibHTS
5
-
6
- =begin
7
-
8
- attach_function \
9
- :cram_fd_get_header,
10
- [CramFd],
11
- SamHdr.by_ref
12
-
13
- attach_function \
14
- :cram_fd_set_header,
15
- [CramFd, SamHdr.by_ref],
16
- :void
17
-
18
- attach_function \
19
- :cram_fd_get_version,
20
- [CramFd],
21
- :int
22
-
23
- attach_function \
24
- :cram_fd_set_version,
25
- [CramFd, :int],
26
- :void
27
-
28
- attach_function \
29
- :cram_major_vers,
30
- [CramFd],
31
- :int
32
-
33
- attach_function \
34
- :cram_minor_vers,
35
- [CramFd],
36
- :int
37
-
38
- attach_function \
39
- :cram_fd_get_fp,
40
- [CramFd],
41
- HFile.by_ref
42
-
43
- attach_function \
44
- :cram_fd_set_fp,
45
- [CramFd, HFile],
46
- :void
47
-
48
- attach_function \
49
- :cram_container_get_length,
50
- [CramContainer],
51
- :int32
52
-
53
- attach_function \
54
- :cram_container_set_length,
55
- [CramContainer, :int32],
56
- :void
57
-
58
- attach_function \
59
- :cram_container_get_num_blocks,
60
- [CramContainer],
61
- :int32
62
-
63
- attach_function \
64
- :cram_container_set_num_blocks,
65
- [CramContainer, :int32],
66
- :void
67
-
68
- attach_function \
69
- :cram_container_get_landmarks,
70
- [CramContainer, :int32],
71
- :pointer
72
-
73
- attach_function \
74
- :cram_container_set_landmarks,
75
- [CramContainer, :Int32, :pointer],
76
- :void
77
-
78
- attach_function \
79
- :cram_container_is_empty,
80
- [CramFd],
81
- :int
82
-
83
- attach_function \
84
- :cram_block_get_content_id,
85
- [CramBlock],
86
- :int32
87
-
88
- attach_function \
89
- :cram_block_get_comp_size,
90
- [CramBlock],
91
- :int32
92
-
93
- attach_function \
94
- :cram_block_get_uncomp_size,
95
- [CramBlock],
96
- :int32
97
-
98
- attach_function \
99
- :cram_block_get_crc32,
100
- [CramBlock],
101
- :int32
102
-
103
- attach_function \
104
- :cram_block_get_data,
105
- [CramBlock],
106
- :pointer
107
-
108
- attach_function \
109
- :cram_block_get_content_type,
110
- [CramBlock],
111
- CramContentType # ?
112
-
113
- attach_function \
114
- :cram_block_set_content_id,
115
- [CramBlock, :int32],
116
- :void
117
-
118
- attach_function \
119
- :cram_block_set_comp_size,
120
- [CramBlock, :int32],
121
- :void
122
-
123
- attach_function \
124
- :cram_block_set_uncomp_size,
125
- [CramBlock, :int32],
126
- :void
127
-
128
- attach_function \
129
- :cram_block_set_crc32,
130
- [CramBlock, :int32],
131
- :void
132
-
133
- attach_function \
134
- :cram_block_set_data,
135
- [CramBlock, :pointer],
136
- :void
137
-
138
- attach_function \
139
- :cram_block_append,
140
- [CramBlock, :pointer, :int],
141
- :int
142
-
143
- attach_function \
144
- :cram_block_update_size,
145
- [CramBlock],
146
- :void
147
-
148
- attach_function \
149
- :cram_block_get_offset,
150
- [CramBlock],
151
- :size_t
152
-
153
- attach_function \
154
- :cram_block_set_offset,
155
- [CramBlock, :size_t],
156
- :void
157
-
158
- attach_function \
159
- :cram_block_size,
160
- [CramBlock],
161
- :uint32
162
-
163
- attach_function \
164
- :cram_transcode_rg,
165
- [CramFd, CramFd, CramContainer, :int, :pointer, :pointer],
166
- :int
167
-
168
- attach_function \
169
- :cram_copy_slice,
170
- [CramFd, CramFd, :int32],
171
- :int
172
-
173
- attach_function \
174
- :cram_new_block,
175
- [CramContentType, :int],
176
- CramBlock
177
-
178
- attach_function \
179
- :cram_read_block,
180
- [CramFd],
181
- CramBlock
182
-
183
- attach_function \
184
- :cram_write_block,
185
- [CramFd, CramBlock],
186
- :int
187
-
188
- attach_function \
189
- :cram_free_block,
190
- [CramBlock],
191
- :void
192
-
193
- attach_function \
194
- :cram_uncompress_block,
195
- [CramBlock],
196
- :int
197
-
198
- attach_function \
199
- :cram_compress_block,
200
- [CramFd, CramBlock, CramMetrics, :int, :int],
201
- :int
202
-
203
- attach_function \
204
- :cram_compress_block2,
205
- [CramFd, CramSlice, CramBlock, CramMetrics, :int, :int],
206
- :int
207
-
208
- attach_function \
209
- :cram_new_container,
210
- [:int, :int],
211
- CramContainer
212
-
213
- attach_function \
214
- :cram_free_container,
215
- [CramContainer],
216
- :void
217
-
218
- attach_function \
219
- :cram_read_container,
220
- [CramFd],
221
- CramContainer
222
-
223
- attach_function \
224
- :cram_write_container,
225
- [CramFd, CramContainer],
226
- :int
227
-
228
- attach_function \
229
- :cram_store_container,
230
- [CramFd, CramContainer, :string, :pointer],
231
- :int
232
-
233
- attach_function \
234
- :cram_container_size,
235
- [CramContainer],
236
- :int
237
-
238
- attach_function \
239
- :cram_open,
240
- [:string, :string],
241
- CramFd
242
-
243
- attach_function \
244
- :cram_dopen,
245
- [:pointer, :string, :string],
246
- CramFd
247
-
248
- attach_function \
249
- :cram_close,
250
- [CramFd],
251
- :int
252
-
253
- =end
254
-
255
- attach_function \
256
- :cram_seek,
257
- [:pointer, :off_t, :int], :int # FIXME pointer should be CramFd
258
-
259
- =begin
260
-
261
- attach_function \
262
- :cram_flush,
263
- [CramFd],
264
- :int
265
-
266
- attach_function \
267
- :cram_eof,
268
- [CramFd],
269
- :int
270
-
271
- attach_function \
272
- :cram_set_option,
273
- [CramFd, HtsFmtOption, ...], # vararg!
274
- :int
275
-
276
- attach_function \
277
- :cram_set_voption,
278
- [CramFd, HtsFmtOption, VaList],
279
- :int
280
-
281
- attach_function \
282
- :cram_set_header,
283
- [CramFd, SamHdr.by_ref],
284
- :int
285
-
286
- attach_function \
287
- :cram_check_eof = :cram_check_EOF,
288
- [CramFd], :int
289
-
290
- attach_function \
291
- :cram_get_refs,
292
- [HtsFile],
293
- RefsT # what is RefsT
294
-
295
- =end
5
+ #
6
+ # attach_function \
7
+ # :cram_fd_get_header,
8
+ # [CramFd],
9
+ # SamHdr.by_ref
10
+ #
11
+ # attach_function \
12
+ # :cram_fd_set_header,
13
+ # [CramFd, SamHdr.by_ref],
14
+ # :void
15
+ #
16
+ # attach_function \
17
+ # :cram_fd_get_version,
18
+ # [CramFd],
19
+ # :int
20
+ #
21
+ # attach_function \
22
+ # :cram_fd_set_version,
23
+ # [CramFd, :int],
24
+ # :void
25
+ #
26
+ # attach_function \
27
+ # :cram_major_vers,
28
+ # [CramFd],
29
+ # :int
30
+ #
31
+ # attach_function \
32
+ # :cram_minor_vers,
33
+ # [CramFd],
34
+ # :int
35
+ #
36
+ # attach_function \
37
+ # :cram_fd_get_fp,
38
+ # [CramFd],
39
+ # HFile.by_ref
40
+ #
41
+ # attach_function \
42
+ # :cram_fd_set_fp,
43
+ # [CramFd, HFile],
44
+ # :void
45
+ #
46
+ # attach_function \
47
+ # :cram_container_get_length,
48
+ # [CramContainer],
49
+ # :int32
50
+ #
51
+ # attach_function \
52
+ # :cram_container_set_length,
53
+ # [CramContainer, :int32],
54
+ # :void
55
+ #
56
+ # attach_function \
57
+ # :cram_container_get_num_blocks,
58
+ # [CramContainer],
59
+ # :int32
60
+ #
61
+ # attach_function \
62
+ # :cram_container_set_num_blocks,
63
+ # [CramContainer, :int32],
64
+ # :void
65
+ #
66
+ # attach_function \
67
+ # :cram_container_get_landmarks,
68
+ # [CramContainer, :int32],
69
+ # :pointer
70
+ #
71
+ # attach_function \
72
+ # :cram_container_set_landmarks,
73
+ # [CramContainer, :Int32, :pointer],
74
+ # :void
75
+ #
76
+ # attach_function \
77
+ # :cram_container_is_empty,
78
+ # [CramFd],
79
+ # :int
80
+ #
81
+ # attach_function \
82
+ # :cram_block_get_content_id,
83
+ # [CramBlock],
84
+ # :int32
85
+ #
86
+ # attach_function \
87
+ # :cram_block_get_comp_size,
88
+ # [CramBlock],
89
+ # :int32
90
+ #
91
+ # attach_function \
92
+ # :cram_block_get_uncomp_size,
93
+ # [CramBlock],
94
+ # :int32
95
+ #
96
+ # attach_function \
97
+ # :cram_block_get_crc32,
98
+ # [CramBlock],
99
+ # :int32
100
+ #
101
+ # attach_function \
102
+ # :cram_block_get_data,
103
+ # [CramBlock],
104
+ # :pointer
105
+ #
106
+ # attach_function \
107
+ # :cram_block_get_content_type,
108
+ # [CramBlock],
109
+ # CramContentType # ?
110
+ #
111
+ # attach_function \
112
+ # :cram_block_set_content_id,
113
+ # [CramBlock, :int32],
114
+ # :void
115
+ #
116
+ # attach_function \
117
+ # :cram_block_set_comp_size,
118
+ # [CramBlock, :int32],
119
+ # :void
120
+ #
121
+ # attach_function \
122
+ # :cram_block_set_uncomp_size,
123
+ # [CramBlock, :int32],
124
+ # :void
125
+ #
126
+ # attach_function \
127
+ # :cram_block_set_crc32,
128
+ # [CramBlock, :int32],
129
+ # :void
130
+ #
131
+ # attach_function \
132
+ # :cram_block_set_data,
133
+ # [CramBlock, :pointer],
134
+ # :void
135
+ #
136
+ # attach_function \
137
+ # :cram_block_append,
138
+ # [CramBlock, :pointer, :int],
139
+ # :int
140
+ #
141
+ # attach_function \
142
+ # :cram_block_update_size,
143
+ # [CramBlock],
144
+ # :void
145
+ #
146
+ # attach_function \
147
+ # :cram_block_get_offset,
148
+ # [CramBlock],
149
+ # :size_t
150
+ #
151
+ # attach_function \
152
+ # :cram_block_set_offset,
153
+ # [CramBlock, :size_t],
154
+ # :void
155
+ #
156
+ # attach_function \
157
+ # :cram_block_size,
158
+ # [CramBlock],
159
+ # :uint32
160
+ #
161
+ # attach_function \
162
+ # :cram_transcode_rg,
163
+ # [CramFd, CramFd, CramContainer, :int, :pointer, :pointer],
164
+ # :int
165
+ #
166
+ # attach_function \
167
+ # :cram_copy_slice,
168
+ # [CramFd, CramFd, :int32],
169
+ # :int
170
+ #
171
+ # attach_function \
172
+ # :cram_new_block,
173
+ # [CramContentType, :int],
174
+ # CramBlock
175
+ #
176
+ # attach_function \
177
+ # :cram_read_block,
178
+ # [CramFd],
179
+ # CramBlock
180
+ #
181
+ # attach_function \
182
+ # :cram_write_block,
183
+ # [CramFd, CramBlock],
184
+ # :int
185
+ #
186
+ # attach_function \
187
+ # :cram_free_block,
188
+ # [CramBlock],
189
+ # :void
190
+ #
191
+ # attach_function \
192
+ # :cram_uncompress_block,
193
+ # [CramBlock],
194
+ # :int
195
+ #
196
+ # attach_function \
197
+ # :cram_compress_block,
198
+ # [CramFd, CramBlock, CramMetrics, :int, :int],
199
+ # :int
200
+ #
201
+ # attach_function \
202
+ # :cram_compress_block2,
203
+ # [CramFd, CramSlice, CramBlock, CramMetrics, :int, :int],
204
+ # :int
205
+ #
206
+ # attach_function \
207
+ # :cram_new_container,
208
+ # [:int, :int],
209
+ # CramContainer
210
+ #
211
+ # attach_function \
212
+ # :cram_free_container,
213
+ # [CramContainer],
214
+ # :void
215
+ #
216
+ # attach_function \
217
+ # :cram_read_container,
218
+ # [CramFd],
219
+ # CramContainer
220
+ #
221
+ # attach_function \
222
+ # :cram_write_container,
223
+ # [CramFd, CramContainer],
224
+ # :int
225
+ #
226
+ # attach_function \
227
+ # :cram_store_container,
228
+ # [CramFd, CramContainer, :string, :pointer],
229
+ # :int
230
+ #
231
+ # attach_function \
232
+ # :cram_container_size,
233
+ # [CramContainer],
234
+ # :int
235
+ #
236
+ # attach_function \
237
+ # :cram_open,
238
+ # [:string, :string],
239
+ # CramFd
240
+ #
241
+ # attach_function \
242
+ # :cram_dopen,
243
+ # [:pointer, :string, :string],
244
+ # CramFd
245
+ #
246
+ # attach_function \
247
+ # :cram_close,
248
+ # [CramFd],
249
+ # :int
250
+ #
251
+
252
+ attach_function \
253
+ :cram_seek,
254
+ %i[pointer off_t int], :int # FIXME: pointer should be CramFd
255
+
256
+ #
257
+ # attach_function \
258
+ # :cram_flush,
259
+ # [CramFd],
260
+ # :int
261
+ #
262
+ # attach_function \
263
+ # :cram_eof,
264
+ # [CramFd],
265
+ # :int
266
+ #
267
+ # attach_function \
268
+ # :cram_set_option,
269
+ # [CramFd, HtsFmtOption, ...], # vararg!
270
+ # :int
271
+ #
272
+ # attach_function \
273
+ # :cram_set_voption,
274
+ # [CramFd, HtsFmtOption, VaList],
275
+ # :int
276
+ #
277
+ # attach_function \
278
+ # :cram_set_header,
279
+ # [CramFd, SamHdr.by_ref],
280
+ # :int
281
+ #
282
+ # attach_function \
283
+ # :cram_check_eof = :cram_check_EOF,
284
+ # [CramFd], :int
285
+ #
286
+ # attach_function \
287
+ # :cram_get_refs,
288
+ # [HtsFile],
289
+ # RefsT # what is RefsT
290
+ #
296
291
  end
297
- end
292
+ end
@@ -221,6 +221,20 @@ module HTS
221
221
  LibHTS::BcfIdpair.size * int_id # offset
222
222
  )[:val][:info][type] >> 12
223
223
  end
224
+
225
+ def bcf_hdr_id2type(hdr, type, int_id)
226
+ LibHTS::BcfIdpair.new(
227
+ hdr[:id][LibHTS::BCF_DT_ID].to_ptr +
228
+ LibHTS::BcfIdpair.size * int_id # offset
229
+ )[:val][:info][type] >> 4 & 0xf
230
+ end
231
+
232
+ def bcf_hdr_id2coltype(hdr, type, int_id)
233
+ LibHTS::BcfIdpair.new(
234
+ hdr[:id][LibHTS::BCF_DT_ID].to_ptr +
235
+ LibHTS::BcfIdpair.size * int_id # offset
236
+ )[:val][:info][type] & 0xf
237
+ end
224
238
  end
225
239
  end
226
240
  end
data/lib/hts/libhts.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "ffi_ext/struct"
4
+ require_relative "ffi_ext/pointer"
4
5
 
5
6
  module HTS
6
7
  module LibHTS
@@ -12,6 +13,9 @@ module HTS
12
13
  raise LoadError, "#{e}\nCould not find #{HTS.lib_path}"
13
14
  end
14
15
 
16
+ # @!macro attach_function
17
+ # @!method $1(${2--2})
18
+ # @return [${-1}] the return value of $0
15
19
  def self.attach_function(*)
16
20
  super
17
21
  rescue FFI::NotFoundError => e
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "../htslib"
2
4
 
3
5
  require_relative "hts"
4
6
 
5
7
  module HTS
6
- class Tabix < Hts
8
+ class Tbx < Hts
7
9
  include Enumerable
8
10
 
9
11
  attr_reader :file_name
@@ -22,7 +24,7 @@ module HTS
22
24
 
23
25
  def initialize(file_name, threads: nil)
24
26
  if block_given?
25
- message = "HTS::Tabix.new() dose not take block; Please use HTS::Tabix.open() instead"
27
+ message = "HTS::Tbx.new() dose not take block; Please use HTS::Tbx.open() instead"
26
28
  raise message
27
29
  end
28
30
 
@@ -40,14 +42,5 @@ module HTS
40
42
  raise "Failed to set number of threads: #{threads}" if r < 0
41
43
  end
42
44
  end
43
-
44
- def close
45
- LibHTS.hts_close(@hts_file)
46
- @hts_file = nil
47
- end
48
-
49
- def closed?
50
- @hts_file.nil?
51
- end
52
45
  end
53
46
  end
data/lib/hts/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HTS
4
- VERSION = "0.0.10"
4
+ VERSION = "0.1.0"
5
5
  end
data/lib/htslib.rb CHANGED
@@ -40,6 +40,6 @@ module HTS
40
40
 
41
41
  autoload :Bam, "hts/bam"
42
42
  autoload :Bcf, "hts/bcf"
43
- autoload :Tabix, "hts/tabix"
43
+ autoload :Tbx, "hts/tbx"
44
44
  autoload :Faidx, "hts/faidx"
45
45
  end