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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c4cf91042ebfca63fa53176e80b71d93e0a3deb8938edbeccb306ac66b2f4d9b
4
+ data.tar.gz: 33ef01ac381c684c1da7ef03e12043164c70e58849e03c97d7fd9f89f19382c7
5
+ SHA512:
6
+ metadata.gz: a0334a54d5e96243652ded099b6d07352f6a145e01dbb7853a0a00f1e040ac5175f0f95c4262600bb4e76ea282e1d283ff12b1b44e54f8d75f1a206a6f5ca319
7
+ data.tar.gz: 006b404fa6a9a05a316bd214bf4a3b737d46a8cc6e9b3fd05772e3547b03960e254bc3aad5d04d26ce741709e8926e6d57eca4a396b345cfe5165646d28a6a11
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 kojix2
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,45 @@
1
+ # HTSlib
2
+
3
+ ![CI](https://github.com/kojix2/ruby-htslib/workflows/CI/badge.svg?branch=master)
4
+
5
+ :apple: Feel free to fork it out if you can develop it!
6
+
7
+ :bowtie: Just a prototype.
8
+
9
+ ## Installation
10
+
11
+ ```sh
12
+ gem install htslib
13
+ ```
14
+
15
+ Set environment variable HTSLIBDIR.
16
+
17
+ ```sh
18
+ export HTSLIBDIR="/your/path/to/htslib"
19
+ ```
20
+
21
+ ## Requirements
22
+
23
+ * [htslib](https://github.com/samtools/htslib)
24
+
25
+ ## Usage
26
+
27
+ ```ruby
28
+ require 'htslib'
29
+
30
+ a = HTS::FFI.hts_open("a.bam", "r")
31
+ b = HTS::FFI.hts_get_format(a)
32
+ p b[:category]
33
+ p b[:format]
34
+ ```
35
+
36
+ ## Development
37
+
38
+ ## Contributing
39
+
40
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kojix2/ruby-htslib.
41
+
42
+
43
+ ## License
44
+
45
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,85 @@
1
+ # Create a skeleton using hts-python as a reference.
2
+ # https://github.com/quinlan-lab/hts-python
3
+
4
+ class BamHeader
5
+ def initialize; end
6
+
7
+ def seqs; end
8
+ end
9
+
10
+ class Cigar
11
+ def initialize; end
12
+
13
+ def to_s; end
14
+
15
+ def inspect; end
16
+ end
17
+
18
+ class Alignment
19
+ def initialize; end
20
+
21
+ def self.rom_sam_str; end
22
+
23
+ def tags; end
24
+
25
+ def qname; end
26
+
27
+ def qname=; end
28
+
29
+ def rnext; end
30
+
31
+ def pnext; end
32
+
33
+ def rname; end
34
+
35
+ def strand; end
36
+
37
+ def base_qualities; end
38
+
39
+ def pos; end
40
+
41
+ def pos=; end
42
+
43
+ def isize; end
44
+
45
+ def mapping_quality; end
46
+
47
+ def cigar; end
48
+
49
+ def qlen; end
50
+
51
+ def rlen; end
52
+
53
+ def seqs; end
54
+
55
+ def flag_str; end
56
+
57
+ def flag; end
58
+
59
+ # def eql?
60
+ # def hash
61
+
62
+ def inspect; end
63
+
64
+ def to_s; end
65
+ end
66
+
67
+ class Bam
68
+ def initialize; end
69
+
70
+ def self.header_from_fasta; end
71
+
72
+ def inspect; end
73
+
74
+ def write; end
75
+
76
+ def close; end
77
+
78
+ def flush; end
79
+
80
+ def to_s; end
81
+
82
+ def each; end
83
+
84
+ # def call
85
+ end
@@ -0,0 +1,14 @@
1
+ # Create a skeleton using hts-python as a reference.
2
+ # https://github.com/quinlan-lab/hts-python
3
+
4
+ class Fai
5
+ def initialize; end
6
+
7
+ # def call
8
+
9
+ def nseqs; end
10
+
11
+ def include?; end
12
+
13
+ # __iter__
14
+ end
@@ -0,0 +1,31 @@
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, "Could not find HTSlib.#{FFI::Platform::LIBSUFFIX}"
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
+ require_relative 'ffi/struct'
22
+ require_relative 'ffi_constants'
23
+
24
+ # alphabetical order
25
+ require_relative 'ffi/bgzf'
26
+ require_relative 'ffi/faidx'
27
+ require_relative 'ffi/hfile'
28
+ require_relative 'ffi/hts'
29
+ require_relative 'ffi/sam'
30
+ require_relative 'ffi/kfunc'
31
+ require_relative 'ffi/tbx'
@@ -0,0 +1,192 @@
1
+ # BGZF
2
+ module HTS
3
+ module FFI
4
+ # Open an existing file descriptor for reading or writing.
5
+ attach_function \
6
+ :bgzf_dopen,
7
+ %i[int string],
8
+ BGZF.by_ref
9
+
10
+ # Open the specified file for reading or writing.
11
+ attach_function \
12
+ :bgzf_open,
13
+ %i[string string],
14
+ BGZF.by_ref
15
+
16
+ # Open an existing hFILE stream for reading or writing.
17
+ attach_function \
18
+ :bgzf_hopen,
19
+ %i[HFILE string],
20
+ BGZF.by_ref
21
+
22
+ # Close the BGZF and free all associated resources.
23
+ attach_function \
24
+ :bgzf_close,
25
+ [:HFILE],
26
+ :int
27
+
28
+ # Read up to _length_ bytes from the file storing into _data_.
29
+ attach_function \
30
+ :bgzf_read,
31
+ %i[HFILE pointer size_t],
32
+ :ssize_t
33
+
34
+ # Write _length_ bytes from _data_ to the file. If no I/O errors occur,
35
+ # the complete _length_ bytes will be written (or queued for writing).
36
+ attach_function \
37
+ :bgzf_write,
38
+ [BGZF, :pointer, :size_t],
39
+ :ssize_t
40
+
41
+ # Write _length_ bytes from _data_ to the file, the index will be used to
42
+ # decide the amount of uncompressed data to be writen to each bgzip block.
43
+ attach_function \
44
+ :bgzf_block_write,
45
+ [BGZF, :pointer, :size_t],
46
+ :ssize_t
47
+
48
+ # Returns the next byte in the file without consuming it.
49
+ attach_function \
50
+ :bgzf_peek,
51
+ [BGZF],
52
+ :int
53
+
54
+ # Read up to _length_ bytes directly from the underlying stream without
55
+ # decompressing. Bypasses BGZF blocking, so must be used with care in
56
+ # specialised circumstances only.
57
+ attach_function \
58
+ :bgzf_raw_read,
59
+ [BGZF, :pointer, :size_t],
60
+ :ssize_t
61
+
62
+ # Write _length_ bytes directly to the underlying stream without
63
+ # compressing. Bypasses BGZF blocking, so must be used with care
64
+ # in specialised circumstances only.
65
+ attach_function \
66
+ :bgzf_raw_write,
67
+ [BGZF, :pointer, :size_t],
68
+ :ssize_t
69
+
70
+ # Write the data in the buffer to the file.
71
+ attach_function \
72
+ :bgzf_flush,
73
+ [BGZF],
74
+ :int
75
+
76
+ # Set the file to read from the location specified by _pos_.
77
+ attach_function \
78
+ :bgzf_seek,
79
+ [BGZF, :int64, :int],
80
+ :int64
81
+
82
+ # Check if the BGZF end-of-file (EOF) marker is present
83
+ attach_function \
84
+ :bgzf_check_EOF,
85
+ [BGZF],
86
+ :int
87
+
88
+ # Return the file's compression format
89
+ attach_function \
90
+ :bgzf_compression,
91
+ [BGZF],
92
+ :int
93
+
94
+ # Check if a file is in the BGZF format
95
+ attach_function \
96
+ :bgzf_is_bgzf,
97
+ [:string],
98
+ :int
99
+
100
+ # Set the cache size. Only effective when compiled with -DBGZF_CACHE.
101
+ attach_function \
102
+ :bgzf_set_cache_size,
103
+ [BGZF, :int],
104
+ :void
105
+
106
+ # Flush the file if the remaining buffer size is smaller than _size_
107
+ attach_function \
108
+ :bgzf_flush_try,
109
+ [BGZF, :ssize_t],
110
+ :int
111
+
112
+ # Read one byte from a BGZF file. It is faster than bgzf_read()
113
+ attach_function \
114
+ :bgzf_getc,
115
+ [BGZF],
116
+ :int
117
+
118
+ # Read one line from a BGZF file. It is faster than bgzf_getc()
119
+ attach_function \
120
+ :bgzf_getline,
121
+ [BGZF, :int, Kstring],
122
+ :int
123
+
124
+ # Read the next BGZF block.
125
+ attach_function \
126
+ :bgzf_read_block,
127
+ [BGZF],
128
+ :int
129
+
130
+ # Enable multi-threading (when compiled with -DBGZF_MT) via a shared
131
+ # thread pool.
132
+ attach_function \
133
+ :bgzf_thread_pool,
134
+ [BGZF, :pointer, :int],
135
+ :int
136
+
137
+ # Enable multi-threading (only effective when the library was compiled
138
+ # with -DBGZF_MT)
139
+ attach_function \
140
+ :bgzf_mt,
141
+ [BGZF, :int, :int],
142
+ :int
143
+
144
+ # Compress a single BGZF block.
145
+ attach_function \
146
+ :bgzf_compress,
147
+ %i[pointer pointer pointer size_t int],
148
+ :int
149
+
150
+ # Position BGZF at the uncompressed offset
151
+ attach_function \
152
+ :bgzf_useek,
153
+ [BGZF, :off_t, :int],
154
+ :int
155
+
156
+ # Position in uncompressed BGZF
157
+ attach_function \
158
+ :bgzf_utell,
159
+ [BGZF],
160
+ :off_t
161
+
162
+ # Tell BGZF to build index while compressing.
163
+ attach_function \
164
+ :bgzf_index_build_init,
165
+ [BGZF],
166
+ :int
167
+
168
+ # Load BGZF index
169
+ attach_function \
170
+ :bgzf_index_load,
171
+ [BGZF, :string, :string],
172
+ :int
173
+
174
+ # Load BGZF index from an hFILE
175
+ attach_function \
176
+ :bgzf_index_load_hfile,
177
+ [BGZF, :HFILE, :string],
178
+ :int
179
+
180
+ # Save BGZF index
181
+ attach_function \
182
+ :bgzf_index_dump,
183
+ [BGZF, :string, :string],
184
+ :int
185
+
186
+ # Write a BGZF index to an hFILE
187
+ attach_function \
188
+ :bgzf_index_dump_hfile,
189
+ [BGZF, :HFILE, :string],
190
+ :int
191
+ end
192
+ end
@@ -0,0 +1,139 @@
1
+ module HTS
2
+ module FFI
3
+ # Build index for a FASTA or FASTQ or bgzip-compressed FASTA or FASTQ file.
4
+ attach_function \
5
+ :fai_build3,
6
+ %i[string string string],
7
+ :int
8
+
9
+ # Build index for a FASTA or FASTQ or bgzip-compressed FASTA or FASTQ file.
10
+ attach_function \
11
+ :fai_build,
12
+ [:string],
13
+ :int
14
+
15
+ # Destroy a faidx_t struct
16
+ attach_function \
17
+ :fai_destroy,
18
+ [Faidx],
19
+ :void
20
+
21
+ # Load FASTA indexes.
22
+ attach_function \
23
+ :fai_load3,
24
+ %i[string string string int],
25
+ Faidx.by_ref
26
+
27
+ # Load index from "fn.fai".
28
+ attach_function \
29
+ :fai_load,
30
+ [:string],
31
+ Faidx.by_ref
32
+
33
+ # Load FASTA or FASTQ indexes.
34
+ attach_function \
35
+ :fai_load3_format,
36
+ [:string, :string, :string, :int, FaiFormatOptions],
37
+ Faidx.by_ref
38
+
39
+ # Load index from "fn.fai".
40
+ attach_function \
41
+ :fai_load_format,
42
+ [:string, FaiFormatOptions],
43
+ Faidx.by_ref
44
+
45
+ # Fetch the sequence in a region
46
+ attach_function \
47
+ :fai_fetch,
48
+ [Faidx, :string, :pointer],
49
+ :string
50
+
51
+ # Fetch the sequence in a region
52
+ attach_function \
53
+ :fai_fetch64,
54
+ [Faidx, :string, :pointer],
55
+ :string
56
+
57
+ # Fetch the quality string for a region for FASTQ files
58
+ attach_function \
59
+ :fai_fetchqual,
60
+ [Faidx, :string, :pointer],
61
+ :string
62
+
63
+ attach_function \
64
+ :fai_fetchqual64,
65
+ [Faidx, :string, :pointer],
66
+ :string
67
+
68
+ # Fetch the number of sequences
69
+ attach_function \
70
+ :faidx_fetch_nseq,
71
+ [Faidx],
72
+ :int
73
+
74
+ # Fetch the sequence in a region
75
+ attach_function \
76
+ :faidx_fetch_seq,
77
+ [Faidx, :string, :int, :int, :pointer],
78
+ :string
79
+
80
+ # Fetch the sequence in a region
81
+ attach_function \
82
+ :faidx_fetch_seq64,
83
+ [Faidx, :string, :int64, :int64, :pointer],
84
+ :string
85
+
86
+ # Fetch the quality string in a region for FASTQ files
87
+ attach_function \
88
+ :faidx_fetch_qual,
89
+ [Faidx, :string, :int, :int, :pointer],
90
+ :string
91
+
92
+ # Fetch the quality string in a region for FASTQ files
93
+ attach_function \
94
+ :faidx_fetch_qual64,
95
+ [Faidx, :string, :int64, :int64, :pointer],
96
+ :string
97
+
98
+ # Query if sequence is present
99
+ attach_function \
100
+ :faidx_has_seq,
101
+ [Faidx, :string],
102
+ :int
103
+
104
+ # Return number of sequences in fai index
105
+ attach_function \
106
+ :faidx_nseq,
107
+ [Faidx],
108
+ :int
109
+
110
+ # Return name of i-th sequence
111
+ attach_function \
112
+ :faidx_iseq,
113
+ [Faidx, :int],
114
+ :string
115
+
116
+ # Return sequence length, -1 if not present
117
+ attach_function \
118
+ :faidx_seq_len,
119
+ [Faidx, :string],
120
+ :int
121
+
122
+ # Parses a region string.
123
+ attach_function \
124
+ :fai_parse_region,
125
+ [Faidx, :string, :pointer, :pointer, :pointer, :int], :string
126
+
127
+ # Sets the cache size of the underlying BGZF compressed file
128
+ attach_function \
129
+ :fai_set_cache_size,
130
+ [Faidx, :int],
131
+ :void
132
+
133
+ # Determines the path to the reference index file
134
+ attach_function \
135
+ :fai_path,
136
+ [:string],
137
+ :string
138
+ end
139
+ end