Class: Bioinform::PrettyMatrixFormatter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ PrettyMatrixFormatter

Returns a new instance of PrettyMatrixFormatter.



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

def initialize(options = {})
  @with_name = options.fetch(:with_name, true)
  @letters_as_rows = options.fetch(:letters_as_rows, false)
end

Instance Attribute Details

#letters_as_rowsObject (readonly)

Returns the value of attribute letters_as_rows.



5
6
7
# File 'lib/bioinform/formatters/pretty_matrix_formatter.rb', line 5

def letters_as_rows
  @letters_as_rows
end

#with_nameObject (readonly)

Returns the value of attribute with_name.



5
6
7
# File 'lib/bioinform/formatters/pretty_matrix_formatter.rb', line 5

def with_name
  @with_name
end

Instance Method Details

#format(motif) ⇒ Object

Raises:



28
29
30
31
32
# File 'lib/bioinform/formatters/pretty_matrix_formatter.rb', line 28

def format(motif)
  raise  Error, "PM doesn't respond to #name. Use formatter with option `with_name: false`"  if @with_name && !motif.respond_to?(:name)
  return MotifFormatter.new(with_name: @with_name, nucleotides_in: (@letters_as_rows ? :rows : :columns)).format(motif)  if @letters_as_rows
  optional_name(motif) + header + matrix_string(motif)
end