Class: HTS::Bam::Cigar
- Inherits:
-
Object
- Object
- HTS::Bam::Cigar
- Includes:
- Enumerable
- Defined in:
- lib/hts/bam/cigar.rb
Constant Summary collapse
- OP_CHARS =
"MIDNSHP=XB"
Instance Attribute Summary collapse
-
#array ⇒ Object
Returns the value of attribute array.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #each ⇒ Object
- #eql?(other) ⇒ Boolean
-
#initialize(record = nil) ⇒ Cigar
constructor
A new instance of Cigar.
- #qlen ⇒ Object
- #rlen ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(record = nil) ⇒ Cigar
Returns a new instance of Cigar.
15 16 17 |
# File 'lib/hts/bam/cigar.rb', line 15 def initialize(record = nil) @array = record ? record.__send__(:native_handle).cigar_values : [] end |
Instance Attribute Details
#array ⇒ Object
Returns the value of attribute array.
9 10 11 |
# File 'lib/hts/bam/cigar.rb', line 9 def array @array end |
Class Method Details
.parse(str) ⇒ Object
11 12 13 |
# File 'lib/hts/bam/cigar.rb', line 11 def self.parse(str) new.tap { |cigar| cigar.array = Native.cigar_parse(str.to_s) } end |
Instance Method Details
#==(other) ⇒ Object
29 |
# File 'lib/hts/bam/cigar.rb', line 29 def ==(other) = other.is_a?(Cigar) && @array == other.array |
#each ⇒ Object
21 22 23 24 25 |
# File 'lib/hts/bam/cigar.rb', line 21 def each return to_enum(__method__) unless block_given? @array.each { |encoded| yield OP_CHARS[encoded & 15], encoded >> 4 } end |
#eql?(other) ⇒ Boolean
30 |
# File 'lib/hts/bam/cigar.rb', line 30 def eql?(other) = other.is_a?(Cigar) && @array.eql?(other.array) |
#qlen ⇒ Object
27 |
# File 'lib/hts/bam/cigar.rb', line 27 def qlen = Native.cigar_qlen(@array) |
#rlen ⇒ Object
28 |
# File 'lib/hts/bam/cigar.rb', line 28 def rlen = Native.cigar_rlen(@array) |
#to_s ⇒ Object
19 |
# File 'lib/hts/bam/cigar.rb', line 19 def to_s = map { |op, len| "#{len}#{op}" }.join |