htslib 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/lib/hts/ffi.rb DELETED
@@ -1,85 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module HTS
4
- module FFI
5
- extend ::FFI::Library
6
-
7
- begin
8
- ffi_lib HTS.ffi_lib
9
- rescue LoadError => e
10
- raise LoadError, "#{e}\nCould not find #{HTS.ffi_lib}"
11
- end
12
-
13
- def self.attach_function(*)
14
- super
15
- rescue ::FFI::NotFoundError => e
16
- warn e.message
17
- end
18
- end
19
- end
20
-
21
- module FFI
22
- class Struct
23
- class << self
24
- def union_layout(*args)
25
- Class.new(FFI::Union) { layout(*args) }
26
- end
27
-
28
- def struct_layout(*args)
29
- Class.new(FFI::Struct) { layout(*args) }
30
- end
31
- end
32
- end
33
-
34
- class BitStruct < Struct
35
- class << self
36
- module BitFieldsModule
37
- def [](name)
38
- bit_fields = self.class.bit_fields_hash_table
39
- parent, start, width = bit_fields[name]
40
- if parent
41
- (super(parent) >> start) & ((1 << width) - 1)
42
- else
43
- super(name)
44
- end
45
- end
46
- end
47
- private_constant :BitFieldsModule
48
-
49
- attr_reader :bit_fields_hash_table
50
-
51
- def bitfields(*args)
52
- unless instance_variable_defined?(:@bit_fields_hash_table)
53
- @bit_fields_hash_table = {}
54
- prepend BitFieldsModule
55
- end
56
-
57
- parent = args.shift
58
- labels = []
59
- widths = []
60
- args.each_slice(2) do |l, w|
61
- labels << l
62
- widths << w
63
- end
64
- starts = widths.inject([0]) do |result, w|
65
- result << (result.last + w)
66
- end
67
- labels.zip(starts, widths).each do |l, s, w|
68
- @bit_fields_hash_table[l] = [parent, s, w]
69
- end
70
- end
71
- end
72
- end
73
- end
74
-
75
- require_relative 'ffi/constants'
76
-
77
- # alphabetical order
78
- require_relative 'ffi/bgzf'
79
- require_relative 'ffi/faidx'
80
- require_relative 'ffi/hfile'
81
- require_relative 'ffi/hts'
82
- require_relative 'ffi/sam'
83
- require_relative 'ffi/kfunc'
84
- require_relative 'ffi/tbx'
85
- require_relative 'ffi/vcf'