Module Bio::Alignment::GAP
In: lib/bio/alignment.rb  (CVS)

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

Methods

Public Instance methods

 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
      def gapped_pos(seq, pos, gap_regexp)
        olen = seq.gsub(gap_regexp, '').length
        pos = olen if pos >= olen
        pos = olen + pos if pos < 0
        
        i = 0
        l = pos + 1
        while l > 0 and i < seq.length
          x = seq[i, l].gsub(gap_regexp, '').length
          i += l
          l -= x
        end
        i -= 1 if i > 0
        i
      end
 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
      def ungapped_pos(seq, pos, gap_regexp)
        p = seq[0..pos].gsub(gap_regexp, '').length
        p -= 1 if p > 0
        p
      end

[Validate]