Class: RawFormatter
Instance Attribute Summary collapse
-
#motif ⇒ Object
Returns the value of attribute motif.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #footer ⇒ Object
- #header ⇒ Object
-
#initialize(motif, options = {}) ⇒ RawFormatter
constructor
A new instance of RawFormatter.
- #matrix_string ⇒ Object
- #name ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(motif, options = {}) ⇒ RawFormatter
Returns a new instance of RawFormatter.
4 5 6 7 8 9 |
# File 'lib/bioinform/formatters/raw_formatter.rb', line 4 def initialize(motif, = {}) @motif = motif = {with_name: true, letters_as_rows: false} @options = .merge() end |
Instance Attribute Details
#motif ⇒ Object
Returns the value of attribute motif.
2 3 4 |
# File 'lib/bioinform/formatters/raw_formatter.rb', line 2 def motif @motif end |
#options ⇒ Object
Returns the value of attribute options.
2 3 4 |
# File 'lib/bioinform/formatters/raw_formatter.rb', line 2 def @options end |
Instance Method Details
#footer ⇒ Object
32 33 34 35 |
# File 'lib/bioinform/formatters/raw_formatter.rb', line 32 def # "\n" '' end |
#header ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/bioinform/formatters/raw_formatter.rb', line 15 def header if [:with_name] && name name + "\n" else '' end end |
#matrix_string ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/bioinform/formatters/raw_formatter.rb', line 23 def matrix_string if [: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 |
#name ⇒ Object
11 12 13 |
# File 'lib/bioinform/formatters/raw_formatter.rb', line 11 def name motif.name end |
#to_s ⇒ Object
38 39 40 |
# File 'lib/bioinform/formatters/raw_formatter.rb', line 38 def to_s header + matrix_string + end |