0
|
1 package Bio::Graphics::Glyph::transcript;
|
|
2 # $Id: transcript.pm,v 1.12.2.1 2003/07/05 00:32:04 lstein Exp $
|
|
3
|
|
4 use strict;
|
|
5 use Bio::Graphics::Glyph::segments;
|
|
6 use vars '@ISA';
|
|
7 @ISA = qw( Bio::Graphics::Glyph::segments);
|
|
8
|
|
9 sub pad_left {
|
|
10 my $self = shift;
|
|
11 my $pad = $self->SUPER::pad_left;
|
|
12 return $pad if $self->{level} > 0;
|
|
13 my $strand = $self->feature->strand;
|
|
14 return $pad unless defined $strand && $strand < 0;
|
|
15 return $self->arrow_length > $pad ? $self->arrow_length : $pad;
|
|
16 }
|
|
17
|
|
18 sub pad_right {
|
|
19 my $self = shift;
|
|
20 my $pad = $self->SUPER::pad_right;
|
|
21 return $pad if $self->{level} > 0;
|
|
22 my $strand = $self->feature->strand;
|
|
23 return $pad unless defined($strand) && $strand > 0;
|
|
24 return $self->arrow_length > $pad ? $self->arrow_length : $pad;
|
|
25 }
|
|
26
|
|
27 sub draw_component {
|
|
28 my $self = shift;
|
|
29 return unless $self->level > 0;
|
|
30 $self->SUPER::draw_component(@_);
|
|
31 }
|
|
32
|
|
33 sub draw_connectors {
|
|
34 my $self = shift;
|
|
35 my $gd = shift;
|
|
36 my ($left,$top) = @_;
|
|
37 $self->SUPER::draw_connectors($gd,$left,$top);
|
|
38 my @parts = $self->parts;
|
|
39
|
|
40 # H'mmm. No parts. Must be in an intron, so draw intron
|
|
41 # spanning entire range
|
|
42 if (!@parts) {
|
|
43 my($x1,$y1,$x2,$y2) = $self->bounds(0,0);
|
|
44 $self->_connector($gd,$left,$top,$x1,$y1,$x1,$y2,$x2,$y1,$x2,$y2);
|
|
45 @parts = $self;
|
|
46 }
|
|
47
|
|
48 # flip argument makes this confusing
|
|
49 # certainly there's a simpler way to express this idea
|
|
50 my $strand = $self->feature->strand;
|
|
51 my ($first,$last) = ($parts[0],$parts[-1]);
|
|
52 ($first,$last) = ($last,$first) if exists $self->{flip};
|
|
53
|
|
54 if ($strand >= 0) {
|
|
55 my($x1,$y1,$x2,$y2) = $last->bounds(@_);
|
|
56 my $center = ($y2+$y1)/2;
|
|
57 $self->{flip} ?
|
|
58 $self->arrow($gd,$x1,$x1-$self->arrow_length,$center)
|
|
59 :
|
|
60 $self->arrow($gd,$x2,$x2+$self->arrow_length,$center);
|
|
61 } else {
|
|
62 my($x1,$y1,$x2,$y2) = $first->bounds(@_);
|
|
63 my $center = ($y2+$y1)/2;
|
|
64 $self->{flip } ?
|
|
65 $self->arrow($gd,$x2,$x2+$self->arrow_length,$center)
|
|
66 :
|
|
67 $self->arrow($gd,$x1,$x1 - $self->arrow_length,$center);
|
|
68 }
|
|
69 }
|
|
70
|
|
71 sub arrow_length {
|
|
72 my $self = shift;
|
|
73 return $self->option('arrow_length') || 8;
|
|
74 }
|
|
75
|
|
76 # override option() for force the "hat" type of connector
|
|
77 sub connector {
|
|
78 my $self = shift;
|
|
79 return $self->SUPER::connector(@_) if $self->all_callbacks;
|
|
80 return ($self->option('connector') || 'hat');
|
|
81 }
|
|
82
|
|
83
|
|
84 1;
|
|
85
|
|
86 __END__
|
|
87
|
|
88 =head1 NAME
|
|
89
|
|
90 Bio::Graphics::Glyph::transcript - The "transcript" glyph
|
|
91
|
|
92 =head1 SYNOPSIS
|
|
93
|
|
94 See L<Bio::Graphics::Panel> and L<Bio::Graphics::Glyph>.
|
|
95
|
|
96 =head1 DESCRIPTION
|
|
97
|
|
98 This glyph is used for drawing transcripts. It is essentially a
|
|
99 "segments" glyph in which the connecting segments are hats. The
|
|
100 direction of the transcript is indicated by an arrow attached to the
|
|
101 end of the glyph.
|
|
102
|
|
103 =head2 OPTIONS
|
|
104
|
|
105 The following options are standard among all Glyphs. See
|
|
106 L<Bio::Graphics::Glyph> for a full explanation.
|
|
107
|
|
108 Option Description Default
|
|
109 ------ ----------- -------
|
|
110
|
|
111 -fgcolor Foreground color black
|
|
112
|
|
113 -outlinecolor Synonym for -fgcolor
|
|
114
|
|
115 -bgcolor Background color turquoise
|
|
116
|
|
117 -fillcolor Synonym for -bgcolor
|
|
118
|
|
119 -linewidth Line width 1
|
|
120
|
|
121 -height Height of glyph 10
|
|
122
|
|
123 -font Glyph font gdSmallFont
|
|
124
|
|
125 -connector Connector type 0 (false)
|
|
126
|
|
127 -connector_color
|
|
128 Connector color black
|
|
129
|
|
130 -label Whether to draw a label 0 (false)
|
|
131
|
|
132 -description Whether to draw a description 0 (false)
|
|
133
|
|
134 In addition, the alignment glyph recognizes the following
|
|
135 glyph-specific options:
|
|
136
|
|
137 Option Description Default
|
|
138 ------ ----------- -------
|
|
139
|
|
140 -arrow_length Length of the directional 8
|
|
141 arrow.
|
|
142
|
|
143 =head1 BUGS
|
|
144
|
|
145 Please report them.
|
|
146
|
|
147 =head1 SEE ALSO
|
|
148
|
|
149
|
|
150 L<Bio::Graphics::Panel>,
|
|
151 L<Bio::Graphics::Glyph>,
|
|
152 L<Bio::Graphics::Glyph::arrow>,
|
|
153 L<Bio::Graphics::Glyph::cds>,
|
|
154 L<Bio::Graphics::Glyph::crossbox>,
|
|
155 L<Bio::Graphics::Glyph::diamond>,
|
|
156 L<Bio::Graphics::Glyph::dna>,
|
|
157 L<Bio::Graphics::Glyph::dot>,
|
|
158 L<Bio::Graphics::Glyph::ellipse>,
|
|
159 L<Bio::Graphics::Glyph::extending_arrow>,
|
|
160 L<Bio::Graphics::Glyph::generic>,
|
|
161 L<Bio::Graphics::Glyph::graded_segments>,
|
|
162 L<Bio::Graphics::Glyph::heterogeneous_segments>,
|
|
163 L<Bio::Graphics::Glyph::line>,
|
|
164 L<Bio::Graphics::Glyph::pinsertion>,
|
|
165 L<Bio::Graphics::Glyph::primers>,
|
|
166 L<Bio::Graphics::Glyph::rndrect>,
|
|
167 L<Bio::Graphics::Glyph::segments>,
|
|
168 L<Bio::Graphics::Glyph::ruler_arrow>,
|
|
169 L<Bio::Graphics::Glyph::toomany>,
|
|
170 L<Bio::Graphics::Glyph::transcript>,
|
|
171 L<Bio::Graphics::Glyph::transcript2>,
|
|
172 L<Bio::Graphics::Glyph::translation>,
|
|
173 L<Bio::Graphics::Glyph::triangle>,
|
|
174 L<Bio::DB::GFF>,
|
|
175 L<Bio::SeqI>,
|
|
176 L<Bio::SeqFeatureI>,
|
|
177 L<Bio::Das>,
|
|
178 L<GD>
|
|
179
|
|
180 =head1 AUTHOR
|
|
181
|
|
182 Lincoln Stein E<lt>lstein@cshl.orgE<gt>
|
|
183
|
|
184 Copyright (c) 2001 Cold Spring Harbor Laboratory
|
|
185
|
|
186 This library is free software; you can redistribute it and/or modify
|
|
187 it under the same terms as Perl itself. See DISCLAIMER.txt for
|
|
188 disclaimers of warranty.
|
|
189
|
|
190 =cut
|