annotate variant_effect_predictor/Bio/Graphics/Glyph/primers.pm @ 0:21066c0abaf5 draft

Uploaded
author willmclaren
date Fri, 03 Aug 2012 10:04:48 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
1 package Bio::Graphics::Glyph::primers;
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
2 # package to use for drawing something that looks like
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
3 # primer pairs.
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
4
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
5 use strict;
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
6 use vars '@ISA';
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
7 @ISA = 'Bio::Graphics::Glyph::generic';
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
8 use Bio::Graphics::Glyph::generic;
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
9
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
10 use constant HEIGHT => 4;
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
11
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
12 # we do not need the default amount of room
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
13 #sub calculate_height {
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
14 # my $self = shift;
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
15 # return $self->option('label') ? HEIGHT + $self->labelheight + 2 : HEIGHT;
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
16 #}
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
17
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
18 # override draw method
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
19 sub draw {
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
20 my $self = shift;
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
21 my $gd = shift;
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
22 my ($x1,$y1,$x2,$y2) = $self->calculate_boundaries(@_);
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
23
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
24 my $fg = $self->fgcolor;
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
25 my $a2 = HEIGHT/2;
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
26 my $center = $y1 + $a2;
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
27
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
28 # just draw us as a solid line -- very simple
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
29 if ($x2-$x1 < HEIGHT*2) {
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
30 $gd->line($x1,$center,$x2,$center,$fg);
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
31 return;
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
32 }
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
33
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
34 # otherwise draw two pairs of arrows
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
35 # --> <--
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
36 my $trunc_left = $x1 < $self->panel->left;
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
37 my $trunc_right = $x2 > $self->panel->right;
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
38
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
39 unless ($trunc_left) {
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
40 $gd->line($x1,$center,$x1 + HEIGHT,$center,$fg);
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
41 $gd->line($x1 + HEIGHT,$center,$x1 + HEIGHT - $a2,$center-$a2,$fg);
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
42 $gd->line($x1 + HEIGHT,$center,$x1 + HEIGHT - $a2,$center+$a2,$fg);
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
43 }
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
44
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
45 unless ($trunc_right) {
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
46 $gd->line($x2,$center,$x2 - HEIGHT,$center,$fg);
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
47 $gd->line($x2 - HEIGHT,$center,$x2 - HEIGHT + $a2,$center+$a2,$fg);
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
48 $gd->line($x2 - HEIGHT,$center,$x2 - HEIGHT + $a2,$center-$a2,$fg);
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
49 }
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
50
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
51 # connect the dots if requested
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
52 if ($self->connect) {
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
53 my $c = $self->color('connect_color') || $self->bgcolor;
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
54 $gd->line($x1 + ($trunc_left ? 0 : HEIGHT + 2),$center,
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
55 $x2 - ($trunc_right ? 0 : HEIGHT + 2),$center,
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
56 $c);
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
57 }
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
58
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
59 # add a label if requested
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
60 $self->draw_label($gd,@_) if $self->option('label');
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
61 $self->draw_description($gd,@_) if $self->option('description');
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
62
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
63 }
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
64
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
65 sub connect {
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
66 my $self = shift;
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
67 return $self->option('connect') if defined $self->option('connect');
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
68 1; # default
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
69 }
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
70
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
71 1;
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
72
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
73 __END__
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
74
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
75 =head1 NAME
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
76
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
77 Bio::Graphics::Glyph::primers - The "STS primers" glyph
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
78
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
79 =head1 SYNOPSIS
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
80
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
81 See L<Bio::Graphics::Panel> and L<Bio::Graphics::Glyph>.
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
82
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
83 =head1 DESCRIPTION
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
84
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
85 This glyph draws two arrows oriented towards each other and connected
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
86 by a line of a contrasting color. The length of the arrows is
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
87 immaterial, but the length of the glyph itself corresponds to the
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
88 length of the scaled feature.
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
89
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
90 =head2 OPTIONS
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
91
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
92 In addition to the common options, the following glyph-specific
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
93 options are recognized:
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
94
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
95 Option Description Default
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
96 ------ ----------- -------
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
97
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
98 -connect Whether to connect the true
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
99 two arrowheads by a line.
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
100
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
101 -connect_color The color to use for the bgcolor
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
102 connecting line.
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
103
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
104 =head1 BUGS
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
105
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
106 Please report them.
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
107
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
108 =head1 SEE ALSO
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
109
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
110
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
111 L<Bio::Graphics::Panel>,
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
112 L<Bio::Graphics::Glyph>,
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
113 L<Bio::Graphics::Glyph::arrow>,
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
114 L<Bio::Graphics::Glyph::cds>,
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
115 L<Bio::Graphics::Glyph::crossbox>,
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
116 L<Bio::Graphics::Glyph::diamond>,
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
117 L<Bio::Graphics::Glyph::dna>,
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
118 L<Bio::Graphics::Glyph::dot>,
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
119 L<Bio::Graphics::Glyph::ellipse>,
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
120 L<Bio::Graphics::Glyph::extending_arrow>,
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
121 L<Bio::Graphics::Glyph::generic>,
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
122 L<Bio::Graphics::Glyph::graded_segments>,
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
123 L<Bio::Graphics::Glyph::heterogeneous_segments>,
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
124 L<Bio::Graphics::Glyph::line>,
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
125 L<Bio::Graphics::Glyph::pinsertion>,
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
126 L<Bio::Graphics::Glyph::primers>,
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
127 L<Bio::Graphics::Glyph::rndrect>,
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
128 L<Bio::Graphics::Glyph::segments>,
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
129 L<Bio::Graphics::Glyph::ruler_arrow>,
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
130 L<Bio::Graphics::Glyph::toomany>,
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
131 L<Bio::Graphics::Glyph::transcript>,
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
132 L<Bio::Graphics::Glyph::transcript2>,
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
133 L<Bio::Graphics::Glyph::translation>,
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
134 L<Bio::Graphics::Glyph::triangle>,
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
135 L<Bio::DB::GFF>,
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
136 L<Bio::SeqI>,
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
137 L<Bio::SeqFeatureI>,
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
138 L<Bio::Das>,
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
139 L<GD>
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
140
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
141 =head1 AUTHOR
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
142
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
143 Allen Day E<lt>day@cshl.orgE<gt>.
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
144
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
145 Copyright (c) 2001 Cold Spring Harbor Laboratory
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
146
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
147 This library is free software; you can redistribute it and/or modify
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
148 it under the same terms as Perl itself. See DISCLAIMER.txt for
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
149 disclaimers of warranty.
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
150
21066c0abaf5 Uploaded
willmclaren
parents:
diff changeset
151 =cut