0
|
1 #
|
|
2 # Ensembl module for Bio::EnsEMBL::Funcgen::Probe
|
|
3 #
|
|
4
|
|
5
|
|
6 =head1 LICENSE
|
|
7
|
|
8 Copyright (c) 1999-2011 The European Bioinformatics Institute and
|
|
9 Genome Research Limited. All rights reserved.
|
|
10
|
|
11 This software is distributed under a modified Apache license.
|
|
12 For license details, please see
|
|
13
|
|
14 http://www.ensembl.org/info/about/code_licence.html
|
|
15
|
|
16 =head1 CONTACT
|
|
17
|
|
18 Please email comments or questions to the public Ensembl
|
|
19 developers list at <ensembl-dev@ebi.ac.uk>.
|
|
20
|
|
21 Questions may also be sent to the Ensembl help desk at
|
|
22 <helpdesk@ensembl.org>.
|
|
23
|
|
24
|
|
25 =head1 NAME
|
|
26
|
|
27 Bio::EnsEMBL::Funcgen::Probe - A module to represent a nucleotide probe.
|
|
28
|
|
29 =head1 SYNOPSIS
|
|
30
|
|
31 use Bio::EnsEMBL::Funcgen::Probe;
|
|
32
|
|
33 #
|
|
34
|
|
35 my $probe = Bio::EnsEMBL::Funcgen::Probe->new(
|
|
36 -PROBE_SET => $probe_set,
|
|
37 -NAME => 'Probe-1',
|
|
38 -ARRAY => $array,
|
|
39 -ARRAY_CHIP_ID => $ac_dbid,
|
|
40 -CLASS => "EXPERIMENTAL",
|
|
41 );
|
|
42
|
|
43 =head1 DESCRIPTION
|
|
44
|
|
45 An Probe object represents an probe on a microarray. The data (currently the
|
|
46 name, probe_set_id, length, pair_index and class) are stored
|
|
47 in the oligo_probe table.
|
|
48
|
|
49 For Affy arrays, a probe can be part of more than one array, but only part of
|
|
50 one probeset. On each Affy array the probe has a slightly different name. For
|
|
51 example, two different complete names for the same probe might be
|
|
52 DrosGenome1:AFFX-LysX-5_at:535:35; and Drosophila_2:AFFX-LysX-5_at:460:51;. In
|
|
53 the database, these two probes will have the same oligo_probe_id. Thus the same
|
|
54 Affy probe can have a number of different names and complete names depending on
|
|
55 which array it is on.
|
|
56
|
|
57 =cut
|
|
58
|
|
59 use strict;
|
|
60 use warnings;
|
|
61
|
|
62 package Bio::EnsEMBL::Funcgen::Probe;
|
|
63
|
|
64 use Bio::EnsEMBL::Utils::Argument qw( rearrange ) ;
|
|
65 use Bio::EnsEMBL::Utils::Exception qw( throw warning );
|
|
66 use Bio::EnsEMBL::Funcgen::Storable;
|
|
67
|
|
68 use vars qw(@ISA);
|
|
69 @ISA = qw(Bio::EnsEMBL::Funcgen::Storable);
|
|
70
|
|
71
|
|
72 =head2 new
|
|
73
|
|
74 Arg [-NAME] : string - probe name
|
|
75 Used when the probe is on one array.
|
|
76 Arg [-NAMES] : Listref of strings - probe names
|
|
77 Used when the probe is on multiple arrays.
|
|
78 Arg [-ARRAY] : Bio::EnsEMBL::Funcgen::Array
|
|
79 Used when the probe is on one array.
|
|
80 Arg [-ARRAYS] : Listref of Bio::EnsEMBL::Funcgen::Array
|
|
81 Used when the probe is on multiple arrays.
|
|
82 Arg [-ARRAY_CHIP_ID] : int - array_chip db ID
|
|
83 Used when the probe is on one array.
|
|
84 Arg [-ARRAY_CHIP_IDS] : Listref of ints - array_chip dbIDs
|
|
85 Used when the probe is on multiple array chips
|
|
86 Arg [-NAMES] : Listref of ints - arary_chip db IDs
|
|
87 Used when the probe is on multiple arrays.
|
|
88 Arg [-PROBE_SET] : Bio::EnsEMBL::ProbeSet
|
|
89 Each probe is part of one(and only one) probeset, if not probe set
|
|
90 then probeset = probe i.e. probe_set size = 1
|
|
91 Arg [-LENGTH] : int - probe length
|
|
92 Will obviously be the same for all probes if same probe
|
|
93 is on multiple arrays.
|
|
94 Arg [-CLASS] : string - probe class e.g. CONTROL, EXPERIMENTAL
|
|
95 Will be the same for all probes if same probe is on
|
|
96 multiple arrays.
|
|
97 Arg [-DESCRIPTION] : (optional) string - description
|
|
98
|
|
99
|
|
100 Example : my $probe = Bio::EnsEMBL::Probe->new(
|
|
101 -NAME => 'Probe-1',
|
|
102 -PROBE_SET => $probe_set,
|
|
103 -ARRAY => $array,
|
|
104 -ARRAY_CHIP_ID => $array_chip_id,
|
|
105 -LENGTH => 25,
|
|
106 -CLASS => 'EXPERIMENTAL',
|
|
107 -DESCRIPTION => 'Some useful description',
|
|
108
|
|
109 );
|
|
110 Description: Creates a new Bio::EnsEMBL::Probe object.
|
|
111 Returntype : Bio::EnsEMBL::Probe
|
|
112 Exceptions : Throws if not supplied with probe name(s) and array(s)
|
|
113 Caller : General
|
|
114 Status : Medium Risk
|
|
115
|
|
116 =cut
|
|
117
|
|
118 sub new {
|
|
119 my $caller = shift;
|
|
120
|
|
121 my $class = ref($caller) || $caller;
|
|
122
|
|
123 my $self = $class->SUPER::new(@_);
|
|
124
|
|
125 my (
|
|
126 $names, $name,
|
|
127 $array_chip_ids, $array_chip_id,
|
|
128 $arrays, $array,
|
|
129 $probeset, $aclass,
|
|
130 $length, $desc
|
|
131 ) = rearrange([
|
|
132 'NAMES', 'NAME',
|
|
133 'ARRAY_CHIP_IDS', 'ARRAY_CHIP_ID',
|
|
134 'ARRAYS', 'ARRAY',
|
|
135 'PROBE_SET', 'CLASS',
|
|
136 'LENGTH', 'DESCRIPTION'
|
|
137 ], @_);
|
|
138
|
|
139
|
|
140 @$names = ($name) if(ref($names) ne "ARRAY");
|
|
141 @$array_chip_ids = ($array_chip_id) if (ref($array_chip_ids) ne "ARRAY");
|
|
142 @$arrays = ($array) if (ref($arrays) ne "ARRAY");
|
|
143
|
|
144 #We need to record duplicates for each probe_set i.e. each array.
|
|
145 #the relationship is really array_chip to name, as everything else stays the same
|
|
146 #can't have same probe_set_id as this wouldn't maintain relationship
|
|
147 #need unique ps id's or array_chip_id in probe table?
|
|
148 #Then we can miss probeset id's out totally if required
|
|
149 #or should we just duplicate everything with unique db IDs
|
|
150
|
|
151
|
|
152 if (defined $$names[0]) {
|
|
153
|
|
154 if(scalar(@$names) != scalar(@$array_chip_ids)){
|
|
155 throw("You have not specified valid name:array_chip_id pairs\nYou need a probe name for each Array");
|
|
156 }
|
|
157
|
|
158 if(defined $$arrays[0]){
|
|
159 if(scalar(@$names) != scalar(@$arrays)){
|
|
160 throw("You have not specified valid name:Array pairs\nYou need a probe name for each Array\n");
|
|
161 }
|
|
162 }
|
|
163 else{
|
|
164 warn("You have not specified and Array objects, this will result in multiple/redundant queries based on the array_chip_id\nYou should pass Array objects to speed up this process");
|
|
165 #Is this true? We should cache this in the ArrayChip and make sure we're caching it in the caller.
|
|
166 }
|
|
167
|
|
168 # Probe(s) have been specified
|
|
169 # Different names reflect different array
|
|
170
|
|
171 for my $i(0..$#{$names}){
|
|
172 $self->add_array_chip_probename($$array_chip_ids[$i], $$names[$i], $$arrays[$i]);
|
|
173 }
|
|
174 } else {
|
|
175 throw('You need to provide a probe name (or names) to create an Probe');
|
|
176 }
|
|
177
|
|
178 $self->probeset($probeset) if defined $probeset;
|
|
179 $self->class($aclass) if defined $aclass;
|
|
180 $self->length($length) if defined $length;
|
|
181 $self->description($desc) if defined $desc;
|
|
182
|
|
183 return $self;
|
|
184 }
|
|
185
|
|
186 #only takes single values for array and array_chip
|
|
187 #as we're shortcuting the constructor and simply blessing the hash
|
|
188 #therefore attr keys should not be lc and not prefix with '-'
|
|
189
|
|
190 =head2 new_fast
|
|
191
|
|
192 Args : Hashref with all internal attributes set
|
|
193 Example : none
|
|
194 Description: Quick and dirty version of new. Only works if the code is very
|
|
195 disciplined. Cannot add array chip probe names unless we recreate
|
|
196 the data structure in the caller.
|
|
197 Returntype : Bio::EnsEMBL::Funcgen::Probe
|
|
198 Exceptions : None
|
|
199 Caller : General
|
|
200 Status : At Risk
|
|
201
|
|
202 =cut
|
|
203
|
|
204 sub new_fast {
|
|
205 bless ($_[1], $_[0]);
|
|
206 }
|
|
207
|
|
208
|
|
209
|
|
210 =head2 add_array_chip_probename
|
|
211
|
|
212 Arg [1] : int - db ID of array_chip
|
|
213 Arg [2] : string - probe name
|
|
214 Arg [3] : Bio::EnsEMBL::Funcgen::Array
|
|
215 Example : $probe->add_array_chip_probename($ac_dbid, $probename, $array);
|
|
216 Description: Adds a probe name / array pair to a probe, allowing incremental
|
|
217 generation of a probe.
|
|
218 Returntype : None
|
|
219 Exceptions : None
|
|
220 Caller : General,
|
|
221 Probe->new(),
|
|
222 ProbeAdaptor->_obj_from_sth(),
|
|
223 AffyProbeAdaptor->_obj_from_sth()
|
|
224 Status : Medium Risk - Change to take ArrayChip object.
|
|
225
|
|
226 =cut
|
|
227
|
|
228 sub add_array_chip_probename {
|
|
229 my $self = shift;
|
|
230 my ($ac_dbid, $probename, $array) = @_;
|
|
231 $self->{ 'arrays' } ||= {};
|
|
232 $self->{ 'probenames' } ||= {};
|
|
233
|
|
234 #mass redundancy here, possibility of fetching same array over and over!!!!!!!!!!!!!!
|
|
235 #Need to implement cache in caller i.e. adaptor
|
|
236 #Made mandatory to force creation of cache
|
|
237 #we need access to adaptor before we can test is valid and stored
|
|
238 #let's no test each time for adaptor as this would slow down
|
|
239 #Just test here instead.
|
|
240
|
|
241 if(! (ref($array) && $array->isa('Bio::EnsEMBL::Funcgen::Array') && $array->dbID)){
|
|
242 #$array = $self->adaptor()->db()->get_ArrayAdaptor()->fetch_by_array_chip_dbID($ac_dbid);
|
|
243 throw('You must pass a valid Bio::EnsEMBL::Funcgen::Array. Maybe you want to generate a cache in the caller?');
|
|
244 }
|
|
245
|
|
246 #mapping between probename and ac_dbid is conserved through array name between hashes
|
|
247 #only easily linked from arrays to probenames,as would have to do foreach on array name
|
|
248
|
|
249 #Can we change the implementation of this so we're only storing the array once, reverse
|
|
250 #the cache? But we want access to the array and using an object reference as a key is ????
|
|
251 #How would this impact on method functionality?
|
|
252
|
|
253 #We now handle multiple names per probe/array
|
|
254 #This will not capture the relationship between
|
|
255 #probe name and position on array!
|
|
256 #Not a problem for affy as name is position
|
|
257 #Currently not a problem for nimblegen as probes never have more than 1 name???
|
|
258
|
|
259 $self->{ 'arrays' }->{$ac_dbid} = $array;
|
|
260
|
|
261 $self->{ 'probenames' }->{$array->name()} ||= [];
|
|
262 push @{$self->{ 'probenames' }->{$array->name()}}, $probename;
|
|
263
|
|
264 return;
|
|
265 }
|
|
266
|
|
267
|
|
268 =head2 get_all_ProbeFeatures
|
|
269
|
|
270 Args : None
|
|
271 Example : my $features = $probe->get_all_ProbeFeatures();
|
|
272 Description: Get all features produced by this probe. The probe needs to be
|
|
273 database persistent.
|
|
274 Returntype : Listref of Bio::EnsEMBL:Funcgen::ProbeFeature objects
|
|
275 Exceptions : None
|
|
276 Caller : General
|
|
277 Status : Medium Risk
|
|
278
|
|
279 =cut
|
|
280
|
|
281 sub get_all_ProbeFeatures {
|
|
282 my $self = shift;
|
|
283 if ( $self->adaptor() && $self->dbID() ) {
|
|
284 return $self->adaptor()->db()->get_ProbeFeatureAdaptor()->fetch_all_by_Probe($self);
|
|
285 } else {
|
|
286 warning('Need database connection to retrieve Features');
|
|
287 return [];
|
|
288 }
|
|
289 }
|
|
290
|
|
291 =head2 get_all_Arrays
|
|
292
|
|
293 Args : None
|
|
294 Example : my $arrays = $probe->get_all_Arrays();
|
|
295 Description: Returns all arrays that this probe is part of. Only works if the
|
|
296 probe was retrieved from the database or created using
|
|
297 add_Array_probename (rather than add_arrayname_probename).
|
|
298 Returntype : Listref of Bio::EnsEMBL::Funcgen::Array objects
|
|
299 Exceptions : None
|
|
300 Caller : General
|
|
301 Status : Medium Risk
|
|
302
|
|
303 =cut
|
|
304
|
|
305 sub get_all_Arrays {
|
|
306 my $self = shift;
|
|
307
|
|
308 #Arrays are currently preloaded using a cache in _objs_from_sth
|
|
309 return [ values %{$self->{'arrays'}} ];
|
|
310 }
|
|
311
|
|
312 =head2 get_names_Arrays
|
|
313
|
|
314 Args : None
|
|
315 Example : my %name_array_pairs = %{$probe->get_names_Arrays};
|
|
316 Description: Returns Array name hash
|
|
317 Returntype : hashref of probe name Bio::EnsEMBL::Funcgen::Array pairs
|
|
318 Exceptions : None
|
|
319 Caller : General
|
|
320 Status : Medium Risk
|
|
321
|
|
322 =cut
|
|
323
|
|
324 sub get_names_Arrays {
|
|
325 my $self = shift;
|
|
326
|
|
327 #Arrays are currently preloaded using a cache in _objs_from_sth
|
|
328 return $self->{'arrays'};
|
|
329 }
|
|
330
|
|
331
|
|
332
|
|
333
|
|
334
|
|
335 =head2 get_all_probenames
|
|
336
|
|
337 Arg [1] : Optional - list of array names, defaults to all available
|
|
338 Example : my @probenames = @{$probe->get_all_probenames()};
|
|
339 Description: Retrieves all names for this probe. Only makes sense for probes
|
|
340 that are part of a probeset (i.e. Affy probes), in which case
|
|
341 get_all_complete_names() would be more appropriate.
|
|
342 Returntype : Listref of strings
|
|
343 Exceptions : None
|
|
344 Caller : General
|
|
345 Status : Medium Risk
|
|
346
|
|
347 =cut
|
|
348
|
|
349 sub get_all_probenames {
|
|
350 my ($self, @array_names) = @_;
|
|
351
|
|
352 my @names;
|
|
353 @array_names = keys %{$self->{'probenames'}} if ! @array_names;
|
|
354
|
|
355 foreach my $array(@array_names){
|
|
356 push @names, @{$self->{'probenames'}->{$array}};
|
|
357 }
|
|
358
|
|
359 return \@names;
|
|
360 }
|
|
361
|
|
362
|
|
363
|
|
364 =head2 get_probename
|
|
365
|
|
366 Arg [1] : string - array name
|
|
367 Example : my $probename = $probe->get_probename('Array-1');
|
|
368 Description: For a given array, retrieve the name for this probe.
|
|
369 Returntype : string
|
|
370 Exceptions : Throws if the array name is required but not specified
|
|
371 Warns if probe has more than one name for the given array.
|
|
372 Caller : General
|
|
373 Status : Medium Risk
|
|
374
|
|
375 =cut
|
|
376
|
|
377
|
|
378 #we can have dulplicate probes on same array for Nimblegen
|
|
379 #what defines and unique probe?
|
|
380 #If we have a duplicate on the same array or even on the same array_chip, then we can still return the same name
|
|
381 #Needs more work
|
|
382
|
|
383 sub get_probename {
|
|
384 my ($self, $arrayname) = @_;
|
|
385
|
|
386
|
|
387 my $probename;
|
|
388
|
|
389 if (! $arrayname){
|
|
390
|
|
391 #Sanity check that there is only one non-AFFY array
|
|
392 my @ac_ids = keys %{$self->{'arrays'}};
|
|
393
|
|
394 if((scalar @ac_ids == 1) && ($self->get_all_Arrays()->[0]->vendor() ne "AFFY")){
|
|
395 $arrayname = $self->get_all_Arrays()->[0]->name();
|
|
396 }
|
|
397 else{
|
|
398 throw('Cannot retrieve name for Probe('.$self->dbID.") without arrayname if more than 1 array chip(@ac_ids) and not NIMBELGEN(".$self->get_all_Arrays()->[0]->vendor().")\n");
|
|
399 }
|
|
400 }
|
|
401
|
|
402
|
|
403 #Need to check if this exists before derefing
|
|
404 #Warn here?
|
|
405 return if(! exists ${$self->{'probenames'}}{$arrayname});
|
|
406
|
|
407
|
|
408 my @names = @{$self->{'probenames'}->{$arrayname}};
|
|
409
|
|
410
|
|
411 if(scalar(@names) > 1){
|
|
412 my $p_info = '';
|
|
413
|
|
414 if($self->probeset){
|
|
415 $p_info = " probeset ".$self->probeset->name;
|
|
416 }
|
|
417
|
|
418 warn("Found replicate probes with different names for array ${arrayname}${p_info}.Returning comma separated string list:\t".join(',', @names)."\n");
|
|
419 return join(',', @names);
|
|
420
|
|
421 }
|
|
422 else{
|
|
423 ($probename) = @{$self->{'probenames'}->{$arrayname}};
|
|
424 }
|
|
425
|
|
426 return $probename;
|
|
427 }
|
|
428
|
|
429
|
|
430
|
|
431 =head2 get_all_complete_names
|
|
432
|
|
433 Args : None
|
|
434 Example : my @compnames = @{$probe->get_all_complete_names()};
|
|
435 Description: Retrieves all complete names for this probe. The complete name
|
|
436 is a concatenation of the array name, the probeset name and the
|
|
437 probe name.
|
|
438 Returntype : Listref of strings
|
|
439 Exceptions : None
|
|
440 Caller : General
|
|
441 Status : Medium Risk
|
|
442
|
|
443 =cut
|
|
444
|
|
445 sub get_all_complete_names {
|
|
446 my $self = shift;
|
|
447
|
|
448 my ($probeset, @result);
|
|
449 my $pset = $self->probeset;
|
|
450
|
|
451 if($pset){
|
|
452 $probeset = $pset->name;
|
|
453 }
|
|
454
|
|
455 $probeset .= ':' if $probeset;
|
|
456
|
|
457
|
|
458 #warn "For Nimblegen this need to be Container:Seqid::probeid?";
|
|
459
|
|
460 while ( my (undef, $array) = each %{$self->{'arrays'}} ) {
|
|
461 #would have to put test in here for $self->arrays()->vendor()
|
|
462 #if($array->vendor() eq "AFFY"){
|
|
463
|
|
464 foreach my $name(@{$self->{'probenames'}{$array->name()}}){
|
|
465
|
|
466 push @result, $array->name().":$probeset".$name;
|
|
467 }
|
|
468 }
|
|
469
|
|
470 return \@result;
|
|
471 }
|
|
472
|
|
473
|
|
474
|
|
475 #For affy this matters as name will be different, but not for Nimblegen
|
|
476 #Need to consolidate this
|
|
477 #have get name method which throws if there is more than one array
|
|
478 #detects array vendor and does appropriate method
|
|
479
|
|
480 =head2 get_complete_name
|
|
481
|
|
482 Arg [1] : string - array name
|
|
483 Example : my $compname = $probe->get_complete_name('Array-1');
|
|
484 Description: For a given array, retrieve the complete name for this probe.
|
|
485 Returntype : string
|
|
486 Exceptions : Throws if the array name not specified or not known for this probe
|
|
487 Caller : General
|
|
488 Status : Medium Risk
|
|
489
|
|
490 =cut
|
|
491
|
|
492 sub get_complete_name {
|
|
493 my $self = shift;
|
|
494 my $arrayname = shift;
|
|
495
|
|
496
|
|
497 throw('Must provide and array name argument to retreive the complete name') if ! defined $arrayname;
|
|
498
|
|
499 my $probename = $self->get_probename($arrayname);
|
|
500
|
|
501 if (!defined $probename) {
|
|
502 throw('Unknown array name');
|
|
503 }
|
|
504
|
|
505 my $probeset = $self->probeset()->name();
|
|
506 $probeset .= ':' if $probeset;
|
|
507
|
|
508 return "$arrayname:$probeset$probename";
|
|
509 }
|
|
510
|
|
511 =head2 probeset
|
|
512
|
|
513 Arg [1] : (optional) Bio::EnsEMBL::Funcgen::ProbeSet
|
|
514 Example : my $probe_set = $probe->probeset();
|
|
515 Description: Getter and setter of probe_set attribute for Probe objects.
|
|
516 Returntype : Bio::EnsEMBL::Funcgen::ProbeSet
|
|
517 Exceptions : None
|
|
518 Caller : General
|
|
519 Status : Medium Risk
|
|
520
|
|
521 =cut
|
|
522
|
|
523 sub probeset {
|
|
524 my $self = shift;
|
|
525
|
|
526 $self->{'probe_set'} = shift if @_;
|
|
527 return $self->{'probe_set'};
|
|
528 }
|
|
529
|
|
530 =head2 class
|
|
531
|
|
532 Arg [1] : (optional) string - class
|
|
533 Example : my $class = $probe->class();
|
|
534 Description: Getter and setter of class attribute for Probe
|
|
535 objects e.g. CONTROL, EXPERIMENTAL
|
|
536 Returntype : string
|
|
537 Exceptions : None
|
|
538 Caller : General
|
|
539 Status : Medium Risk
|
|
540
|
|
541 =cut
|
|
542
|
|
543 sub class {
|
|
544 my $self = shift;
|
|
545 $self->{'class'} = shift if @_;
|
|
546 return $self->{'class'};
|
|
547 }
|
|
548
|
|
549 =head2 length
|
|
550
|
|
551 Arg [1] : (optional) int - probe length
|
|
552 Example : my $probelength = $probe->length();
|
|
553 Description: Getter and setter of length attribute for Probe
|
|
554 objects.
|
|
555 Returntype : int
|
|
556 Exceptions : None
|
|
557 Caller : General
|
|
558 Status : Medium Risk
|
|
559
|
|
560 =cut
|
|
561
|
|
562 sub length {
|
|
563 my $self = shift;
|
|
564 $self->{'length'} = shift if @_;
|
|
565 return $self->{'length'};
|
|
566 }
|
|
567
|
|
568 =head2 description
|
|
569
|
|
570 Arg [1] : (optional) string - description
|
|
571 Example : my $pdesc = $probe->description();
|
|
572 Description: Getter and setter of description attribute for Probe
|
|
573 objects.
|
|
574 Returntype : string
|
|
575 Exceptions : None
|
|
576 Caller : General
|
|
577 Status : At Risk
|
|
578
|
|
579 =cut
|
|
580
|
|
581 sub description {
|
|
582 my $self = shift;
|
|
583 $self->{'description'} = shift if @_;
|
|
584 return $self->{'description'};
|
|
585 }
|
|
586
|
|
587
|
|
588 =head2 feature_count
|
|
589
|
|
590 Arg[0] : recount flag
|
|
591 Example : my $num_features = $probe->feature_count();
|
|
592 Description: Counts the number of ProbeFeatures associated with this Probe
|
|
593 Returntype : int
|
|
594 Exceptions : None
|
|
595 Caller : General
|
|
596 Status : Medium Risk
|
|
597
|
|
598 =cut
|
|
599
|
|
600
|
|
601 sub feature_count{
|
|
602 my ($self, $recount) = @_;
|
|
603
|
|
604 if($recount ||
|
|
605 (! $self->{feature_count})){
|
|
606 $self->{feature_count} = $self->adaptor->db->get_ProbeFeatureAdaptor->count_probe_features_by_probe_id($self->dbID);
|
|
607 }
|
|
608
|
|
609 return $self->{feature_count};
|
|
610 }
|
|
611
|
|
612
|
|
613
|
|
614
|
|
615 ### ARRAY DESIGN SPECIFIC METHODS
|
|
616
|
|
617 =head2 add_Analysis_score
|
|
618
|
|
619 Arg [1] : Bio::EnsEMBL::Analysis
|
|
620 Arg [2] : string - analysis score (as string a precision may differ between analyses)??
|
|
621 Example : $probe->add_Analysis_score($analysis, $score);
|
|
622 Description: Setter for probe analysis attributes from an array design
|
|
623 Returntype : None
|
|
624 Exceptions : throws if args are not met or valid
|
|
625 Caller : General
|
|
626 Status : at risk
|
|
627
|
|
628 =cut
|
|
629
|
|
630 sub add_Analysis_score{
|
|
631 my ($self, $anal, $score) = @_;
|
|
632
|
|
633 if(! ($anal && $anal->dbID() && $anal->isa("Bio::EnsEMBL::Analysis"))){
|
|
634 throw("Must provide a valid stored Bio::EnsEMBL::Analysis");
|
|
635 }
|
|
636
|
|
637 throw("Must provide a score to add to the probe") if ! defined $score;
|
|
638
|
|
639 $self->{'analysis'}{$anal->dbID()} = $score;
|
|
640
|
|
641 return;
|
|
642 }
|
|
643
|
|
644 =head2 add_Analysis_CoordSystem_score
|
|
645
|
|
646 Arg [1] : Bio::EnsEMBL::Analysis
|
|
647 Arg [2] : Bio::EnsEMBL::CoordSystem
|
|
648 Arg [3] : string - analysis score (as string a precision may differ between analyses)??
|
|
649 Example : $probe->add_Analysis_CoordSystem_score($analysis, $coord_sys, $score);
|
|
650 Description: Setter for coord system dependant probe analysis attributes from an array design
|
|
651 Returntype : None
|
|
652 Exceptions : throws if args are not met or valid
|
|
653 Caller : General
|
|
654 Status : at risk
|
|
655
|
|
656 =cut
|
|
657
|
|
658 sub add_Analysis_CoordSystem_score{
|
|
659 my ($self, $anal, $cs, $score) = @_;
|
|
660
|
|
661 if(! ($anal && $anal->dbID() && $anal->isa("Bio::EnsEMBL::Analysis"))){
|
|
662 throw("Must provide a valid stored Bio::EnsEMBL::Analysis");
|
|
663 }
|
|
664
|
|
665 if(! ($cs && $cs->dbID() && $cs->isa("Bio::EnsEMBL::Funcgen::CoordSystem"))){
|
|
666 throw("Must provide a valid stored Bio::EnsEMBL::Funcgen::CoordSystem");
|
|
667 }
|
|
668
|
|
669 throw("Must provide a score to add to the probe") if ! defined $score;
|
|
670
|
|
671 $self->{'analysis_coord_system'}{$anal->dbID()}{$cs->dbID()} = $score;
|
|
672
|
|
673 return;
|
|
674 }
|
|
675
|
|
676 =head2 get_score_by_Analysis
|
|
677
|
|
678 Arg [1] : Bio::EnsEMBL::Analysis
|
|
679 Example : my $anal_score = $probe->get_analysis_score($analysis);
|
|
680 Description: Setter for probe analysis attributes from an array design
|
|
681 Returntype : string
|
|
682 Exceptions : throws if args are not met or valid
|
|
683 Caller : General
|
|
684 Status : at risk
|
|
685
|
|
686 =cut
|
|
687
|
|
688 sub get_score_by_Analysis{
|
|
689 my ($self, $anal) = @_;
|
|
690
|
|
691 $self->get_all_design_scores() if ! defined $self->{'analysis'};
|
|
692
|
|
693 if(! ($anal && $anal->dbID() && $anal->isa("Bio::EnsEMBL::Analysis"))){
|
|
694 throw("Must provide a valid stored Bio::EnsEMBL::Analysis");
|
|
695 }
|
|
696
|
|
697
|
|
698 return (exists $self->{'analysis'}{$anal->dbID()}) ? $self->{'analysis'}{$anal->dbID()} : undef;
|
|
699 }
|
|
700
|
|
701 =head2 get_score_by_Analysis_CoordSystem
|
|
702
|
|
703 Arg [1] : Bio::EnsEMBL::Analysis
|
|
704 Arg [2] : Bio::EnsEMBL::CoordSystem
|
|
705 Arg [3] : string - analysis score (as string a precision may differ between analyses)??
|
|
706 Example : $probe->add_analysis($analysis, $coord_sys, $score);
|
|
707 Description: Setter for coord system dependant probe analysis attributes from an array design
|
|
708 Returntype : None
|
|
709 Exceptions : throws if args are not met or valid
|
|
710 Caller : General
|
|
711 Status : at risk
|
|
712
|
|
713 =cut
|
|
714
|
|
715 sub get_score_by_Analysis_CoordSystem{
|
|
716 my ($self, $anal, $cs) = @_;
|
|
717
|
|
718 $self->get_all_design_scores() if ! defined $self->{'analysis_coord_system'};
|
|
719
|
|
720 if(! ($anal && $anal->dbID() && $anal->isa("Bio::EnsEMBL::Analysis"))){
|
|
721 throw("Must provide a valid stored Bio::EnsEMBL::Analysis");
|
|
722 }
|
|
723
|
|
724 if(! ($cs && $cs->dbID() && $cs->isa("Bio::EnsEMBL::Funcgen::CoordSystem"))){
|
|
725 throw("Must provide a valid stored Bio::EnsEMBL::Funcgen::CoordSystem");
|
|
726 }
|
|
727
|
|
728 my $score = undef;
|
|
729
|
|
730 if(exists $self->{'analysis_coord_system'}{$anal->dbID()} &&
|
|
731 exists $self->{'analysis_coord_system'}{$anal->dbID()}{$cs->dbID()}){
|
|
732 $score = $self->{'analysis_coord_system'}{$anal->dbID()}{$cs->dbID()};
|
|
733 }
|
|
734
|
|
735 return $score;
|
|
736 }
|
|
737
|
|
738
|
|
739 =head2 get_all_design_scores
|
|
740
|
|
741 Arg [1] : Boolean - No fetch flag, to fetch design scores from DB, used in adaptor
|
|
742 To avoid testing DB for each probe when no design scores have been added.
|
|
743 Example : my @anal_score_coordsets = @{$probe->get_all_design_scores()};
|
|
744 Description: Gets all design scores as analysis_id, score and optionally coord_system_id
|
|
745 Returntype : ARRAYREF
|
|
746 Exceptions : throws if no fetch flag is not defined and adaptor or probe is not defined and or stored.
|
|
747 Caller : General
|
|
748 Status : at risk
|
|
749
|
|
750 =cut
|
|
751
|
|
752 #not named get_all_Analysis_scores as this would imply only non-cs dependent scores
|
|
753 #hence named after table, as this returns simple table records
|
|
754
|
|
755 sub get_all_design_scores{
|
|
756 my ($self, $no_fetch) = @_;
|
|
757
|
|
758 my ($analysis_id, $cs_id, $score, @design_scores);
|
|
759
|
|
760 if(! $no_fetch){#can assume we have none stored already due to implementation of add methods
|
|
761
|
|
762 throw("Probe must have and adaptor to fetch design scores from the DB") if(! $self->adaptor());
|
|
763
|
|
764 foreach my $probe_analysis(@{$self->adaptor->fetch_all_design_records($self)}){
|
|
765 #we can't use the add methods here as would be cyclical
|
|
766 #nor do we need extra validation
|
|
767
|
|
768 ($analysis_id, $cs_id, $score) = @$probe_analysis;
|
|
769
|
|
770 if($cs_id){
|
|
771 $self->{'analysis_coord_system'}{$analysis_id}{$cs_id} = $score;
|
|
772 }else{
|
|
773 $self->{'analysis'}{$analysis_id} = $score;
|
|
774 }
|
|
775 }
|
|
776 }
|
|
777
|
|
778 #populate array from attrs
|
|
779 if(exists $self->{'analysis_coord_system'}){
|
|
780
|
|
781 foreach $analysis_id(keys %{$self->{'analysis_coord_system'}}){
|
|
782
|
|
783 foreach $cs_id(keys %{$self->{'analysis_coord_system'}{$analysis_id}}){
|
|
784 push @design_scores, [$analysis_id, $self->{'analysis_coord_system'}{$analysis_id}{$cs_id}, $cs_id];
|
|
785 }
|
|
786 }
|
|
787 }
|
|
788
|
|
789 if(exists $self->{'analysis'}){
|
|
790
|
|
791 foreach $analysis_id(keys %{$self->{'analysis'}}){
|
|
792
|
|
793 push @design_scores, [$analysis_id, $self->{'analysis'}{$analysis_id}];
|
|
794 }
|
|
795 }
|
|
796
|
|
797
|
|
798 return \@design_scores;
|
|
799
|
|
800 }
|
|
801
|
|
802
|
|
803 #do we need get_all methods for Analysis and Analysis_CoordSystem?
|
|
804 #maybe if we split into another Class and Adaptor
|
|
805
|
|
806 1;
|
|
807
|