0
|
1 package Bio::Graphics::Glyph::heterogeneous_segments;
|
|
2
|
|
3 # this glyph acts like graded_segments but the bgcolor of each segment is
|
|
4 # controlled by the source field of the feature. Use the source field name
|
|
5 # to set the background color:
|
|
6 # -waba_strong => 'blue'
|
|
7 # -waba_weak => 'red'
|
|
8 # -waba_coding => 'green'
|
|
9
|
|
10 # $Id: heterogeneous_segments.pm,v 1.5 2002/12/23 01:33:41 lstein Exp $
|
|
11
|
|
12 use strict;
|
|
13 use Bio::Graphics::Glyph::graded_segments;
|
|
14 use vars '@ISA';
|
|
15 @ISA = 'Bio::Graphics::Glyph::graded_segments';
|
|
16
|
|
17 # override draw method to calculate the min and max values for the components
|
|
18 sub draw {
|
|
19 my $self = shift;
|
|
20
|
|
21 # bail out if this isn't the right kind of feature
|
|
22 # handle both das-style and Bio::SeqFeatureI style,
|
|
23 # which use different names for subparts.
|
|
24 my @parts = $self->parts;
|
|
25 @parts = $self if !@parts && $self->level == 0;
|
|
26 return $self->SUPER::draw(@_) unless @parts;
|
|
27
|
|
28 # figure out the colors
|
|
29 $self->{source2color} ||= {};
|
|
30 my $fill = $self->bgcolor;
|
|
31 for my $part (@parts) {
|
|
32 my $s = eval { $part->feature->source_tag } or next;
|
|
33 $self->{source2color}{$s} ||= $self->color(lc($s)."_color") || $fill;
|
|
34 $part->{partcolor} = $self->{source2color}{$s};
|
|
35 }
|
|
36
|
|
37 $self->Bio::Graphics::Glyph::generic::draw(@_);
|
|
38 }
|
|
39
|
|
40
|
|
41 # synthesize a key glyph
|
|
42 sub keyglyph {
|
|
43 my $self = shift;
|
|
44
|
|
45 my $scale = 1/$self->scale; # base pairs/pixel
|
|
46
|
|
47 # two segments, at pixels 0->50, 60->80
|
|
48 my $offset = $self->panel->offset;
|
|
49
|
|
50 my $feature =
|
|
51 Bio::Graphics::Feature->new(
|
|
52 -segments=>[ [ 0*$scale +$offset,25*$scale+$offset],
|
|
53 [ 25*$scale +$offset,50*$scale+$offset],
|
|
54 [ 50*$scale+$offset, 75*$scale+$offset]
|
|
55 ],
|
|
56 -name => $self->option('key'),
|
|
57 -strand => '+1');
|
|
58 my @sources = grep {/_color$/} $self->factory->options;
|
|
59 foreach (@sources) {s/_color$//}
|
|
60 ($feature->segments)[0]->source_tag($sources[1]);
|
|
61 ($feature->segments)[1]->source_tag($sources[0]);
|
|
62 ($feature->segments)[2]->source_tag($sources[2]);
|
|
63 my $factory = $self->factory->clone;
|
|
64 $factory->set_option(label => 1);
|
|
65 $factory->set_option(bump => 0);
|
|
66 $factory->set_option(connector => 'solid');
|
|
67 my $glyph = $factory->make_glyph(0,$feature);
|
|
68 return $glyph;
|
|
69 }
|
|
70
|
|
71 1;
|
|
72
|
|
73 =head1 NAME
|
|
74
|
|
75 Bio::Graphics::Glyph::heterogeneous_segments - The "heterogeneous_segments" glyph
|
|
76
|
|
77 =head1 SYNOPSIS
|
|
78
|
|
79 See L<Bio::Graphics::Panel> and L<Bio::Graphics::Glyph>.
|
|
80
|
|
81 =head1 DESCRIPTION
|
|
82
|
|
83 This glyph acts like graded_segments but the bgcolor of each segment (sub-feature)
|
|
84 can be individually set using the source field of the feature.
|
|
85
|
|
86 Each segment type color is specified using the following nomenclature:
|
|
87
|
|
88 -{source}_color => $color
|
|
89
|
|
90 For example, if the feature consists of a gene containing both
|
|
91 confirmed and unconfirmed exons, you can make the confirmed exons
|
|
92 green and the unconfirmed ones red this way:
|
|
93
|
|
94 -confirmed_color => 'green',
|
|
95 -unconfirmed_color => 'red'
|
|
96
|
|
97 =head2 OPTIONS
|
|
98
|
|
99 The following options are standard among all Glyphs. See
|
|
100 L<Bio::Graphics::Glyph> for a full explanation.
|
|
101
|
|
102 Option Description Default
|
|
103 ------ ----------- -------
|
|
104
|
|
105 -fgcolor Foreground color black
|
|
106
|
|
107 -outlinecolor Synonym for -fgcolor
|
|
108
|
|
109 -bgcolor Background color turquoise
|
|
110
|
|
111 -fillcolor Synonym for -bgcolor
|
|
112
|
|
113 -linewidth Line width 1
|
|
114
|
|
115 -height Height of glyph 10
|
|
116
|
|
117 -font Glyph font gdSmallFont
|
|
118
|
|
119 -connector Connector type 0 (false)
|
|
120
|
|
121 -connector_color
|
|
122 Connector color black
|
|
123
|
|
124 -label Whether to draw a label 0 (false)
|
|
125
|
|
126 -description Whether to draw a description 0 (false)
|
|
127
|
|
128 =head1 BUGS
|
|
129
|
|
130 Please report them.
|
|
131
|
|
132 =head1 SEE ALSO
|
|
133
|
|
134 L<Bio::Graphics::Panel>,
|
|
135 L<Bio::Graphics::Glyph>,
|
|
136 L<Bio::Graphics::Glyph::arrow>,
|
|
137 L<Bio::Graphics::Glyph::cds>,
|
|
138 L<Bio::Graphics::Glyph::crossbox>,
|
|
139 L<Bio::Graphics::Glyph::diamond>,
|
|
140 L<Bio::Graphics::Glyph::dna>,
|
|
141 L<Bio::Graphics::Glyph::dot>,
|
|
142 L<Bio::Graphics::Glyph::ellipse>,
|
|
143 L<Bio::Graphics::Glyph::extending_arrow>,
|
|
144 L<Bio::Graphics::Glyph::generic>,
|
|
145 L<Bio::Graphics::Glyph::graded_segments>,
|
|
146 L<Bio::Graphics::Glyph::heterogeneous_segments>,
|
|
147 L<Bio::Graphics::Glyph::line>,
|
|
148 L<Bio::Graphics::Glyph::pinsertion>,
|
|
149 L<Bio::Graphics::Glyph::primers>,
|
|
150 L<Bio::Graphics::Glyph::rndrect>,
|
|
151 L<Bio::Graphics::Glyph::segments>,
|
|
152 L<Bio::Graphics::Glyph::ruler_arrow>,
|
|
153 L<Bio::Graphics::Glyph::toomany>,
|
|
154 L<Bio::Graphics::Glyph::transcript>,
|
|
155 L<Bio::Graphics::Glyph::transcript2>,
|
|
156 L<Bio::Graphics::Glyph::translation>,
|
|
157 L<Bio::Graphics::Glyph::triangle>,
|
|
158 L<Bio::DB::GFF>,
|
|
159 L<Bio::SeqI>,
|
|
160 L<Bio::SeqFeatureI>,
|
|
161 L<Bio::Das>,
|
|
162 L<GD>
|
|
163
|
|
164 =head1 AUTHOR
|
|
165
|
|
166 Lincoln Stein E<lt>lstein@cshl.orgE<gt>
|
|
167
|
|
168 Copyright (c) 2001 Cold Spring Harbor Laboratory
|
|
169
|
|
170 This library is free software; you can redistribute it and/or modify
|
|
171 it under the same terms as Perl itself. See DISCLAIMER.txt for
|
|
172 disclaimers of warranty.
|
|
173
|
|
174 =cut
|