Graph/MapSpace.pm untested

filter: Statementstmt 0.0% 0 / 55 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 15 Podpod 0.0% 0 / 10 totaltotal 0.0% 0 / 82 CC 2 SCAR 9.2
CC
2
Cov
0%
wrapperFitsP
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.5
1 package Bio::GMOD::Blast::Graph::MapSpace;
2 BEGIN {
3 $Bio::GMOD::Blast::Graph::MapSpace::AUTHORITY = 'cpan:RBUELS';
4 }
5 BEGIN {
6 $Bio::GMOD::Blast::Graph::MapSpace::VERSION = '0.06';
7 }
8 #####################################################################
9 #
10 # Cared for by Shuai Weng <shuai@genome.stanford.edu>
11 #
12 # Originally created by John Slenk <jces@genome.stanford.edu>
13 #
14 # You may distribute this module under the same terms as perl itself
15 #-----------------------------------------------------------------
16  
17 use Bio::GMOD::Blast::Graph::BaseObj;
18 use Bio::GMOD::Blast::Graph::MyUtils;
19 use Bio::GMOD::Blast::Graph::MapDefs;
20 use Bio::GMOD::Blast::Graph::HitWrapper;
21 use Bio::GMOD::Blast::Graph::MyDebug qw( assert dmsg );
22  
23 @ISA = qw( Bio::GMOD::Blast::Graph::BaseObj );
24  
25 my $kInitialSpace =
26 Bio::GMOD::Blast::Graph::MyUtils::makeVariableName( "initial", "space" );
27 my $kSpaceRemaining =
28 Bio::GMOD::Blast::Graph::MyUtils::makeVariableName( "space", "remaining" );
29 my $kFullP =
30 Bio::GMOD::Blast::Graph::MyUtils::makeVariableName( "full", "predicate" );
31  
32 #######################################################################
33 sub init {
34 #######################################################################
35 my( $self ) = shift;
36  
37 $self->{ $kInitialSpace } =
38 $self->{ $kSpaceRemaining } =
39 ($Bio::GMOD::Blast::Graph::MapDefs::imgHeight -
40 $Bio::GMOD::Blast::Graph::MapDefs::hspPosInit -
41 $Bio::GMOD::Blast::Graph::MapDefs::imgBottomBorder );
42  
43 #dmsg( "init(): space = ", $self->getSpaceRemaining() );
44 }
45  
46 #######################################################################
47 sub getSpaceRemaining {
48 #######################################################################
49 my( $self ) = shift;
50 return( $self->{ $kSpaceRemaining } );
51 }
52  
53 #######################################################################
54 sub getSpaceUsed {
55 #######################################################################
56 my( $self ) = shift;
57 return( $self->{ $kInitialSpace } - $self->{ $kSpaceRemaining } );
58 }
59  
60 #######################################################################
61 sub putSpaceRemaining {
62 #######################################################################
63 my( $self, $space ) = @_;
64 assert( $space >= 0, "space must be non-negative" );
65 $self->{ $kSpaceRemaining } = $space;
66 }
67  
68 # return true iff the last call to wrapperFitsP returned false.
69 #######################################################################
70 sub getFullP {
71 #######################################################################
72 my( $self ) = shift;
73 return( $self->{ $kFullP } );
74 }
75  
76 #######################################################################
77 sub putFullP {
78 #######################################################################
79 my( $self, $fp ) = @_;
80 $self->{ $kFullP } = $fp;
81 }
82  
83 #######################################################################
84 sub wrapperFitsP {
85 #######################################################################
86 my( $self, $wrap ) = @_;
87 my( $space );
88 my( $wheight );
89 my( $fitsP );
90  
91 $space = $self->getSpaceRemaining();
92  
93 $wheight = $wrap->getHSPLineCount() * $Bio::GMOD::Blast::Graph::MapDefs::hspHeight;
94 if( $wheight <= $space )
95 {
96 $fitsP = 1;
97 #dmsg( "wrapperFitsP(): $wheight <= $space" );
98 }
99 else
100 {
101 $fitsP = 0;
102 #dmsg( "wrapperFitsP(): $wheight > $space" );
103 }
104  
105 $self->{ $kFullP } = (! $fitsP);
106  
107 return( $fitsP );
108 }
109  
110 #######################################################################
111 sub updateFromWrapper {
112 #######################################################################
113 my( $self, $wrap ) = @_;
114 my( $space );
115 my( $count );
116 my( $wheight );
117  
118 $space = $self->getSpaceRemaining();
119 $count = $wrap->getHSPLineCount();
120 $wheight = $count * $Bio::GMOD::Blast::Graph::MapDefs::hspHeight;
121 #dmsg( "updateFromWrapper(): ", $wrap->getName(), "$count $wheight" );
122  
123 assert( $wheight <= $space, "not enough space left" );
124  
125 $self->putSpaceRemaining( $space - $wheight );
126 }
127  
128 #######################################################################
129 1;
130 #######################################################################
131  
132 __END__