Class: SSW::Align
- Inherits:
-
Object
- Object
- SSW::Align
- Defined in:
- lib/ssw/align.rb
Overview
structure of the alignment result
Instance Attribute Summary collapse
-
#cigar ⇒ Array
readonly
Best alignment cigar; stored the same as that in BAM format, high 28 bits: length, low 4 bits: M/I/D (0/1/2); cigar = 0 when the best alignment path is not available.
-
#cigar_len ⇒ Integer
Length of the cigar string; cigarLen = 0 when the best alignment path is not available.
-
#cigar_string ⇒ String
Cigar string.
-
#read_begin1 ⇒ Integer
0-based best alignment beginning position on read; read_begin1 = -1 when the best alignment beginning position is not available.
-
#read_end1 ⇒ Integer
0-based best alignment ending position on read.
-
#read_end2 ⇒ Integer
0-based sub-optimal alignment ending position on read.
-
#ref_begin1 ⇒ Integer
0-based best alignment beginning position on reference; ref_begin1 = -1 when the best alignment beginning position is not available.
-
#ref_end1 ⇒ Integer
0-based best alignment ending position on reference.
-
#score1 ⇒ Integer
The best alignment score.
-
#score2 ⇒ Integer
Sub-optimal alignment score.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(ptr) ⇒ Align
constructor
A new instance of Align.
- #to_h ⇒ Object
Constructor Details
#initialize(ptr) ⇒ Align
Returns a new instance of Align.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/ssw/align.rb', line 42 def initialize(ptr) @ptr = ptr @cstruct = align = FFI::Align.new(ptr) @score1 = align.score1 @score2 = align.score2 @ref_begin1 = align.ref_begin1 @ref_end1 = align.ref_end1 @read_begin1 = align.read_begin1 @read_end1 = align.read_end1 @ref_end2 = align.ref_end2 @cigar_len = align.cigarLen @cigar = cigar_len.positive? ? align.cigar[0, 4 * cigar_len].unpack('L*') : [] # Attributes for ruby binding only @cigar_string = array_to_cigar_string(@cigar) SSW.align_destroy(ptr) end |
Instance Attribute Details
#cigar ⇒ Array (readonly)
Returns best alignment cigar; stored the same as that in BAM format, high 28 bits: length, low 4 bits: M/I/D (0/1/2); cigar = 0 when the best alignment path is not available.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/ssw/align.rb', line 33 class Align def self.keys %i[score1 score2 ref_begin1 ref_end1 read_begin1 read_end1 ref_end2 cigar cigar_len cigar_string] end # This class is read_only attr_reader(*keys) def initialize(ptr) @ptr = ptr @cstruct = align = FFI::Align.new(ptr) @score1 = align.score1 @score2 = align.score2 @ref_begin1 = align.ref_begin1 @ref_end1 = align.ref_end1 @read_begin1 = align.read_begin1 @read_end1 = align.read_end1 @ref_end2 = align.ref_end2 @cigar_len = align.cigarLen @cigar = cigar_len.positive? ? align.cigar[0, 4 * cigar_len].unpack('L*') : [] # Attributes for ruby binding only @cigar_string = array_to_cigar_string(@cigar) SSW.align_destroy(ptr) end def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end private def array_to_cigar_string(arr) cigar_string = String.new arr.each do |x| n = x >> 4 m = x & 15 c = m > 8 ? 'M' : 'MIDNSHP=X'[m] cigar_string << n.to_s << c end cigar_string end end |
#cigar_len ⇒ Integer
Returns length of the cigar string; cigarLen = 0 when the best alignment path is not available.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/ssw/align.rb', line 33 class Align def self.keys %i[score1 score2 ref_begin1 ref_end1 read_begin1 read_end1 ref_end2 cigar cigar_len cigar_string] end # This class is read_only attr_reader(*keys) def initialize(ptr) @ptr = ptr @cstruct = align = FFI::Align.new(ptr) @score1 = align.score1 @score2 = align.score2 @ref_begin1 = align.ref_begin1 @ref_end1 = align.ref_end1 @read_begin1 = align.read_begin1 @read_end1 = align.read_end1 @ref_end2 = align.ref_end2 @cigar_len = align.cigarLen @cigar = cigar_len.positive? ? align.cigar[0, 4 * cigar_len].unpack('L*') : [] # Attributes for ruby binding only @cigar_string = array_to_cigar_string(@cigar) SSW.align_destroy(ptr) end def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end private def array_to_cigar_string(arr) cigar_string = String.new arr.each do |x| n = x >> 4 m = x & 15 c = m > 8 ? 'M' : 'MIDNSHP=X'[m] cigar_string << n.to_s << c end cigar_string end end |
#cigar_string ⇒ String
Returns cigar string.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/ssw/align.rb', line 33 class Align def self.keys %i[score1 score2 ref_begin1 ref_end1 read_begin1 read_end1 ref_end2 cigar cigar_len cigar_string] end # This class is read_only attr_reader(*keys) def initialize(ptr) @ptr = ptr @cstruct = align = FFI::Align.new(ptr) @score1 = align.score1 @score2 = align.score2 @ref_begin1 = align.ref_begin1 @ref_end1 = align.ref_end1 @read_begin1 = align.read_begin1 @read_end1 = align.read_end1 @ref_end2 = align.ref_end2 @cigar_len = align.cigarLen @cigar = cigar_len.positive? ? align.cigar[0, 4 * cigar_len].unpack('L*') : [] # Attributes for ruby binding only @cigar_string = array_to_cigar_string(@cigar) SSW.align_destroy(ptr) end def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end private def array_to_cigar_string(arr) cigar_string = String.new arr.each do |x| n = x >> 4 m = x & 15 c = m > 8 ? 'M' : 'MIDNSHP=X'[m] cigar_string << n.to_s << c end cigar_string end end |
#read_begin1 ⇒ Integer
Returns 0-based best alignment beginning position on read; read_begin1 = -1 when the best alignment beginning position is not available.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/ssw/align.rb', line 33 class Align def self.keys %i[score1 score2 ref_begin1 ref_end1 read_begin1 read_end1 ref_end2 cigar cigar_len cigar_string] end # This class is read_only attr_reader(*keys) def initialize(ptr) @ptr = ptr @cstruct = align = FFI::Align.new(ptr) @score1 = align.score1 @score2 = align.score2 @ref_begin1 = align.ref_begin1 @ref_end1 = align.ref_end1 @read_begin1 = align.read_begin1 @read_end1 = align.read_end1 @ref_end2 = align.ref_end2 @cigar_len = align.cigarLen @cigar = cigar_len.positive? ? align.cigar[0, 4 * cigar_len].unpack('L*') : [] # Attributes for ruby binding only @cigar_string = array_to_cigar_string(@cigar) SSW.align_destroy(ptr) end def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end private def array_to_cigar_string(arr) cigar_string = String.new arr.each do |x| n = x >> 4 m = x & 15 c = m > 8 ? 'M' : 'MIDNSHP=X'[m] cigar_string << n.to_s << c end cigar_string end end |
#read_end1 ⇒ Integer
Returns 0-based best alignment ending position on read.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/ssw/align.rb', line 33 class Align def self.keys %i[score1 score2 ref_begin1 ref_end1 read_begin1 read_end1 ref_end2 cigar cigar_len cigar_string] end # This class is read_only attr_reader(*keys) def initialize(ptr) @ptr = ptr @cstruct = align = FFI::Align.new(ptr) @score1 = align.score1 @score2 = align.score2 @ref_begin1 = align.ref_begin1 @ref_end1 = align.ref_end1 @read_begin1 = align.read_begin1 @read_end1 = align.read_end1 @ref_end2 = align.ref_end2 @cigar_len = align.cigarLen @cigar = cigar_len.positive? ? align.cigar[0, 4 * cigar_len].unpack('L*') : [] # Attributes for ruby binding only @cigar_string = array_to_cigar_string(@cigar) SSW.align_destroy(ptr) end def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end private def array_to_cigar_string(arr) cigar_string = String.new arr.each do |x| n = x >> 4 m = x & 15 c = m > 8 ? 'M' : 'MIDNSHP=X'[m] cigar_string << n.to_s << c end cigar_string end end |
#read_end2 ⇒ Integer
Returns 0-based sub-optimal alignment ending position on read.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/ssw/align.rb', line 33 class Align def self.keys %i[score1 score2 ref_begin1 ref_end1 read_begin1 read_end1 ref_end2 cigar cigar_len cigar_string] end # This class is read_only attr_reader(*keys) def initialize(ptr) @ptr = ptr @cstruct = align = FFI::Align.new(ptr) @score1 = align.score1 @score2 = align.score2 @ref_begin1 = align.ref_begin1 @ref_end1 = align.ref_end1 @read_begin1 = align.read_begin1 @read_end1 = align.read_end1 @ref_end2 = align.ref_end2 @cigar_len = align.cigarLen @cigar = cigar_len.positive? ? align.cigar[0, 4 * cigar_len].unpack('L*') : [] # Attributes for ruby binding only @cigar_string = array_to_cigar_string(@cigar) SSW.align_destroy(ptr) end def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end private def array_to_cigar_string(arr) cigar_string = String.new arr.each do |x| n = x >> 4 m = x & 15 c = m > 8 ? 'M' : 'MIDNSHP=X'[m] cigar_string << n.to_s << c end cigar_string end end |
#ref_begin1 ⇒ Integer
Returns 0-based best alignment beginning position on reference; ref_begin1 = -1 when the best alignment beginning position is not available.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/ssw/align.rb', line 33 class Align def self.keys %i[score1 score2 ref_begin1 ref_end1 read_begin1 read_end1 ref_end2 cigar cigar_len cigar_string] end # This class is read_only attr_reader(*keys) def initialize(ptr) @ptr = ptr @cstruct = align = FFI::Align.new(ptr) @score1 = align.score1 @score2 = align.score2 @ref_begin1 = align.ref_begin1 @ref_end1 = align.ref_end1 @read_begin1 = align.read_begin1 @read_end1 = align.read_end1 @ref_end2 = align.ref_end2 @cigar_len = align.cigarLen @cigar = cigar_len.positive? ? align.cigar[0, 4 * cigar_len].unpack('L*') : [] # Attributes for ruby binding only @cigar_string = array_to_cigar_string(@cigar) SSW.align_destroy(ptr) end def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end private def array_to_cigar_string(arr) cigar_string = String.new arr.each do |x| n = x >> 4 m = x & 15 c = m > 8 ? 'M' : 'MIDNSHP=X'[m] cigar_string << n.to_s << c end cigar_string end end |
#ref_end1 ⇒ Integer
Returns 0-based best alignment ending position on reference.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/ssw/align.rb', line 33 class Align def self.keys %i[score1 score2 ref_begin1 ref_end1 read_begin1 read_end1 ref_end2 cigar cigar_len cigar_string] end # This class is read_only attr_reader(*keys) def initialize(ptr) @ptr = ptr @cstruct = align = FFI::Align.new(ptr) @score1 = align.score1 @score2 = align.score2 @ref_begin1 = align.ref_begin1 @ref_end1 = align.ref_end1 @read_begin1 = align.read_begin1 @read_end1 = align.read_end1 @ref_end2 = align.ref_end2 @cigar_len = align.cigarLen @cigar = cigar_len.positive? ? align.cigar[0, 4 * cigar_len].unpack('L*') : [] # Attributes for ruby binding only @cigar_string = array_to_cigar_string(@cigar) SSW.align_destroy(ptr) end def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end private def array_to_cigar_string(arr) cigar_string = String.new arr.each do |x| n = x >> 4 m = x & 15 c = m > 8 ? 'M' : 'MIDNSHP=X'[m] cigar_string << n.to_s << c end cigar_string end end |
#score1 ⇒ Integer
Returns the best alignment score.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/ssw/align.rb', line 33 class Align def self.keys %i[score1 score2 ref_begin1 ref_end1 read_begin1 read_end1 ref_end2 cigar cigar_len cigar_string] end # This class is read_only attr_reader(*keys) def initialize(ptr) @ptr = ptr @cstruct = align = FFI::Align.new(ptr) @score1 = align.score1 @score2 = align.score2 @ref_begin1 = align.ref_begin1 @ref_end1 = align.ref_end1 @read_begin1 = align.read_begin1 @read_end1 = align.read_end1 @ref_end2 = align.ref_end2 @cigar_len = align.cigarLen @cigar = cigar_len.positive? ? align.cigar[0, 4 * cigar_len].unpack('L*') : [] # Attributes for ruby binding only @cigar_string = array_to_cigar_string(@cigar) SSW.align_destroy(ptr) end def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end private def array_to_cigar_string(arr) cigar_string = String.new arr.each do |x| n = x >> 4 m = x & 15 c = m > 8 ? 'M' : 'MIDNSHP=X'[m] cigar_string << n.to_s << c end cigar_string end end |
#score2 ⇒ Integer
Returns sub-optimal alignment score.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/ssw/align.rb', line 33 class Align def self.keys %i[score1 score2 ref_begin1 ref_end1 read_begin1 read_end1 ref_end2 cigar cigar_len cigar_string] end # This class is read_only attr_reader(*keys) def initialize(ptr) @ptr = ptr @cstruct = align = FFI::Align.new(ptr) @score1 = align.score1 @score2 = align.score2 @ref_begin1 = align.ref_begin1 @ref_end1 = align.ref_end1 @read_begin1 = align.read_begin1 @read_end1 = align.read_end1 @ref_end2 = align.ref_end2 @cigar_len = align.cigarLen @cigar = cigar_len.positive? ? align.cigar[0, 4 * cigar_len].unpack('L*') : [] # Attributes for ruby binding only @cigar_string = array_to_cigar_string(@cigar) SSW.align_destroy(ptr) end def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end private def array_to_cigar_string(arr) cigar_string = String.new arr.each do |x| n = x >> 4 m = x & 15 c = m > 8 ? 'M' : 'MIDNSHP=X'[m] cigar_string << n.to_s << c end cigar_string end end |
Class Method Details
.keys ⇒ Object
34 35 36 37 |
# File 'lib/ssw/align.rb', line 34 def self.keys %i[score1 score2 ref_begin1 ref_end1 read_begin1 read_end1 ref_end2 cigar cigar_len cigar_string] end |
Instance Method Details
#to_h ⇒ Object
59 60 61 |
# File 'lib/ssw/align.rb', line 59 def to_h self.class.keys.map { |k| [k, __send__(k)] }.to_h end |