blib/lib/Bio/Graphics/Glyph/primers.pm untested

filter: Statementstmt 0.0% 0 / 41 Branchbran 0.0% 0 / 22 Conditioncond 0.0% 0 / 9 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 79 CC 12 SCAR 45.2
CC
12
Cov
0%
draw_component
132.0
connect
6.0
BEGIN
2.0
CRAP 91.9
1 package Bio::Graphics::Glyph::primers;
2 # package to use for drawing something that looks like
3 # primer pairs.
4  
5 use strict;
6 use base qw(Bio::Graphics::Glyph::generic);
7  
8 use constant HEIGHT => 8;
9  
10 # override draw method
11 sub draw_component {
12 my $self = shift;
13 my $gd = shift;
14 my ($x1,$y1,$x2,$y2) = $self->calculate_boundaries(@_);
15 my $height = $self->option('height') || $self->option('size') || HEIGHT;
16  
17 my $fg = $self->fgcolor;
18 my $a2 = $height/2;
19 my $center = $y1 + $a2;
20  
21  
22 # just draw us as a solid line -- very simple
23 if ($x2-$x1 < $height*2) {
24 $gd->line($x1,$center,$x2,$center,$fg);
25 return;
26 }
27  
28 # otherwise draw two pairs of arrows
29 # --> <--
30 my $trunc_left = $x1 < $self->panel->left;
31 my $trunc_right = $x2 > $self->panel->right;
32  
33 unless ($trunc_left) {
34 $gd->setThickness(2) if $height > 6;
35 $gd->line($x1,$center,$x1 + $height,$center,$fg);
36 $gd->line($x1 + $height,$center,$x1 + $height - $a2,$center-$a2,$fg);
37 $gd->line($x1 + $height,$center,$x1 + $height - $a2,$center+$a2,$fg);
38 $gd->setThickness(1);
39 }
40  
41 unless ($trunc_right) {
42 $gd->setThickness(2) if $height > 6;
43 $gd->line($x2,$center,$x2 - $height,$center,$fg);
44 $gd->line($x2 - $height,$center,$x2 - $height + $a2,$center+$a2,$fg);
45 $gd->line($x2 - $height,$center,$x2 - $height + $a2,$center-$a2,$fg);
46 $gd->setThickness(1);
47 }
48  
49 # connect the dots if requested
50 if ($self->connect) {
51 my $c = $self->color('connect_color') || $self->bgcolor;
52 $gd->line($x1 + ($trunc_left ? 0 : $height + 2),$center,
53 $x2 - ($trunc_right ? 0 : $height + 2),$center,
54 $c);
55 }
56  
57 # add a label if requested
58 $self->draw_label($gd,@_) if $self->option('label');
59 $self->draw_description($gd,@_) if $self->option('description');
60  
61 }
62  
63 sub connect {
64 my $self = shift;
65 return $self->option('connect') if defined $self->option('connect');
66 1; # default
67 }
68  
69 1;
70  
71 __END__