| 1 | package Bio::Graphics::Glyph::redgreen_segment; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use base qw(Bio::Graphics::Glyph::graded_segments); | ||
| 5 | |||
| 6 | sub calculate_color { | ||
| 7 | my $self = shift; | ||
| 8 | my $val = shift; | ||
| 9 | return (0,0,0) unless $val =~ /^[\d.]+$/; | ||
| 10 | return HSVtoRGB(120*(1-$val),1,255); | ||
| 11 | } | ||
| 12 | |||
| 13 | sub HSVtoRGB ($$$) { | ||
| 14 | my ($h,$s,$v)=@_; | ||
| 15 | my ($r,$g,$b,$i,$f,$p,$q,$t); | ||
| 16 | |||
| 17 | if( $s == 0 ) { | ||
| 18 | ## achromatic (grey) | ||
| 19 | return ($v,$v,$v); | ||
| 20 | } | ||
| 21 | |||
| 22 | $h /= 60; ## sector 0 to 5 | ||
| 23 | $i = int($h); | ||
| 24 | $f = $h - $i; ## factorial part of h | ||
| 25 | $p = $v * ( 1 - $s ); | ||
| 26 | $q = $v * ( 1 - $s * $f ); | ||
| 27 | $t = $v * ( 1 - $s * ( 1 - $f ) ); | ||
| 28 | |||
| 29 | if($i<1) { | ||
| 30 | $r = $v; | ||
| 31 | $g = $t; | ||
| 32 | $b = $p; | ||
| 33 | } elsif($i<2){ | ||
| 34 | $r = $q; | ||
| 35 | $g = $v; | ||
| 36 | $b = $p; | ||
| 37 | } elsif($i<3){ | ||
| 38 | $r = $p; | ||
| 39 | $g = $v; | ||
| 40 | $b = $t; | ||
| 41 | } elsif($i<4){ | ||
| 42 | $r = $p; | ||
| 43 | $g = $q; | ||
| 44 | $b = $v; | ||
| 45 | } elsif($i<5){ | ||
| 46 | $r = $t; | ||
| 47 | $g = $p; | ||
| 48 | $b = $v; | ||
| 49 | } else { | ||
| 50 | $r = $v; | ||
| 51 | $g = $p; | ||
| 52 | $b = $q; | ||
| 53 | } | ||
| 54 | return ($r,$g,$b); | ||
| 55 | } | ||
| 56 | |||
| 57 | sub mMin { | ||
| 58 | my $n=10000000000000; | ||
| 59 | map { $n=($n>$_) ? $_ : $n } @_; | ||
| 60 | return($n); | ||
| 61 | } | ||
| 62 | |||
| 63 | sub mMax { | ||
| 64 | my $n=0; | ||
| 65 | map { $n=($n<$_) ? $_ : $n } @_; | ||
| 66 | return($n); | ||
| 67 | } | ||
| 68 | |||
| 69 | |||
| 70 | 1; | ||
| 71 | |||
| 72 | =head1 NAME | ||
| 73 | |||
| 74 | Bio::Graphics::Glyph::redgreen_segment - The "redgreen_segments" glyph | ||
| 75 | |||
| 76 | =head1 SYNOPSIS | ||
| 77 | |||
| 78 | See L<Bio::Graphics::Panel> and L<Bio::Graphics::Glyph>. | ||
| 79 | |||
| 80 | =head1 DESCRIPTION | ||
| 81 | |||
| 82 | This glyph is similar to the graded_segments glyph except that it | ||
| 83 | generates a green-E<gt>red gradient suitable for use with microarray data. | ||
| 84 | A feature score of 0 is full green; a feature score of 1.0 is full | ||
| 85 | red; intermediate scores are shades of yellow. | ||
| 86 | |||
| 87 | =head2 OPTIONS | ||
| 88 | |||
| 89 | The following options are standard among all Glyphs. See | ||
| 90 | L<Bio::Graphics::Glyph> for a full explanation. | ||
| 91 | |||
| 92 | Option Description Default | ||
| 93 | ------ ----------- ------- | ||
| 94 | |||
| 95 | -fgcolor Foreground color black | ||
| 96 | |||
| 97 | -outlinecolor Synonym for -fgcolor | ||
| 98 | |||
| 99 | -bgcolor Background color turquoise | ||
| 100 | |||
| 101 | -fillcolor Synonym for -bgcolor | ||
| 102 | |||
| 103 | -linewidth Line width 1 | ||
| 104 | |||
| 105 | -height Height of glyph 10 | ||
| 106 | |||
| 107 | -font Glyph font gdSmallFont | ||
| 108 | |||
| 109 | -connector Connector type 0 (false) | ||
| 110 | |||
| 111 | -connector_color | ||
| 112 | Connector color black | ||
| 113 | |||
| 114 | -label Whether to draw a label 0 (false) | ||
| 115 | |||
| 116 | -description Whether to draw a description 0 (false) | ||
| 117 | |||
| 118 | =head1 BUGS | ||
| 119 | |||
| 120 | Please report them. | ||
| 121 | |||
| 122 | =head1 SEE ALSO | ||
| 123 | |||
| 124 | L<Bio::Graphics::Panel>, | ||
| 125 | L<Bio::Graphics::Glyph>, | ||
| 126 | L<Bio::Graphics::Glyph::arrow>, | ||
| 127 | L<Bio::Graphics::Glyph::cds>, | ||
| 128 | L<Bio::Graphics::Glyph::crossbox>, | ||
| 129 | L<Bio::Graphics::Glyph::diamond>, | ||
| 130 | L<Bio::Graphics::Glyph::dna>, | ||
| 131 | L<Bio::Graphics::Glyph::dot>, | ||
| 132 | L<Bio::Graphics::Glyph::ellipse>, | ||
| 133 | L<Bio::Graphics::Glyph::extending_arrow>, | ||
| 134 | L<Bio::Graphics::Glyph::generic>, | ||
| 135 | L<Bio::Graphics::Glyph::graded_segments>, | ||
| 136 | L<Bio::Graphics::Glyph::heterogeneous_segments>, | ||
| 137 | L<Bio::Graphics::Glyph::line>, | ||
| 138 | L<Bio::Graphics::Glyph::pinsertion>, | ||
| 139 | L<Bio::Graphics::Glyph::primers>, | ||
| 140 | L<Bio::Graphics::Glyph::rndrect>, | ||
| 141 | L<Bio::Graphics::Glyph::segments>, | ||
| 142 | L<Bio::Graphics::Glyph::ruler_arrow>, | ||
| 143 | L<Bio::Graphics::Glyph::toomany>, | ||
| 144 | L<Bio::Graphics::Glyph::transcript>, | ||
| 145 | L<Bio::Graphics::Glyph::transcript2>, | ||
| 146 | L<Bio::Graphics::Glyph::translation>, | ||
| 147 | L<Bio::Graphics::Glyph::triangle>, | ||
| 148 | L<Bio::DB::GFF>, | ||
| 149 | L<Bio::SeqI>, | ||
| 150 | L<Bio::SeqFeatureI>, | ||
| 151 | L<Bio::Das>, | ||
| 152 | L<GD> | ||
| 153 | |||
| 154 | =head1 AUTHOR | ||
| 155 | |||
| 156 | Lincoln Stein E<lt>lstein@cshl.orgE<gt> | ||
| 157 | |||
| 158 | Copyright (c) 2001 Cold Spring Harbor Laboratory | ||
| 159 | |||
| 160 | This library is free software; you can redistribute it and/or modify | ||
| 161 | it under the same terms as Perl itself. See DISCLAIMER.txt for | ||
| 162 | disclaimers of warranty. | ||
| 163 | |||
| 164 | =cut |