Class: HTS::Hts
- Inherits:
-
Object
- Object
- HTS::Hts
- Defined in:
- lib/hts/hts.rb
Instance Method Summary collapse
- #close ⇒ Object
- #closed? ⇒ Boolean
- #format ⇒ Object
- #format_version ⇒ Object
- #rewind ⇒ Object
- #seek(offset) ⇒ Object
- #struct ⇒ Object
- #tell ⇒ Object
- #to_ptr ⇒ Object
Instance Method Details
#close ⇒ Object
30 31 32 33 34 35 |
# File 'lib/hts/hts.rb', line 30 def close return if closed? LibHTS.hts_close(@hts_file) @hts_file = nil end |
#closed? ⇒ Boolean
37 38 39 |
# File 'lib/hts/hts.rb', line 37 def closed? @hts_file.nil? || @hts_file.null? end |
#format ⇒ Object
15 16 17 |
# File 'lib/hts/hts.rb', line 15 def format LibHTS.hts_get_format(@hts_file)[:format].to_s end |
#format_version ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/hts/hts.rb', line 19 def format_version v = LibHTS.hts_get_format(@hts_file)[:version] major = v[:major] minor = v[:minor] if minor == -1 major.to_s else "#{major}.#{minor}" end end |
#rewind ⇒ Object
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/hts/hts.rb', line 63 def rewind if @start_position r = seek(@start_position) raise "Failed to rewind: #{r}" if r < 0 tell else raise "Cannot rewind: no start position" end end |
#seek(offset) ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/hts/hts.rb', line 41 def seek(offset) if @hts_file[:is_cram] == 1 LibHTS.cram_seek(@hts_file[:fp][:cram], offset, IO::SEEK_SET) elsif @hts_file[:is_bgzf] == 1 LibHTS.bgzf_seek(@hts_file[:fp][:bgzf], offset, IO::SEEK_SET) else LibHTS.hseek(@hts_file[:fp][:hfile], offset, IO::SEEK_SET) end end |
#struct ⇒ Object
7 8 9 |
# File 'lib/hts/hts.rb', line 7 def struct @hts_file end |
#tell ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/hts/hts.rb', line 51 def tell if @hts_file[:is_cram] == 1 # LibHTS.cram_tell(@hts_file[:fp][:cram]) # warn 'cram_tell is not implemented in c htslib' nil elsif @hts_file[:is_bgzf] == 1 LibHTS.bgzf_tell(@hts_file[:fp][:bgzf]) else LibHTS.htell(@hts_file[:fp][:hfile]) end end |
#to_ptr ⇒ Object
11 12 13 |
# File 'lib/hts/hts.rb', line 11 def to_ptr @hts_file.to_ptr end |