Class: RGFA::CIGAR::Operation

Inherits:
Object
  • Object
show all
Defined in:
lib/rgfa/cigar.rb

Overview

An operation in a CIGAR string

Constant Summary collapse

CODE =

CIGAR operation code

[:M, :I, :D, :N, :S, :H, :P, :X, :"="]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(len, code) ⇒ Operation

Returns a new instance of Operation.

Parameters:



102
103
104
105
# File 'lib/rgfa/cigar.rb', line 102

def initialize(len, code)
  @len = len
  @code = code
end

Instance Attribute Details

#codeObject

Returns the value of attribute code.



95
96
97
# File 'lib/rgfa/cigar.rb', line 95

def code
  @code
end

#lenObject

Returns the value of attribute len.



94
95
96
# File 'lib/rgfa/cigar.rb', line 94

def len
  @len
end

Instance Method Details

#==(other) ⇒ Boolean

Compare two operations

Returns:

  • (Boolean)


115
116
117
# File 'lib/rgfa/cigar.rb', line 115

def ==(other)
  other.len == len and other.code == code
end

#to_cigar_operationRGFA::CIGAR::Operation

Returns self.

Returns:



131
132
133
# File 'lib/rgfa/cigar.rb', line 131

def to_cigar_operation
  self
end

#to_sString

The string representation of the operation

Returns:



109
110
111
# File 'lib/rgfa/cigar.rb', line 109

def to_s
  "#{len}#{code}"
end

#validate!void

This method returns an undefined value.

Validate the operation

Raises:



123
124
125
126
127
128
# File 'lib/rgfa/cigar.rb', line 123

def validate!
  if Integer(len) <= 0 or
       !RGFA::CIGAR::Operation::CODE.include?(code)
    raise RGFA::CIGAR::ValueError
  end
end