Graph/BucketSet.pm untested

filter: Statementstmt 0.0% 0 / 55 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 14 Podpod 0.0% 0 / 8 totaltotal 0.0% 0 / 86 CC 3 SCAR 11.0
CC
3
Cov
0%
addRegion
6.0
findNonIntersectingBucket
6.0
BEGIN
2.0
CRAP 3.0
1 package Bio::GMOD::Blast::Graph::BucketSet;
2 BEGIN {
3 $Bio::GMOD::Blast::Graph::BucketSet::AUTHORITY = 'cpan:RBUELS';
4 }
5 BEGIN {
6 $Bio::GMOD::Blast::Graph::BucketSet::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 Carp;
18  
19 use Bio::GMOD::Blast::Graph::BaseObj;
20 use Bio::GMOD::Blast::Graph::IntSpan;
21 use Bio::GMOD::Blast::Graph::Bucket;
22 use Bio::GMOD::Blast::Graph::MyUtils;
23 use Bio::GMOD::Blast::Graph::MyDebug qw( dmsg );
24  
25 @ISA = qw( Bio::GMOD::Blast::Graph::BaseObj );
26  
27 #
28 # used to keep track of exploded HSPs from
29 # one Bio::GMOD::Blast::Graph::HitWrapper. the HSPs are
30 # split into as many lines as required
31 # to make sure they aren't overlapping.
32 #
33  
34 my( $kBucketList ) =
35 Bio::GMOD::Blast::Graph::MyUtils::makeVariableName( "bucket", "list" );
36  
37 ##################################################################
38 sub init {
39 ##################################################################
40 my( $self ) = shift;
41  
42 # note that they aren't stored in
43 # any kind of sorted order; we
44 # always do a linear search.
45 $self->{ $kBucketList } = new Bio::GMOD::Blast::Graph::List();
46 }
47  
48 ##################################################################
49 sub getBucketList {
50 ##################################################################
51 my( $self ) = shift;
52 return( $self->{ $kBucketList } );
53 }
54  
55 ##################################################################
56 sub getCount {
57 ##################################################################
58 my( $self ) = shift;
59  
60 return( $self->getBucketList()->getCount() );
61 }
62  
63 ##################################################################
64 sub addBucket {
65 ##################################################################
66 my( $self, $bucket ) = @_;
67 my( $bucketList ) = $self->getBucketList();
68  
69 #dmsg( "addBucket(): bucket = " . $bucket->toString() );
70 #dmsg( "addBucket(): this = $self, bucketList = $bucketList" );
71 #dmsg( "addBucket(): before = " . join( ", ", @{$bucketList->getElementsRef()} ) );
72 $bucketList->addElement( $bucket );
73 #dmsg( "addBucket(): after = " . join( ", ", @{$bucketList->getElementsRef()} ) );
74 }
75  
76 ##################################################################
77 sub addRegion {
78 ##################################################################X
79 my( $self, $region ) = @_;
80 my( $bucket );
81  
82 $bucket = $self->findNonIntersectingBucket( $region );
83 if( defined($bucket) )
84 {
85 #dmsg( "addRegion(): adding " . $region->run_list() . " to bucket = " . $bucket->toString() );
86 $bucket->addRegion( $region );
87 }
88 else
89 {
90 #dmsg( "addRegion(): no good bucket, creating " . $region->run_list() );
91 $bucket = new Bio::GMOD::Blast::Graph::Bucket( $region );
92 $self->addBucket( $bucket );
93 }
94 }
95  
96 ##################################################################
97 sub findNonIntersectingBucket {
98 ##################################################################
99 my( $self ) = shift;
100 my( $region ) = shift;
101  
102 my( $bucketList ) = $self->getBucketList();
103 my( $foundP ) = 0;
104 my( $testBucket );
105 my( $match );
106 my( $dex );
107  
108 #dmsg( "findNonIntersectingBucket(): region = " . $region->run_list() );
109  
110 for( $dex = 0;
111 $dex < $bucketList->getCount() && !$foundP;
112 $dex++ )
113 {
114 $testBucket = $bucketList->getElementAt( $dex );
115 #dmsg( "findNonIntersectingBucket(): test = " . $testBucket->toString() );
116  
117 if( $testBucket->disjointP( $region ) )
118 {
119 $match = $testBucket;
120 $foundP = 1;
121 }
122 }
123  
124 return( $match );
125 }
126  
127 ##################################################################
128 1;
129 ##################################################################
130  
131 __END__