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