module Bio::ColorScheme

bio/util/color_scheme.rb - Popular color codings for nucleic and amino acids

Author

Trevor Wennblom <trevor@corevx.com>

Copyright

Copyright © 2005-2007 Midwinter Laboratories, LLC (midwinterlabs.com)

License

The Ruby License

Description

The Bio::ColorScheme module contains classes that return popular color codings for nucleic and amino acids in RGB hex format suitable for HTML code.

The current schemes supported are:

Planned color schemes include:

Color schemes BLOSUM62, ClustalX, and Percentage Identity are all dependent on the alignment consensus.

This data is currently referenced from the JalView alignment editor. Clamp, M., Cuff, J., Searle, S. M. and Barton, G. J. (2004), “The Jalview Java Alignment Editor,” Bioinformatics, 12, 426-7 www.jalview.org

Currently the score data for things such as hydropathy, helix, turn, etc. are contained here but should be moved to bio/data/aa once a good reference is found for these values.

Usage

require 'bio'

seq = 'gattaca'
scheme = Bio::ColorScheme::Zappo
postfix = '</span>'
html = ''
seq.each_byte do |c|
  color = scheme[c.chr]
  prefix = %Q(<span style="background:\##{color};">)
  html += prefix + c.chr + postfix
end

puts html

Accessing colors

puts Bio::ColorScheme::Buried['A']  # 00DC22
puts Bio::ColorScheme::Buried[:c]   # 00BF3F
puts Bio::ColorScheme::Buried[nil]  # nil
puts Bio::ColorScheme::Buried['-']  # FFFFFF
puts Bio::ColorScheme::Buried[7]    # FFFFFF
puts Bio::ColorScheme::Buried['junk']  # FFFFFF
puts Bio::ColorScheme::Buried['t']  # 00CC32

Constants

NA