Sha256: 7cc63c8524474ae92a216b21492b0efb283dbdc818039672093949f0966fb034

Contents?: true

Size: 726 Bytes

Versions: 5

Compression:

Stored size: 726 Bytes

Contents

class RawFormatter
  attr_accessor :motif, :options
  
  def initialize(motif, options = {})
    @motif = motif
    
    default_options = {with_name: true, letters_as_rows: false}
    @options = default_options.merge(options)
  end
  
  def name
    motif.name
  end
  
  def header
    if options[:with_name] && name
      name + "\n"
    else
      ''
    end
  end
  
  def matrix_string
    if options[:letters_as_rows]
      hsh = motif.to_hash
      [:A,:C,:G,:T].collect{|letter| "#{letter}|" + hsh[letter].join("\t")}.join("\n")
    else
      motif.each_position.map{|pos| pos.join("\t")}.join("\n")
    end
  end
  
  def footer
    # "\n"
    ''
  end
  
  
  def to_s
    header + matrix_string + footer
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
bioinform-0.1.17 lib/bioinform/formatters/raw_formatter.rb
bioinform-0.1.16 lib/bioinform/formatters/raw_formatter.rb
bioinform-0.1.15 lib/bioinform/formatters/raw_formatter.rb
bioinform-0.1.14 lib/bioinform/formatters/raw_formatter.rb
bioinform-0.1.13 lib/bioinform/formatters/raw_formatter.rb