Cluster.pm

filter: Statementstmt 7.4% 8 / 107 Branchbran 0.0% 0 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 12.5% 2 / 16 Podpod 100% 14 / 14 totaltotal 15.6% 24 / 153 CC 12 SCAR 19.1
CC
12
Cov
7%
get_all_subsets
12.0
get_available_types
12.0
get_all_seqs
12.0
CRAP 6.7
« Sequence.pm ↑ Summary Util/Search.pm »
1 package Bio::DOOP::Cluster;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =head1 NAME
7  
8 Bio::DOOP::Cluster - DoOP cluster object
9  
10 =head1 VERSION
11  
12 Version 0.12
13  
14 =cut
15  
16 2 our $VERSION = '0.12';
17  
18 =head1 SYNOPSIS
19  
20 $cluster = Bio::DOOP::Cluster->new($db,"81007400","500");
21 print $cluster->get_cluster_id;
22  
23 =head1 DESCRIPTION
24
25 This object represents a cluster. You can access its properties through the methods.
26  
27 =head1 AUTHORS
28  
29 Tibor Nagy, Godollo, Hungary and Endre Sebestyen, Martonvasar, Hungary
30  
31 =head1 METHODS
32  
33 =head2 new
34  
35 Creates a new cluster object from the cluster id and promoter type. Every promoter cluster has a unique
36 identifier. This is the cluster id. There are three promoter sizes (500,1000,3000 bp), so a unique
37 cluster is identified by two parameters : cluster id and promoter type.
38  
39 Return type: Bio::DOOP::Cluster object
40  
41 $cluster = Bio::DOOP::Cluster->new($db,"8010110","500");
42  
43 =cut
44  
45 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
46 0 my $self = {};
47 0 my $dummy = shift;
48 0 my $db = shift;
49 0 $self->{ID} = shift; # cluster_id field in the MySQL tables.
50 0 $self->{PROMO_TYPE} = shift;
51  
52 0 my $id = $self->{ID};
53 0 my $size = $self->{PROMO_TYPE};
54  
55 0 my $ret = $db->query("SELECT * FROM cluster WHERE cluster_id=\"$id\" AND cluster_promoter_type=\"$size\";");
56  
57 0 ▶ if ($#$ret == -1){
Branch: 1 branch
BranchTrueFalseTotal
if ($ret->$#* == -1) 0 0 0
58 0 return(-1);
59 }
60  
61 0 my @cluster = @{$$ret[0]};
62  
63 0 $self->{PRIMARY} = $cluster[0];
64 0 $self->{TYPE} = $cluster[3];
65 0 $self->{DATE} = $cluster[4];
66 0 $self->{VERSION} = $cluster[5];
67 0 $self->{DB} = $db;
68 0 bless $self;
69 0 return ($self);
70 }
71  
72 =head2 new_by_id
73  
74 Used by internal MySQL queries.
75  
76 Return type: Bio::DOOP::Cluster object
77  
78 Bio::DOOP::Cluster->new_by_id($db,"2453");
79  
80 =cut
81  
82  
83 0 ▶sub new_by_id {
Subroutine new_by_id: not called CC=2 SCAR=17.9
Pod documented
84 0 my $self = {};
85 0 my $dummy = shift;
86 0 my $db = shift;
87 0 $self->{PRIMARY} = shift; # cluster_id field in the MySQL tables.
88  
89 0 my $id = $self->{PRIMARY};
90  
91 0 my $ret = $db->query("SELECT * FROM cluster WHERE cluster_primary_id=\"$id\";");
92  
93 0 ▶ if ($#$ret == -1){
Branch: 1 branch
BranchTrueFalseTotal
if ($ret->$#* == -1) 0 0 0
94 0 return(-1);
95 }
96  
97 0 my @cluster = @{$$ret[0]};
98  
99 0 $self->{PRIMARY} = $cluster[0];
100 0 $self->{PROMO_TYPE} = $cluster[1];
101 0 $self->{ID} = $cluster[2];
102 0 $self->{TYPE} = $cluster[3];
103 0 $self->{DATE} = $cluster[4];
104 0 $self->{VERSION} = $cluster[5];
105 0 $self->{DB} = $db;
106 0 bless $self;
107 0 return ($self);
108 }
109  
110  
111 =head2 get_id
112  
113 Returns the MySQL id of the cluster
114  
115 Return type: string
116  
117 $cluster_id = $cluster->get_id;
118  
119 =cut
120  
121 0 ▶sub get_id {
Subroutine get_id: not called CC=1 SCAR=6.9
Pod documented
122 0 my $self = shift;
123 0 return $self->{PRIMARY};
124 }
125  
126 =head2 get_cluster_id
127  
128 Returns the cluster id of the cluster.
129  
130 Return type: string
131  
132 $cluster_id = $cluster->get_cluster_id;
133  
134 =cut
135  
136 0 ▶sub get_cluster_id {
Subroutine get_cluster_id: not called CC=1 SCAR=6.9
Pod documented
137 0 my $self = shift;
138 0 return $self->{ID};
139 }
140  
141 =head2 get_promo_type
142  
143 Returns the size of the promoter (500,1000,3000 bp).
144  
145 Return type: string
146  
147 $pt = $cluster->get_promo_type;
148  
149 =cut
150  
151 0 ▶sub get_promo_type {
Subroutine get_promo_type: not called CC=1 SCAR=6.9
Pod documented
152 0 my $self = shift;
153 0 return($self->{PROMO_TYPE});
154 }
155  
156 =head2 get_type
157  
158 Returns the type of the promoter (The available return types are the following: 1,2,3,4,5n,6n).
159 See http://doop.abc.hu for more details.
160  
161 Return type: string
162  
163 print $cluster->get_type;
164  
165 =cut
166  
167 0 ▶sub get_type {
Subroutine get_type: not called CC=1 SCAR=6.9
Pod documented
168 0 my $self = shift;
169 0 return($self->{TYPE});
170 }
171  
172 =head2 get_date
173  
174 Returns the date when the cluster was last modified.
175  
176 Return type: string
177  
178 $date = $cluster->get_date;
179  
180 =cut
181  
182 0 ▶sub get_date {
Subroutine get_date: not called CC=1 SCAR=6.9
Pod documented
183 0 my $self = shift;
184 0 return($self->{DATE});
185 }
186  
187 =head2 get_version
188  
189 Returns the version of the cluster.
190  
191 Return type: string
192  
193 print $cluster->get_version;
194  
195 =cut
196  
197 0 ▶sub get_version {
Subroutine get_version: not called CC=1 SCAR=6.9
Pod documented
198 0 my $self = shift;
199 0 return($self->{VERSION});
200 }
201  
202 =head2 get_all_subsets
203  
204 Returns the arrayref of all subsets associated with the cluster.
205  
206 Return type: arrayref, the array containing Bio::DOOP::ClusterSubset objects
207  
208 @subsets = @{$cluster->get_all_subsets};
209  
210 =cut
211  
212 0 ▶sub get_all_subsets {
Subroutine get_all_subsets: not called CC=3 SCAR=24.8
Pod documented
213 0 my $self = shift;
214 0 my $id = $self->{PRIMARY};
215 0 my $ret = $self->{DB}->query("SELECT subset_primary_id FROM cluster_subset WHERE cluster_primary_id = $id");
216  
217 0 ▶ if ($#$ret == -1){
Branch: 1 branch
BranchTrueFalseTotal
if ($ret->$#* == -1) 0 0 0
218 0 return(-1);
219 }
220  
221 0 my @subsets;
222 0 for my $i (@$ret){
223 0 push @subsets,Bio::DOOP::ClusterSubset->new($self->{DB},$$i[0]);
224 }
225  
226 0 return(\@subsets);
227 }
228  
229 =head2 get_subset_by_type
230  
231 Returns a subset of a cluster, specified by type.
232  
233 Return type: Bio::DOOP::ClusterSubset object
234  
235 $subset = $cluster->get_subset_by_type("B");
236 if ($subset == -1){
237 print"No subsets! Try another subset type\n";
238 }
239  
240 =cut
241  
242 0 ▶sub get_subset_by_type {
Subroutine get_subset_by_type: not called CC=2 SCAR=17.9
Pod documented
243 0 my $self = shift;
244 0 my $type = shift;
245  
246 0 my $id = $self->{PRIMARY};
247 0 my $ret = $self->{DB}->query("SELECT subset_primary_id FROM cluster_subset WHERE cluster_primary_id = $id AND subset_type = \"$type\"");
248  
249 0 ▶ if ($#$ret == -1){
Branch: 1 branch
BranchTrueFalseTotal
if ($ret->$#* == -1) 0 0 0
250 0 return(-1);
251 }
252  
253 0 my $subset = Bio::DOOP::ClusterSubset->new($self->{DB},$$ret[0]->[0]);
254 0 return($subset);
255 }
256  
257 =head2 get_available_types
258  
259 Returns all available cluster subset types.
260  
261 Return type: arrayref of strings
262  
263 @types = @{$cluster->get_available_types};
264  
265 =cut
266  
267 0 ▶sub get_available_types {
Subroutine get_available_types: not called CC=3 SCAR=24.8
Pod documented
268 0 my $self = shift;
269 0 my $id = $self->{PRIMARY};
270 0 my $ret = $self->{DB}->query("SELECT subset_type FROM cluster_subset WHERE cluster_primary_id = $id");
271  
272 0 ▶ if ($#$ret == -1){
Branch: 1 branch
BranchTrueFalseTotal
if ($ret->$#* == -1) 0 0 0
273 0 return(-1);
274 }
275  
276 0 my @types;
277  
278 0 for my $i (@$ret){
279 0 push @types,$$i[0];
280 }
281 0 return(\@types);
282 }
283  
284 =head2 get_all_seqs
285  
286 Returns the arrayref of all sequences associated with the cluster.
287  
288 Return type: arrayref, the array containig Bio::DOOP::Sequence objects
289  
290 @seqs = @{$cluster->get_all_seqs};
291  
292 =cut
293  
294 0 ▶sub get_all_seqs {
Subroutine get_all_seqs: not called CC=3 SCAR=24.8
Pod documented
295 0 my $self = shift;
296 0 my $id = $self->{PRIMARY};
297 0 my $ret = $self->{DB}->query("SELECT DISTINCT(sequence_primary_id) FROM subset_xref WHERE cluster_primary_id = $id;");
298  
299 0 ▶ if ($#$ret == -1){
Branch: 1 branch
BranchTrueFalseTotal
if ($ret->$#* == -1) 0 0 0
300 0 return(-1);
301 }
302  
303 0 my @seqs;
304 0 for my $i (@$ret){
305 0 push @seqs,Bio::DOOP::Sequence->new($self->{DB},$$i[0]);
306 }
307  
308 0 return(\@seqs);
309 }
310  
311 =head2 get_orig_subset
312  
313 Returns the original subset, containing the whole cluster.
314  
315 Return type: Bio::DOOP::ClusterSubset object
316  
317 @subsets = @{$cluster->get_orig_subset};
318  
319 =cut
320  
321 0 ▶sub get_orig_subset {
Subroutine get_orig_subset: not called CC=2 SCAR=17.9
Pod documented
322 0 my $self = shift;
323 0 my $id = $self->{PRIMARY};
324 0 my $ret = $self->{DB}->query("SELECT subset_primary_id FROM cluster_subset WHERE cluster_primary_id = $id AND original = \"y\"");
325 0 ▶ if ($#$ret == -1){
Branch: 1 branch
BranchTrueFalseTotal
if ($ret->$#* == -1) 0 0 0
326 0 return(-1);
327 }
328 0 my $subset = Bio::DOOP::ClusterSubset->new($self->{DB},$$ret[0]->[0]);
329 0 return($subset);
330 }
331  
332 =head2 get_ref_seq
333  
334 Returns the cluster reference sequence (human or arabidopsis).
335  
336 Return type: Bio::DOOP::Sequence object
337  
338 $refseq = $cluster->get_ref_seq;
339  
340 =cut
341  
342 0 ▶sub get_ref_seq {
Subroutine get_ref_seq: not called CC=2 SCAR=17.9
Pod documented
343 0 my $self = shift;
344 0 my $id = $self->{PRIMARY};
345  
346 0 my $ret = $self->{DB}->query("SELECT sequence.sequence_primary_id FROM sequence, taxon_annotation, subset_xref WHERE cluster_primary_id = $id AND (taxon_taxid = '3702' OR taxon_taxid = '9606') AND taxon_annotation.taxon_primary_id = sequence.taxon_primary_id AND sequence.sequence_primary_id = subset_xref.sequence_primary_id;");
347
348 0 ▶ if ($#$ret == -1){
Branch: 1 branch
BranchTrueFalseTotal
if ($ret->$#* == -1) 0 0 0
349 0 return(-1);
350 }
351  
352 0 my $seq = Bio::DOOP::Sequence->new($self->{DB},$$ret[0]->[0]);
353 0 return($seq);
354 }
355  
356 2 1;
« Sequence.pm ↑ Summary Util/Search.pm »