class BioDSL::SliceAlign::PosIndex

Class for indexing gapped sequence positions to non-gapped sequence positions.

Public Class Methods

new(entry, indels) click to toggle source

Constructor for PosIndex.

@param entry [BioDSL::Seq] Gapped sequence entry. @param indels [String] String with indel alphabet.

@return [PosIndex] Class instance.

# File lib/BioDSL/commands/slice_align.rb, line 368
def initialize(entry, indels)
  @entry  = entry
  @indels = indels
  @index  = index_positions
end

Public Instance Methods

[](pos) click to toggle source

Given a non-gapped sequence postion return the gapped position.

@param pos [Integer] Non-gapped sequence position.

@return [Integer] Gapped sequence position

# File lib/BioDSL/commands/slice_align.rb, line 379
def [](pos)
  @index[pos]
end

Private Instance Methods

index_positions() click to toggle source

Return an index mapping gapped sequence positions to non-gapped positions.

@return [Array] Position index.

# File lib/BioDSL/commands/slice_align.rb, line 389
def index_positions
  pos_index = []

  @entry.seq.chars.each_with_index do |c, i|
    pos_index << i unless @indels.include? c
  end

  pos_index
end