Class: Bioinform::ConsensusFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/bioinform/formatters/consensus_formatter.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ ConsensusFormatter

ConsensusFormatter.new{|pos, el, nucleotide_index| el == pos.max }

Raises:



7
8
9
10
# File 'lib/bioinform/formatters/consensus_formatter.rb', line 7

def initialize(&block)
  raise Error, 'block is necessary to create an instance of ConsensusFormatter'  unless block_given?
  @block = block
end

Class Method Details

.by_maximal_elementsObject

Simplest consensus formatter which takes into account only maximal elements



13
14
15
# File 'lib/bioinform/formatters/consensus_formatter.rb', line 13

def self.by_maximal_elements
  self.new{|pos, el, nucleotide_index| el == pos.max }
end

Instance Method Details

#format_string(pm) ⇒ Object



18
19
20
# File 'lib/bioinform/formatters/consensus_formatter.rb', line 18

def format_string(pm)
  pm.each_position.map{|pos| iupac_letter_by_position(pos) }.join
end