Sha256: c7452b7d7b5a55dc758610af3545f7c10286a31d662ecaa82ccb74204e5ed0ac

Contents?: true

Size: 766 Bytes

Versions: 4

Compression:

Stored size: 766 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

4 entries across 4 versions & 1 rubygems

Version Path
bioinform-0.1.12 lib/bioinform/formatters/raw_formatter.rb
bioinform-0.1.11 lib/bioinform/formatters/raw_formatter.rb
bioinform-0.1.10 lib/bioinform/formatters/raw_formatter.rb
bioinform-0.1.9 lib/bioinform/formatters/raw_formatter.rb