Class: HTS::Tbx
Instance Attribute Summary collapse
-
#file_name ⇒ Object
readonly
Returns the value of attribute file_name.
-
#index_name ⇒ Object
readonly
Returns the value of attribute index_name.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#nthreads ⇒ Object
readonly
Returns the value of attribute nthreads.
Class Method Summary collapse
Instance Method Summary collapse
- #build_index ⇒ Object
-
#initialize(file_name, mode = "r", index: nil, threads: nil, build_index: false) ⇒ Tbx
constructor
A new instance of Tbx.
- #load_index(index_name = nil) ⇒ Object
- #seqnames ⇒ Object
- #tid(name) ⇒ Object
Methods inherited from Hts
#close, #closed?, #file_format, #file_format_version, #rewind, #seek, #set_threads, #struct, #tell, #to_ptr
Constructor Details
#initialize(file_name, mode = "r", index: nil, threads: nil, build_index: false) ⇒ Tbx
Returns a new instance of Tbx.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/hts/tbx.rb', line 25 def initialize(file_name, mode = "r", index: nil, threads: nil, build_index: false) if block_given? = "HTS::Tbx.new() dose not take block; Please use HTS::Tbx.open() instead" raise end # NOTE: Do not check for the existence of local files, since file_names may be remote URIs. @file_name = file_name @index_name = index @mode = mode @nthreads = threads @hts_file = LibHTS.hts_open(@file_name, @mode) raise Errno::ENOENT, "Failed to open #{@file_name}" if @hts_file.null? set_threads(threads) if threads # return if @mode[0] == "w" raise "Not implemented" if @mode[0] == "w" # build_index(index) if build_index @idx = load_index(index) end |
Instance Attribute Details
#file_name ⇒ Object (readonly)
Returns the value of attribute file_name.
11 12 13 |
# File 'lib/hts/tbx.rb', line 11 def file_name @file_name end |
#index_name ⇒ Object (readonly)
Returns the value of attribute index_name.
11 12 13 |
# File 'lib/hts/tbx.rb', line 11 def index_name @index_name end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
11 12 13 |
# File 'lib/hts/tbx.rb', line 11 def mode @mode end |
#nthreads ⇒ Object (readonly)
Returns the value of attribute nthreads.
11 12 13 |
# File 'lib/hts/tbx.rb', line 11 def nthreads @nthreads end |
Class Method Details
.open(*args, **kw) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/hts/tbx.rb', line 13 def self.open(*args, **kw) file = new(*args, **kw) # do not yield return file unless block_given? begin yield file ensure file.close end file end |
Instance Method Details
#build_index ⇒ Object
50 51 52 |
# File 'lib/hts/tbx.rb', line 50 def build_index raise "Not implemented yet" end |
#load_index(index_name = nil) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/hts/tbx.rb', line 54 def load_index(index_name = nil) if index_name LibHTS.tbx_index_load2(@file_name, index_name) else LibHTS.tbx_index_load3(@file_name, nil, 2) end end |
#seqnames ⇒ Object
66 67 68 69 70 71 |
# File 'lib/hts/tbx.rb', line 66 def seqnames nseq = FFI::MemoryPointer.new(:int) LibHTS.tbx_seqnames(@idx, nseq).then do |pts| pts.read_array_of_pointer(nseq.read_int).map(&:read_string) end end |
#tid(name) ⇒ Object
62 63 64 |
# File 'lib/hts/tbx.rb', line 62 def tid(name) LibHTS.tbx_name2id(@idx, name) end |