class Bio::BioAlignment::Column
Support the notion of columns in an alignment. A column is simply an integer index into the alignment, stored in @col. A column can have state by attaching state objects.
Public Class Methods
new(aln, col)
click to toggle source
# File lib/bio-alignment/columns.rb, line 60 def initialize aln, col @aln = aln @col = col # column index number @col.freeze @aln end
Public Instance Methods
[](index)
click to toggle source
# File lib/bio-alignment/columns.rb, line 67 def [] index @aln[index][@col] end
count(&block)
click to toggle source
# File lib/bio-alignment/columns.rb, line 89 def count &block counter = 0 each do | e | found = if e.kind_of?(String) block.call(Element.new(e)) else block.call(e) end counter += 1 if found end counter end
each() { |seq| ... }
click to toggle source
iterator fetches a column on demand, yielding column elements
# File lib/bio-alignment/columns.rb, line 79 def each @aln.each do | seq | yield seq[@col] end end
length()
click to toggle source
# File lib/bio-alignment/columns.rb, line 85 def length @length ||= @aln.rows.size end
to_s()
click to toggle source
# File lib/bio-alignment/columns.rb, line 103 def to_s map{|e| e.to_s}.join('') end