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

filter: Statementstmt 0.0% 0 / 50 Branchbran 0.0% 0 / 32 Conditioncond 0.0% 0 / 10 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 108 CC 17 SCAR 34.4
CC
17
Cov
0%
draw_connectors
72.0
pad_left
20.0
pad_right
20.0
CRAP 31.1
1 package Bio::Graphics::Glyph::transcript;
2  
3 use strict;
4 use base qw(Bio::Graphics::Glyph::segments);
5  
6 sub pad_left {
7 my $self = shift;
8 return 0 unless $self->{level} == 0;
9 my $pad = $self->SUPER::pad_left;
10 my $strand = $self->feature->strand;
11 return $pad unless defined $strand && $strand < 0;
12 return $self->arrow_length > $pad ? $self->arrow_length : $pad;
13 }
14  
15 sub pad_right {
16 my $self = shift;
17 return 0 unless $self->{level} == 0;
18 my $pad = $self->SUPER::pad_right;
19 my $strand = $self->feature->strand;
20 return $pad unless defined($strand) && $strand > 0;
21 return $self->arrow_length > $pad ? $self->arrow_length : $pad;
22 }
23  
24 sub draw_component {
25 my $self = shift;
26 return unless $self->level > 0;
27 $self->SUPER::draw_component(@_);
28 }
29  
30 sub part_label_merge {
31 my $self = shift;
32 my $label = $self->SUPER::part_label_merge;
33 return $label if defined $label;
34 1;
35 }
36  
37 sub draw_connectors {
38 my $self = shift;
39 my $gd = shift;
40 my ($left,$top) = @_;
41 $self->SUPER::draw_connectors($gd,$left,$top);
42 my @parts = $self->parts; # or return;
43  
44 # H'mmm. No parts. Must be in an intron, so draw intron
45 # spanning entire range
46 if (!@parts) {
47 return unless $self->feature_has_subparts;
48 my($x1,$y1,$x2,$y2) = $self->bounds(0,0);
49 $self->_connector($gd,$left,$top,$x1,$y1,$x1,$y2,$x2,$y1,$x2,$y2);
50 @parts = ($self);
51 }
52  
53 # flip argument makes this confusing
54 # certainly there's a simpler way to express this idea
55 my $strand = $self->feature->strand;
56 my ($first,$last) = ($parts[0],$parts[-1]);
57  
58 ($first,$last) = ($last,$first) if exists $self->{flip};
59  
60 if ($strand >= 0) {
61 my($x1,$y1,$x2,$y2) = $last->bounds(@_);
62 my $center = ($y2+$y1)/2;
63 $self->{flip} ?
64 $self->arrow($gd,$x1,$x1-$self->arrow_length,$center)
65 :
66 $self->arrow($gd,$x2,$x2+$self->arrow_length,$center);
67 }
68  
69 elsif ($strand < 0) {
70 my($x1,$y1,$x2,$y2) = $first->bounds(@_);
71 my $center = ($y2+$y1)/2;
72 $self->{flip } ?
73 $self->arrow($gd,$x2,$x2+$self->arrow_length,$center)
74 :
75 $self->arrow($gd,$x1,$x1 - $self->arrow_length,$center);
76 }
77 }
78  
79 sub arrow_length {
80 my $self = shift;
81 return $self->option('arrow_length') || 8;
82 }
83  
84 # override option() for force the "hat" type of connector
85 sub connector {
86 my $self = shift;
87 return $self->SUPER::connector(@_) if $self->all_callbacks;
88 return ($self->option('connector') || 'hat');
89 }
90  
91  
92 1;
93  
94 __END__