Module | Bio::Alignment::GAP
In: | lib/bio/alignment.rb

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

### Methods

gapped_pos ungapped_pos

### Public Instance methods

gapped_pos(seq, pos, gap_regexp)

     position without gaps are translated into the position with gaps.

seq: | sequence
pos: | position with gaps
gap_regexp: | regular expression to specify gaps

[Source]

          # File lib/bio/alignment.rb, line 2168
    2168:       def gapped_pos(seq, pos, gap_regexp)
    2169:         olen = seq.gsub(gap_regexp, '').length
    2170:         pos = olen if pos >= olen
    2171:         pos = olen + pos if pos < 0
    2172:
    2173:         i = 0
    2174:         l = pos + 1
    2175:         while l > 0 and i < seq.length
    2176:           x = seq[i, l].gsub(gap_regexp, '').length
    2177:           i += l
    2178:           l -= x
    2179:         end
    2180:         i -= 1 if i > 0
    2181:         i
    2182:       end

ungapped_pos(seq, pos, gap_regexp)

     position with gaps are translated into the position without gaps.

seq: | sequence
pos: | position with gaps
gap_regexp: | regular expression to specify gaps

[Source]

          # File lib/bio/alignment.rb, line 2157
    2157:       def ungapped_pos(seq, pos, gap_regexp)
    2158:         p = seq[0..pos].gsub(gap_regexp, '').length
    2159:         p -= 1 if p > 0
    2160:         p
    2161:       end

[Validate]