htslib 0.0.8 → 0.2.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 +40 -33
- data/lib/hts/bam/aux.rb +40 -0
- data/lib/hts/bam/cigar.rb +10 -14
- data/lib/hts/bam/flag.rb +27 -58
- data/lib/hts/bam/header.rb +3 -5
- data/lib/hts/bam/record.rb +97 -56
- data/lib/hts/bam.rb +134 -64
- data/lib/hts/bcf/format.rb +85 -14
- data/lib/hts/bcf/header.rb +5 -4
- data/lib/hts/bcf/info.rb +58 -32
- data/lib/hts/bcf/record.rb +67 -38
- data/lib/hts/bcf.rb +155 -38
- data/lib/hts/faidx.rb +28 -19
- data/lib/hts/ffi_ext/pointer.rb +18 -0
- data/lib/hts/hts.rb +121 -0
- data/lib/hts/libhts/bgzf.rb +10 -5
- data/lib/hts/libhts/constants.rb +46 -7
- data/lib/hts/libhts/cram.rb +300 -0
- data/lib/hts/libhts/hfile.rb +37 -11
- data/lib/hts/libhts/hts.rb +158 -25
- data/lib/hts/libhts/sam.rb +683 -94
- data/lib/hts/libhts/sam_funcs.rb +92 -587
- data/lib/hts/libhts/vcf.rb +433 -220
- data/lib/hts/libhts/vcf_funcs.rb +232 -424
- data/lib/hts/libhts.rb +9 -3
- data/lib/hts/tbx.rb +45 -0
- data/lib/hts/version.rb +1 -1
- data/lib/htslib.rb +5 -5
- metadata +8 -4
- data/lib/hts/tabix.rb +0 -28
data/lib/hts/libhts.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
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
|
7
|
+
# A Module for working with native C HTSlib structures and functions.
|
6
8
|
module LibHTS
|
7
9
|
extend FFI::Library
|
8
10
|
|
@@ -12,6 +14,9 @@ module HTS
|
|
12
14
|
raise LoadError, "#{e}\nCould not find #{HTS.lib_path}"
|
13
15
|
end
|
14
16
|
|
17
|
+
# @!macro attach_function
|
18
|
+
# @!method $1(${2--2})
|
19
|
+
# @return [${-1}] the return value of $0
|
15
20
|
def self.attach_function(*)
|
16
21
|
super
|
17
22
|
rescue FFI::NotFoundError => e
|
@@ -23,12 +28,13 @@ end
|
|
23
28
|
require_relative "libhts/constants"
|
24
29
|
|
25
30
|
# This is alphabetical order.
|
31
|
+
require_relative "libhts/kfunc"
|
26
32
|
require_relative "libhts/bgzf"
|
27
|
-
require_relative "libhts/faidx"
|
28
33
|
require_relative "libhts/hfile"
|
29
34
|
require_relative "libhts/hts"
|
30
35
|
require_relative "libhts/sam"
|
31
|
-
require_relative "libhts/
|
32
|
-
require_relative "libhts/tbx"
|
36
|
+
require_relative "libhts/cram"
|
33
37
|
require_relative "libhts/vcf"
|
38
|
+
require_relative "libhts/tbx"
|
39
|
+
require_relative "libhts/faidx"
|
34
40
|
require_relative "libhts/thread_pool"
|
data/lib/hts/tbx.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../htslib"
|
4
|
+
|
5
|
+
require_relative "hts"
|
6
|
+
|
7
|
+
module HTS
|
8
|
+
class Tbx < Hts
|
9
|
+
include Enumerable
|
10
|
+
|
11
|
+
attr_reader :file_name
|
12
|
+
|
13
|
+
def self.open(*args, **kw)
|
14
|
+
file = new(*args, **kw) # do not yield
|
15
|
+
return file unless block_given?
|
16
|
+
|
17
|
+
begin
|
18
|
+
yield file
|
19
|
+
ensure
|
20
|
+
file.close
|
21
|
+
end
|
22
|
+
file
|
23
|
+
end
|
24
|
+
|
25
|
+
def initialize(file_name, threads: nil)
|
26
|
+
if block_given?
|
27
|
+
message = "HTS::Tbx.new() dose not take block; Please use HTS::Tbx.open() instead"
|
28
|
+
raise message
|
29
|
+
end
|
30
|
+
|
31
|
+
@file_name = file_name
|
32
|
+
|
33
|
+
# NOTE: Do not check for the existence of local files, since file_names may be remote URIs.
|
34
|
+
|
35
|
+
@mode = "r"
|
36
|
+
@hts_file = LibHTS.hts_open(@file_name, @mode)
|
37
|
+
|
38
|
+
raise Errno::ENOENT, "Failed to open #{@file_name}" if @hts_file.null?
|
39
|
+
|
40
|
+
set_threads(threads) if threads
|
41
|
+
|
42
|
+
super # do nothing
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/hts/version.rb
CHANGED
data/lib/htslib.rb
CHANGED
@@ -37,9 +37,9 @@ module HTS
|
|
37
37
|
# You can change the path of the shared library with `HTS.lib_path=`
|
38
38
|
# before calling the LibHTS module.
|
39
39
|
autoload :LibHTS, "hts/libhts"
|
40
|
-
end
|
41
40
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
41
|
+
autoload :Bam, "hts/bam"
|
42
|
+
autoload :Bcf, "hts/bcf"
|
43
|
+
autoload :Tbx, "hts/tbx"
|
44
|
+
autoload :Faidx, "hts/faidx"
|
45
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: htslib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kojix2
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- LICENSE.txt
|
133
133
|
- README.md
|
134
134
|
- lib/hts/bam.rb
|
135
|
+
- lib/hts/bam/aux.rb
|
135
136
|
- lib/hts/bam/cigar.rb
|
136
137
|
- lib/hts/bam/flag.rb
|
137
138
|
- lib/hts/bam/header.rb
|
@@ -143,10 +144,13 @@ files:
|
|
143
144
|
- lib/hts/bcf/record.rb
|
144
145
|
- lib/hts/faidx.rb
|
145
146
|
- lib/hts/ffi_ext/README.md
|
147
|
+
- lib/hts/ffi_ext/pointer.rb
|
146
148
|
- lib/hts/ffi_ext/struct.rb
|
149
|
+
- lib/hts/hts.rb
|
147
150
|
- lib/hts/libhts.rb
|
148
151
|
- lib/hts/libhts/bgzf.rb
|
149
152
|
- lib/hts/libhts/constants.rb
|
153
|
+
- lib/hts/libhts/cram.rb
|
150
154
|
- lib/hts/libhts/faidx.rb
|
151
155
|
- lib/hts/libhts/hfile.rb
|
152
156
|
- lib/hts/libhts/hts.rb
|
@@ -157,7 +161,7 @@ files:
|
|
157
161
|
- lib/hts/libhts/thread_pool.rb
|
158
162
|
- lib/hts/libhts/vcf.rb
|
159
163
|
- lib/hts/libhts/vcf_funcs.rb
|
160
|
-
- lib/hts/
|
164
|
+
- lib/hts/tbx.rb
|
161
165
|
- lib/hts/version.rb
|
162
166
|
- lib/htslib.rb
|
163
167
|
homepage: https://github.com/kojix2/ruby-htslib
|
@@ -172,7 +176,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
172
176
|
requirements:
|
173
177
|
- - ">="
|
174
178
|
- !ruby/object:Gem::Version
|
175
|
-
version: '
|
179
|
+
version: '3.1'
|
176
180
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
177
181
|
requirements:
|
178
182
|
- - ">="
|
data/lib/hts/tabix.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Based on hts-python
|
4
|
-
# https://github.com/quinlan-lab/hts-python
|
5
|
-
|
6
|
-
module HTS
|
7
|
-
class Tabix
|
8
|
-
class << self
|
9
|
-
alias open new
|
10
|
-
end
|
11
|
-
def initialize
|
12
|
-
# IO like API
|
13
|
-
if block_given?
|
14
|
-
begin
|
15
|
-
yield self
|
16
|
-
ensure
|
17
|
-
close
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def build; end
|
23
|
-
|
24
|
-
def sequences; end
|
25
|
-
|
26
|
-
# def __call__\
|
27
|
-
end
|
28
|
-
end
|