lib/bio/shell/plugin/codon.rb in bio-1.0.0 vs lib/bio/shell/plugin/codon.rb in bio-1.1.0

- old
+ new

@@ -1,13 +1,13 @@ # # = bio/shell/plugin/codon.rb - plugin for the codon table # # Copyright:: Copyright (C) 2005 # Toshiaki Katayama <k@bioruby.org> -# License:: Ruby's +# License:: The Ruby License # -# $Id: codon.rb,v 1.13 2006/02/09 20:48:53 k Exp $ +# $Id: codon.rb,v 1.16 2007/04/05 23:35:41 trevor Exp $ # module Bio::Shell class ColoredCodonTable @@ -33,28 +33,28 @@ end end attr_reader :table def setup_colors - esc_seq = Bio::Shell.esc_seq + c = Bio::Shell.colors @colors = { - :text => esc_seq[:none], - :aa => esc_seq[:green], - :start => esc_seq[:red], - :stop => esc_seq[:red], - :basic => esc_seq[:cyan], - :polar => esc_seq[:blue], - :acidic => esc_seq[:magenta], - :nonpolar => esc_seq[:yellow], + :text => c[:none], + :aa => c[:green], + :start => c[:red], + :stop => c[:red], + :basic => c[:cyan], + :polar => c[:blue], + :acidic => c[:magenta], + :nonpolar => c[:yellow], } end def generate_mono_text @table.each do |codon, aa| if aa == '*' - code = "STOP" + code = 'STOP' aa = '' unless @cuhash else code = @aacode[aa] end if @cuhash @@ -76,14 +76,22 @@ def generate_colored_text @table.each do |codon, aa| property, = @@properties.detect {|key, list| list.include?(aa)} if aa == '*' - color_code = "#{@colors[:stop]}STOP" if @cuhash + color_code = "#{@colors[:stop]}STOP" color_aa = "#{@colors[:stop]}#{aa}" else - color_aa = '' + color_code = "#{@colors[:stop]}STP" + case codon + when 'tga' + color_aa = "#{@colors[:text]}U" + when 'tag' + color_aa = "#{@colors[:text]}O" + else + color_aa = "#{@colors[:text]}*" + end end else color_code = "#{@colors[property]}#{@aacode[aa]}" if @table.start_codon?(codon) if @cuhash