htslib 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +31 -3
- data/lib/hts/bam.rb +74 -82
- data/lib/hts/bam/alignment.rb +156 -0
- data/lib/hts/bam/cigar.rb +30 -0
- data/lib/hts/bam/header.rb +27 -0
- data/lib/hts/fai.rb +9 -7
- data/lib/hts/ffi.rb +14 -3
- data/lib/hts/{ffi_constants.rb → ffi/constants.rb} +3 -1
- data/lib/hts/ffi/sam.rb +13 -3
- data/lib/hts/tbx.rb +8 -6
- data/lib/hts/vcf.rb +18 -16
- data/lib/hts/version.rb +1 -1
- data/lib/htslib.rb +13 -1
- metadata +27 -11
- data/lib/hts/ffi/struct.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c0c00377d4485fa702cc429c3005e98d1d095842d51fa6d27346fad9891c280
|
4
|
+
data.tar.gz: 56e680d3f890ef1df37f2d99644c13bde250a130ca46e5d6b756ca16366fe81e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a38ecbb819edb2f81e5b76250c8ef070bf5d252925fecb859a4083462a7934feefd8ac50b2628f9f3912915982354bd61d424224302b45e9e2911321469bba6
|
7
|
+
data.tar.gz: 01d5ac7826b5db6b6838986d05801b69c76320bbb4a89029cf21a6f01031c9bcc23c287526fbda02c8a2c0a32453e53ed6d689373754680c584f969214c58f6f
|
data/README.md
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
# HTSlib
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/htslib.svg)](https://badge.fury.io/rb/htslib)
|
4
|
-
![CI](https://github.com/kojix2/ruby-htslib/workflows/CI/badge.svg
|
4
|
+
![CI](https://github.com/kojix2/ruby-htslib/workflows/CI/badge.svg)
|
5
5
|
[![The MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.txt)
|
6
|
+
[![DOI](https://zenodo.org/badge/247078205.svg)](https://zenodo.org/badge/latestdoi/247078205)
|
7
|
+
|
8
|
+
:dna: [HTSlib](https://github.com/samtools/htslib) - high-throughput sequencing data manipulation - for Ruby
|
6
9
|
|
7
10
|
:apple: Feel free to fork it out if you can develop it!
|
8
11
|
|
@@ -26,6 +29,8 @@ export HTSLIBDIR="/your/path/to/htslib"
|
|
26
29
|
|
27
30
|
## Usage
|
28
31
|
|
32
|
+
HTS::FFI - Low-level API
|
33
|
+
|
29
34
|
```ruby
|
30
35
|
require 'htslib'
|
31
36
|
|
@@ -35,13 +40,36 @@ p b[:category]
|
|
35
40
|
p b[:format]
|
36
41
|
```
|
37
42
|
|
43
|
+
A high-level API based on [hts-python](https://github.com/quinlan-lab/hts-python) is under development.
|
44
|
+
|
45
|
+
## Documentation
|
46
|
+
|
47
|
+
* [RubyDoc.info - HTSlib](https://rdoc.info/gems/htslib)
|
48
|
+
|
38
49
|
## Development
|
39
50
|
|
51
|
+
To get started with development
|
52
|
+
|
53
|
+
```sh
|
54
|
+
git clone --recurse-submodules https://github.com/kojix2/ruby-htslib
|
55
|
+
cd ruby-htslib
|
56
|
+
bundle install
|
57
|
+
bundle exec rake htslib:compile
|
58
|
+
bundle exec rake spec
|
59
|
+
```
|
60
|
+
|
40
61
|
## Contributing
|
41
62
|
|
42
|
-
|
63
|
+
* [Report bugs](https://github.com/kojix2/ruby-htslib/issues)
|
64
|
+
* Fix bugs and [submit pull requests](https://github.com/kojix2/ruby-htslib/pulls)
|
65
|
+
* Write, clarify, or fix documentation
|
66
|
+
* Suggest or add new features
|
67
|
+
|
68
|
+
## Links
|
43
69
|
|
70
|
+
* [samtools/hts-spec](https://github.com/samtools/hts-specs)
|
71
|
+
* [c2ffi](https://github.com/rpav/c2ffi)
|
44
72
|
|
45
73
|
## License
|
46
74
|
|
47
|
-
|
75
|
+
[MIT License](https://opensource.org/licenses/MIT).
|
data/lib/hts/bam.rb
CHANGED
@@ -1,87 +1,79 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
3
|
+
# Based on hts-python
|
4
4
|
# https://github.com/quinlan-lab/hts-python
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
def flush; end
|
81
|
-
|
82
|
-
def to_s; end
|
83
|
-
|
84
|
-
def each; end
|
85
|
-
|
86
|
-
# def call
|
6
|
+
require_relative 'bam/header'
|
7
|
+
require_relative 'bam/cigar'
|
8
|
+
require_relative 'bam/alignment'
|
9
|
+
|
10
|
+
module HTS
|
11
|
+
class Bam
|
12
|
+
include Enumerable
|
13
|
+
attr_reader :fname, :mode, :header, :htf
|
14
|
+
|
15
|
+
def initialize(fname, mode = 'r', create_index: nil, header: nil, fasta: nil)
|
16
|
+
@fname = File.expand_path(fname)
|
17
|
+
File.exist?(@fname) || raise("No such SAM/BAM file - #{@fname}")
|
18
|
+
|
19
|
+
@mode = mode
|
20
|
+
@htf = FFI.hts_open(@fname, mode)
|
21
|
+
|
22
|
+
if mode[0] == 'r'
|
23
|
+
@idx = FFI.sam_index_load(@htf, @fname)
|
24
|
+
if (@idx.null? && create_index.nil?) || create_index
|
25
|
+
FFI.sam_index_build(fname, -1)
|
26
|
+
@idx = FFI.sam_index_load(@htf, @fname)
|
27
|
+
warn 'NO querying'
|
28
|
+
end
|
29
|
+
@header = Bam::Header.new(FFI.sam_hdr_read(@htf))
|
30
|
+
@b = FFI.bam_init1
|
31
|
+
|
32
|
+
else
|
33
|
+
# FIXME
|
34
|
+
raise 'not implemented yet.'
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.header_from_fasta; end
|
40
|
+
|
41
|
+
def write(alns)
|
42
|
+
alns.each do
|
43
|
+
FFI.sam_write1(@htf, @header, alns.b) > 0 || raise
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Close the current file.
|
48
|
+
def close
|
49
|
+
FFI.hts_close(@htf)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Flush the current file.
|
53
|
+
def flush
|
54
|
+
raise
|
55
|
+
# FFI.bgzf_flush(@htf.fp.bgzf)
|
56
|
+
end
|
57
|
+
|
58
|
+
def each(&block)
|
59
|
+
# Each does not always start at the beginning of the file.
|
60
|
+
# This is the common behavior of IO objects in Ruby.
|
61
|
+
# This may change in the future.
|
62
|
+
block.call(Alignment.new(@b, @header.h)) while FFI.sam_read1(@htf, @header.h, @b) > 0
|
63
|
+
end
|
64
|
+
|
65
|
+
# query [WIP]
|
66
|
+
def query(region)
|
67
|
+
qiter = FFI.sam_itr_querys(@idx, @header.h, region)
|
68
|
+
begin
|
69
|
+
slen = FFI.sam_itr_next(@htf, qiter, @b)
|
70
|
+
while slen > 0
|
71
|
+
yield Alignment.new(@b, @header.h)
|
72
|
+
slen = FFI.sam_itr_next(@htf, qiter, @b)
|
73
|
+
end
|
74
|
+
ensure
|
75
|
+
FFI.hts_itr_destroy(qiter)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
87
79
|
end
|
@@ -0,0 +1,156 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Based on hts-python
|
4
|
+
# https://github.com/quinlan-lab/hts-python
|
5
|
+
|
6
|
+
module HTS
|
7
|
+
# A cigar object usually created from `Alignment`.
|
8
|
+
class Bam
|
9
|
+
class Alignment
|
10
|
+
def initialize(bam1_t, bam_hdr_t)
|
11
|
+
@b = bam1_t
|
12
|
+
@h = bam_hdr_t
|
13
|
+
end
|
14
|
+
|
15
|
+
# def initialize_copy
|
16
|
+
# super
|
17
|
+
# end
|
18
|
+
|
19
|
+
def self.rom_sam_str; end
|
20
|
+
|
21
|
+
def tags; end
|
22
|
+
|
23
|
+
# Read (query) name.
|
24
|
+
def qname
|
25
|
+
FFI.bam_get_qname(@b).read_string
|
26
|
+
end
|
27
|
+
|
28
|
+
# Set (query) name.
|
29
|
+
# def qname=(name)
|
30
|
+
# raise 'Not Implemented'
|
31
|
+
# end
|
32
|
+
|
33
|
+
# returns the chromosome of the mate or '' if not mapped.
|
34
|
+
def mate_chrom
|
35
|
+
tid = @b[:core][:mtid]
|
36
|
+
return '' if tid == -1
|
37
|
+
|
38
|
+
FFI.sam_hdr_tid2name(@h, tid)
|
39
|
+
end
|
40
|
+
|
41
|
+
# returns the tid of the mate or -1 if not mapped.
|
42
|
+
def mate_tid
|
43
|
+
@b[:core][:mtid]
|
44
|
+
end
|
45
|
+
|
46
|
+
# returns the tid of the alignment or -1 if not mapped.
|
47
|
+
def tid
|
48
|
+
@b[:core][:tid]
|
49
|
+
end
|
50
|
+
|
51
|
+
# mate position
|
52
|
+
def mate_pos
|
53
|
+
@b[:core][:mpos]
|
54
|
+
end
|
55
|
+
|
56
|
+
# returns 0-based start position.
|
57
|
+
def start
|
58
|
+
@b[:core][:pos]
|
59
|
+
end
|
60
|
+
|
61
|
+
# returns end position of the read.
|
62
|
+
def stop
|
63
|
+
FFI.bam_endpos @b
|
64
|
+
end
|
65
|
+
|
66
|
+
# returns the chromosome or '' if not mapped.
|
67
|
+
def chrom
|
68
|
+
tid = @b[:core][:tid]
|
69
|
+
return '' if tid == -1
|
70
|
+
|
71
|
+
FFI.sam_hdr_tid2name(@h, tid)
|
72
|
+
end
|
73
|
+
|
74
|
+
def strand
|
75
|
+
FFI.bam_is_rev(@b) ? '-' : '+'
|
76
|
+
end
|
77
|
+
|
78
|
+
# def start=(v)
|
79
|
+
# raise 'Not Implemented'
|
80
|
+
# end
|
81
|
+
|
82
|
+
# insert size
|
83
|
+
def isize
|
84
|
+
@b[:core][:isize]
|
85
|
+
end
|
86
|
+
|
87
|
+
# mapping quality
|
88
|
+
def mapping_quality
|
89
|
+
@b[:core][:qual]
|
90
|
+
end
|
91
|
+
|
92
|
+
# returns a `Cigar` object.
|
93
|
+
def cigar
|
94
|
+
Cigar.new(FFI.bam_get_cigar(@b), @b[:core][:n_cigar])
|
95
|
+
end
|
96
|
+
|
97
|
+
def qlen
|
98
|
+
FFI.bam_cigar2qlen(
|
99
|
+
@b[:core][:n_cigar],
|
100
|
+
FFI.bam_get_cigar(@b)
|
101
|
+
)
|
102
|
+
end
|
103
|
+
|
104
|
+
def rlen
|
105
|
+
FFI.bam_cigar2rlen(
|
106
|
+
@b[:core][:n_cigar],
|
107
|
+
FFI.bam_get_cigar(@b)
|
108
|
+
)
|
109
|
+
end
|
110
|
+
|
111
|
+
# return the read sequence
|
112
|
+
def sequence
|
113
|
+
seq_nt16_str = '=ACMGRSVTWYHKDBN'
|
114
|
+
r = FFI.bam_get_seq(@b)
|
115
|
+
Array.new(@b[:core][:l_qseq]) do |i|
|
116
|
+
seq_nt16_str[FFI.bam_seqi(r, i)]
|
117
|
+
end.join
|
118
|
+
end
|
119
|
+
|
120
|
+
def base_at(n)
|
121
|
+
n += @b[:core][:l_qseq] if n < 0
|
122
|
+
seq_nt16_str = '=ACMGRSVTWYHKDBN'
|
123
|
+
return '.' if (n >= @b[:core][:l_qseq]) || (n < 0) # eg. base_at(-1000)
|
124
|
+
|
125
|
+
r = FFI.bam_get_seq(@b)
|
126
|
+
seq_nt16_str[FFI.bam_seqi(r, n)]
|
127
|
+
end
|
128
|
+
|
129
|
+
def base_qualities
|
130
|
+
q_ptr = FFI.bam_get_qual(@b)
|
131
|
+
q_ptr.read_array_of_uint8(@b[:core][:l_qseq])
|
132
|
+
end
|
133
|
+
|
134
|
+
def base_quality_at(n)
|
135
|
+
n += @b[:core][:l_qseq] if n < 0 # eg. base_quality_at(-1000)
|
136
|
+
return 0 if (n >= @b[:core][:l_qseq]) || (n < 0)
|
137
|
+
|
138
|
+
q_ptr = FFI.bam_get_qual(@b)
|
139
|
+
q_ptr.get_uint8(n)
|
140
|
+
end
|
141
|
+
|
142
|
+
def flag_str
|
143
|
+
FFI.bam_flag2str(flag)
|
144
|
+
end
|
145
|
+
|
146
|
+
# returns a `Flag` object.
|
147
|
+
def flag
|
148
|
+
@b[:core][:flag]
|
149
|
+
end
|
150
|
+
|
151
|
+
# TODO:
|
152
|
+
# def eql?
|
153
|
+
# def hash
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
@@ -0,0 +1,30 @@
|
|
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 Bam
|
8
|
+
class Cigar
|
9
|
+
include Enumerable
|
10
|
+
OPS = 'MIDNSHP=XB'
|
11
|
+
|
12
|
+
def initialize(cigar, n_cigar)
|
13
|
+
@c = cigar
|
14
|
+
@n_cigar = n_cigar
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_s
|
18
|
+
to_a.flatten.join
|
19
|
+
end
|
20
|
+
|
21
|
+
def each
|
22
|
+
@n_cigar.times do |i|
|
23
|
+
c = @c[i].read_uint32
|
24
|
+
yield [FFI.bam_cigar_oplen(c),
|
25
|
+
FFI.bam_cigar_opchr(c)]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,27 @@
|
|
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 Bam
|
8
|
+
class Header
|
9
|
+
attr_reader :h
|
10
|
+
|
11
|
+
def initialize(h)
|
12
|
+
@h = h
|
13
|
+
end
|
14
|
+
|
15
|
+
# FIXME: better name?
|
16
|
+
def seqs
|
17
|
+
Array.new(@h[:n_targets]) do |i|
|
18
|
+
FFI.sam_hdr_tid2name(@h, i)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def text
|
23
|
+
FFI.sam_hdr_str(@h)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/hts/fai.rb
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
3
|
+
# Based on hts-python
|
4
4
|
# https://github.com/quinlan-lab/hts-python
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
module HTS
|
7
|
+
class Fai
|
8
|
+
def initialize; end
|
8
9
|
|
9
|
-
|
10
|
+
# def call
|
10
11
|
|
11
|
-
|
12
|
+
def nseqs; end
|
12
13
|
|
13
|
-
|
14
|
+
def include?; end
|
14
15
|
|
15
|
-
|
16
|
+
# __iter__
|
17
|
+
end
|
16
18
|
end
|
data/lib/hts/ffi.rb
CHANGED
@@ -7,7 +7,7 @@ module HTS
|
|
7
7
|
begin
|
8
8
|
ffi_lib HTS.ffi_lib
|
9
9
|
rescue LoadError => e
|
10
|
-
raise LoadError, "
|
10
|
+
raise LoadError, "#{e}\nCould not find #{HTS.ffi_lib}"
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.attach_function(*)
|
@@ -18,8 +18,19 @@ module HTS
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
|
21
|
+
module FFI
|
22
|
+
class Struct
|
23
|
+
def self.union_layout(*args)
|
24
|
+
Class.new(FFI::Union) { layout(*args) }
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.struct_layout(*args)
|
28
|
+
Class.new(FFI::Struct) { layout(*args) }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
require_relative 'ffi/constants'
|
23
34
|
|
24
35
|
# alphabetical order
|
25
36
|
require_relative 'ffi/bgzf'
|
@@ -141,7 +141,8 @@ module HTS
|
|
141
141
|
)
|
142
142
|
end
|
143
143
|
|
144
|
-
|
144
|
+
# HtsFile
|
145
|
+
class SamHdr < ::FFI::Struct
|
145
146
|
layout \
|
146
147
|
:n_targets, :int32,
|
147
148
|
:ignore_sam_err, :int32,
|
@@ -225,6 +226,7 @@ module HTS
|
|
225
226
|
:a, :pointer
|
226
227
|
)
|
227
228
|
end
|
229
|
+
|
228
230
|
class Bam1Core < ::FFI::Struct
|
229
231
|
layout \
|
230
232
|
:pos, :hts_pos_t,
|
data/lib/hts/ffi/sam.rb
CHANGED
@@ -12,8 +12,8 @@ module HTS
|
|
12
12
|
c >> BAM_CIGAR_SHIFT
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
16
|
-
|
15
|
+
def bam_cigar_opchr(c)
|
16
|
+
(BAM_CIGAR_STR + '??????')[bam_cigar_op(c)]
|
17
17
|
end
|
18
18
|
|
19
19
|
def bam_cigar_gen(l, o)
|
@@ -60,7 +60,9 @@ module HTS
|
|
60
60
|
b[:l_data] - (b[:core][:n_cigar] << 2) - b[:core][:l_qname] - b[:core][:l_qseq] - ((b[:core][:l_qseq] + 1) >> 1)
|
61
61
|
end
|
62
62
|
|
63
|
-
|
63
|
+
def bam_seqi(s, i)
|
64
|
+
s[(i) >> 1].read_uint8 >> ((~i & 1) << 2) & 0xf
|
65
|
+
end
|
64
66
|
|
65
67
|
# def bam_set_seqi(s, i, b)
|
66
68
|
end
|
@@ -405,6 +407,14 @@ module HTS
|
|
405
407
|
[HtsIdx, SamHdr, :pointer, :uint],
|
406
408
|
HtsItr.by_ref
|
407
409
|
|
410
|
+
# Get the next read from a SAM/BAM/CRAM iterator
|
411
|
+
def self.sam_itr_next(htsfp, itr, r)
|
412
|
+
# FIXME: check if htsfp is compressed BGZF
|
413
|
+
hts_log_error('Null iterator') if itr.null?
|
414
|
+
# FIXME: check multi
|
415
|
+
hts_itr_next(htsfp[:fp][:bgzf], itr, r, htsfp)
|
416
|
+
end
|
417
|
+
|
408
418
|
attach_function \
|
409
419
|
:sam_parse_region,
|
410
420
|
[SamHdr, :string, :pointer, :pointer, :pointer, :int],
|
data/lib/hts/tbx.rb
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
3
|
+
# Based on hts-python
|
4
4
|
# https://github.com/quinlan-lab/hts-python
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
module HTS
|
7
|
+
class Tbx
|
8
|
+
def initialize; end
|
8
9
|
|
9
|
-
|
10
|
+
def build; end
|
10
11
|
|
11
|
-
|
12
|
+
def sequences; end
|
12
13
|
|
13
|
-
|
14
|
+
# def __call__\
|
15
|
+
end
|
14
16
|
end
|
data/lib/hts/vcf.rb
CHANGED
@@ -1,30 +1,32 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
3
|
+
# Based on hts-python
|
4
4
|
# https://github.com/quinlan-lab/hts-python
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
module HTS
|
7
|
+
class VCF
|
8
|
+
def initialize; end
|
8
9
|
|
9
|
-
|
10
|
+
def inspect; end
|
10
11
|
|
11
|
-
|
12
|
+
def each; end
|
12
13
|
|
13
|
-
|
14
|
+
def seq; end
|
14
15
|
|
15
|
-
|
16
|
-
end
|
16
|
+
def n_samples; end
|
17
|
+
end
|
17
18
|
|
18
|
-
class Variant
|
19
|
-
|
19
|
+
class Variant
|
20
|
+
def initialize; end
|
20
21
|
|
21
|
-
|
22
|
+
def inspect; end
|
22
23
|
|
23
|
-
|
24
|
+
def formats; end
|
24
25
|
|
25
|
-
|
26
|
-
end
|
26
|
+
def genotypes; end
|
27
|
+
end
|
27
28
|
|
28
|
-
class Format
|
29
|
-
|
29
|
+
class Format
|
30
|
+
def initialize; end
|
31
|
+
end
|
30
32
|
end
|
data/lib/hts/version.rb
CHANGED
data/lib/htslib.rb
CHANGED
@@ -10,9 +10,21 @@ module HTS
|
|
10
10
|
class << self
|
11
11
|
attr_accessor :ffi_lib
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
|
+
suffix = ::FFI::Platform::LIBSUFFIX
|
15
|
+
|
16
|
+
self.ffi_lib = if ENV['HTSLIBDIR']
|
17
|
+
File.expand_path("libhts.#{suffix}", ENV['HTSLIBDIR'])
|
18
|
+
else
|
19
|
+
File.expand_path("../vendor/libhts.#{suffix}", __dir__)
|
20
|
+
end
|
14
21
|
autoload :FFI, 'hts/ffi'
|
15
22
|
end
|
16
23
|
|
17
24
|
# alias
|
18
25
|
HTSlib = HTS
|
26
|
+
|
27
|
+
require_relative 'hts/bam'
|
28
|
+
require_relative 'hts/fai'
|
29
|
+
require_relative 'hts/tbx'
|
30
|
+
require_relative 'hts/vcf'
|
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.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kojix2
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: pry
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,7 +81,7 @@ dependencies:
|
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
84
|
+
name: rubocop
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
87
|
- - ">="
|
@@ -81,7 +95,7 @@ dependencies:
|
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
98
|
+
name: simplecov
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
101
|
- - ">="
|
@@ -94,7 +108,7 @@ dependencies:
|
|
94
108
|
- - ">="
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '0'
|
97
|
-
description:
|
111
|
+
description:
|
98
112
|
email:
|
99
113
|
- 2xijok@gmail.com
|
100
114
|
executables: []
|
@@ -104,18 +118,20 @@ files:
|
|
104
118
|
- LICENSE.txt
|
105
119
|
- README.md
|
106
120
|
- lib/hts/bam.rb
|
121
|
+
- lib/hts/bam/alignment.rb
|
122
|
+
- lib/hts/bam/cigar.rb
|
123
|
+
- lib/hts/bam/header.rb
|
107
124
|
- lib/hts/fai.rb
|
108
125
|
- lib/hts/ffi.rb
|
109
126
|
- lib/hts/ffi/bgzf.rb
|
127
|
+
- lib/hts/ffi/constants.rb
|
110
128
|
- lib/hts/ffi/faidx.rb
|
111
129
|
- lib/hts/ffi/hfile.rb
|
112
130
|
- lib/hts/ffi/hts.rb
|
113
131
|
- lib/hts/ffi/kfunc.rb
|
114
132
|
- lib/hts/ffi/sam.rb
|
115
|
-
- lib/hts/ffi/struct.rb
|
116
133
|
- lib/hts/ffi/tbx.rb
|
117
134
|
- lib/hts/ffi/vcf.rb
|
118
|
-
- lib/hts/ffi_constants.rb
|
119
135
|
- lib/hts/tbx.rb
|
120
136
|
- lib/hts/vcf.rb
|
121
137
|
- lib/hts/version.rb
|
@@ -124,7 +140,7 @@ homepage: https://github.com/kojix2/ruby-htslib
|
|
124
140
|
licenses:
|
125
141
|
- MIT
|
126
142
|
metadata: {}
|
127
|
-
post_install_message:
|
143
|
+
post_install_message:
|
128
144
|
rdoc_options: []
|
129
145
|
require_paths:
|
130
146
|
- lib
|
@@ -139,8 +155,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
155
|
- !ruby/object:Gem::Version
|
140
156
|
version: '0'
|
141
157
|
requirements: []
|
142
|
-
rubygems_version: 3.
|
143
|
-
signing_key:
|
158
|
+
rubygems_version: 3.0.3
|
159
|
+
signing_key:
|
144
160
|
specification_version: 4
|
145
161
|
summary: HTSlib bindings for Ruby
|
146
162
|
test_files: []
|
data/lib/hts/ffi/struct.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# This should be removed if you get the better way...
|
4
|
-
module FFI
|
5
|
-
class Struct
|
6
|
-
def self.union_layout(*args)
|
7
|
-
Class.new(FFI::Union) { layout(*args) }
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.struct_layout(*args)
|
11
|
-
Class.new(FFI::Struct) { layout(*args) }
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|