Method: IUPAC#initialize
- Defined in:
- lib/sequence_logo/ytilib/iupac.rb
#initialize(words) ⇒ IUPAC
Returns a new instance of IUPAC.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/sequence_logo/ytilib/iupac.rb', line 11 def initialize(words) if words.is_a?(Array) iupac = (0...words[0].size).collect { |i| (0...words.size).collect { |j| words[j][i,1] }.uniq.sort.inject("") { |cola, letter| cola += letter } }.inject("") { |iup, cola| checkerr("bad letter set #{cola}") { !CODE.has_key?(cola) } iup += CODE[cola] } super(iupac) elsif words.is_a?(IUPAC) super(words) elsif words.is_a?(String) checkerr("word #{words} has strange characters") { words.tr('ACGTURYKMSWBDHVN', '').size > 0 } super(words) end end |