Class: TransfacFormatter
- Defined in:
- lib/bioinform/formatters/transfac_formatter.rb
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 = {}) ⇒ TransfacFormatter
constructor
A new instance of TransfacFormatter.
- #matrix_string ⇒ Object
- #name ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(motif, options = {}) ⇒ TransfacFormatter
4 5 6 7 8 9 |
# File 'lib/bioinform/formatters/transfac_formatter.rb', line 4 def initialize(motif, = {}) @motif = motif = {with_name: true, letters_as_rows: false} = .merge() end |
Instance Attribute Details
#motif ⇒ Object
Returns the value of attribute motif.
2 3 4 |
# File 'lib/bioinform/formatters/transfac_formatter.rb', line 2 def motif @motif end |
#options ⇒ Object
Returns the value of attribute options.
2 3 4 |
# File 'lib/bioinform/formatters/transfac_formatter.rb', line 2 def end |
Instance Method Details
#footer ⇒ Object
31 32 33 34 |
# File 'lib/bioinform/formatters/transfac_formatter.rb', line 31 def #"XX\n//\n" "\nXX\n//" end |
#header ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/bioinform/formatters/transfac_formatter.rb', line 15 def header if [:with_name] && name "ID #{name}\nBF StubSpeciesName\nP0\tA\tC\tG\tT\n" else raise 'Transfac should have the name field' end end |
#matrix_string ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/bioinform/formatters/transfac_formatter.rb', line 23 def matrix_string motif.each_position.map.with_index{|pos,ind| line_number = ind.to_s line_number = (line_number.size == 1) ? "0#{line_number}" : line_number line_number + ' ' + pos.join("\t") }.join("\n") end |
#name ⇒ Object
11 12 13 |
# File 'lib/bioinform/formatters/transfac_formatter.rb', line 11 def name motif.name end |
#to_s ⇒ Object
36 37 38 |
# File 'lib/bioinform/formatters/transfac_formatter.rb', line 36 def to_s header + matrix_string + end |