module Bio::Alignment::GAP

Bio::Alignment::GAP is a set of class methods for gap-related position translation.

Public Class Methods

gapped_pos(seq, pos, gap_regexp) click to toggle source
position without gaps are translated into the position with gaps.
seq

sequence

pos

position with gaps

gap_regexp

regular expression to specify gaps

     # File lib/bio/alignment.rb
2162 def gapped_pos(seq, pos, gap_regexp)
2163   olen = seq.gsub(gap_regexp, '').length
2164   pos = olen if pos >= olen
2165   pos = olen + pos if pos < 0
2166   
2167   i = 0
2168   l = pos + 1
2169   while l > 0 and i < seq.length
2170     x = seq[i, l].gsub(gap_regexp, '').length
2171     i += l
2172     l -= x
2173   end
2174   i -= 1 if i > 0
2175   i
2176 end
ungapped_pos(seq, pos, gap_regexp) click to toggle source
position with gaps are translated into the position without gaps.
seq

sequence

pos

position with gaps

gap_regexp

regular expression to specify gaps

     # File lib/bio/alignment.rb
2151 def ungapped_pos(seq, pos, gap_regexp)
2152   p = seq[0..pos].gsub(gap_regexp, '').length
2153   p -= 1 if p > 0
2154   p
2155 end