EnsEMBL/Map/Marker.pm untested

filter: Statementstmt 0.0% 0 / 94 Branchbran 0.0% 0 / 32 Conditioncond 0.0% 0 / 40 Subroutinesub 0.0% 0 / 20 Podpod 0.0% 0 / 16 totaltotal 0.0% 0 / 202 CC 17 SCAR 19.6
CC
17
Cov
0%
new
12.0
display_MarkerSynonym
12.0
get_MapLocation
12.0
CRAP 7.1
1 =head1 LICENSE
2  
3 See the NOTICE file distributed with this work for additional information
4 regarding copyright ownership.
5  
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9  
10 http://www.apache.org/licenses/LICENSE-2.0
11  
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17  
18 =cut
19  
20  
21 =head1 CONTACT
22  
23 Please email comments or questions to the public Ensembl
24 developers list at <http://lists.ensembl.org/mailman/listinfo/dev>.
25  
26 Questions may also be sent to the Ensembl help desk at
27 <http://www.ensembl.org/Help/Contact>.
28  
29 =cut
30  
31 =head1 NAME
32  
33 Bio::EnsEMBL::Map::Marker
34  
35 =head1 SYNOPSIS
36  
37 =head1 DESCRIPTION
38  
39 Represents a marker in the EnsEMBL database. The marker object
40 is unpositioned on the genome. Markers which are positioned are
41 represented by the MarkerFeature object.
42  
43 =head1 METHODS
44  
45 =cut
46  
47 package Bio::EnsEMBL::Map::Marker;
48 $Bio::EnsEMBL::Map::Marker::VERSION = '114.0.0_50'; # TRIAL
49 $Bio::EnsEMBL::Map::Marker::VERSION = '114.0.050';
50 use strict;
51 use vars qw(@ISA);
52  
53 use Bio::EnsEMBL::Storable;
54 use Bio::EnsEMBL::Utils::Exception qw(throw);
55  
56 @ISA = qw(Bio::EnsEMBL::Storable);
57  
58  
59  
60 =head2 new
61  
62 Arg [1] : (optional) int $dbID
63 Arg [2] : (optional) Bio::EnsEMBL::Map::DBSQL::MarkerAdaptor $adaptor
64 Arg [3] : (optional) string $left_primer
65 Arg [4] : (optional) string $right_primer
66 Arg [5] : (optional) int $primer_distance
67 Arg [6] : (optional) int $priority
68 Arg [7] : (optional) string $type
69 Arg [8] : (optional) Bio::EnsEMBL::Map::MarkerSynonym $display_synonym
70 Arg [9] : (optional) listref of Bio::EnsEMBL::Map::MarkerSynonyms $syns
71 Arg [10] : (optional) listref of Bio::EnsEMBL::Map::MapLocations $locs
72 Example : $marker = Bio::EnsEMBL::Map::MarkerSynonym->new
73 (123, $adaptor,
74 $left_primer, $right_primer, 400,
75 80, $ms1, [$ms1, $ms2], [$mloc1, $mloc2]);
76 Description: Creates a new Marker
77 Returntype : Bio::EnsEMBL::Map::Marker
78 Exceptions : none
79 Caller : general
80 Status : stable
81  
82 =cut
83  
84 sub new {
85 my ($caller, $dbID, $adaptor, $left_primer, $right_primer,
86 $min_primer_dist, $max_primer_dist, $priority, $type, $display_synonym,
87 $syns, $mlocs) = @_;
88  
89 my $class = ref($caller) || $caller;
90  
91 my $self = bless( {'dbID' => $dbID,
92 'left_primer' => $left_primer,
93 'right_primer' => $right_primer,
94 'min_primer_dist' => $min_primer_dist,
95 'max_primer_dist' => $max_primer_dist,
96 'priority' => $priority,
97 'type' => $type,
98 'display_marker_synonym' => $display_synonym
99 }, $class);
100  
101 $self->adaptor($adaptor);
102  
103 #only load the marker synononyms if they were supplied, otherwise they
104 # will be lazy-loaded
105 if($syns && @$syns) {
106 $self->{'marker_synonyms'} = $syns;
107 }
108  
109 #only load the map_locations if they were supplied, otherwise they will
110 # be lazy-loaded
111 if($mlocs) {
112 foreach my $ml (@$mlocs) {
113 $self->add_MapLocation($ml);
114 }
115 }
116  
117 return $self;
118 }
119  
120  
121 =head2 left_primer
122  
123 Arg [1] : (optional) string $left_primer
124 Example : $left_primer = $marker->left_primer;
125 Description: Getter/Setter for the left primer sequence of this marker
126 Returntype : string
127 Exceptions : none
128 Caller : general
129 Status : stable
130  
131 =cut
132  
133 sub left_primer {
134 my $self = shift;
135
136 if(@_) {
137 $self->{'left_primer'} = shift;
138 }
139  
140 return $self->{'left_primer'};
141 }
142  
143  
144  
145 =head2 right_primer
146  
147 Arg [1] : (optional) string $right_primer
148 Example : $right_primer = $marker->right_primer;
149 Description: Getter/Setter for the right primer sequence of this marker
150 Returntype : string
151 Exceptions : none
152 Caller : general
153 Status : stable
154  
155 =cut
156  
157 sub right_primer {
158 my $self = shift;
159
160 if(@_) {
161 $self->{'right_primer'} = shift;
162 }
163  
164 return $self->{'right_primer'};
165 }
166  
167  
168  
169 =head2 min_primer_dist
170  
171 Arg [1] : (optional) string $min
172 Example : $dist = $marker->min_primer_dist;
173 Description: Getter/Setter for the minimum seperation distance between the
174 left and right primers of this marker
175 Returntype : int
176 Exceptions : none
177 Caller : general
178 Status : stable
179  
180 =cut
181  
182 sub min_primer_dist {
183 my $self = shift;
184  
185 if(@_) {
186 $self->{'min_primer_dist'} = shift;
187 }
188  
189 return $self->{'min_primer_dist'};
190 }
191  
192  
193 =head2 max_primer_dist
194  
195 Arg [1] : (optional) string $max
196 Example : $dist = $marker->max_primer_dist;
197 Description: Getter/Setter for the maximum seperation distance between the
198 left and right primers of this marker
199 Returntype : int
200 Exceptions : none
201 Caller : general
202 Status : stable
203  
204 =cut
205  
206 sub max_primer_dist {
207 my $self = shift;
208  
209 if(@_) {
210 $self->{'max_primer_dist'} = shift;
211 }
212  
213 return $self->{'max_primer_dist'};
214 }
215  
216  
217  
218 =head2 priority
219  
220 Arg [1] : (optional) int $priority
221 Example : $priority = $marker->priority;
222 Description: Getter/Setter for priority of this marker which can be used to
223 determine which markers are displayed.
224 Returntype : int
225 Exceptions : none
226 Caller : general
227 Status : stable
228  
229 =cut
230  
231 sub priority {
232 my $self = shift;
233  
234 if(@_) {
235 $self->{'priority'} = shift;
236 }
237
238 return $self->{'priority'};
239 }
240  
241  
242  
243  
244 =head2 type
245  
246 Arg [1] : (optional) string $type
247 Example : $type = $marker->type;
248 Description: Getter/Setter for type of this marker. Rat markers are typed
249 as 'est' or 'microsatellite'. Other markers may not have
250 defined types.
251 Returntype : string
252 Exceptions : none
253 Caller : general
254 Status : stable
255  
256 =cut
257  
258 sub type {
259 my $self = shift;
260  
261 if(@_) {
262 $self->{'type'} = shift;
263 }
264
265 return $self->{'type'};
266 }
267  
268  
269  
270  
271 =head2 get_all_MarkerSynonyms
272  
273 Arg [1] : none
274 Example : @synonyms = @{$marker->get_all_MarkerSynonyms};
275 Description: Retrieves a list of marker synonyms associated with this
276 marker. If this marker is connected to the datbase (i.e. it
277 has an adaptor and
278 Returntype : listref of Bio::EnsEMBL::Map::MarkerSynonyms
279 Exceptions : none
280 Caller : general
281 Status : stable
282  
283 =cut
284  
285 sub get_all_MarkerSynonyms {
286 my $self = shift;
287
288 #lazy-load the marker synonyms if they haven't been retrieved
289 if(!exists $self->{'marker_synonyms'} &&
290 $self->adaptor && $self->{'dbID'}) {
291 $self->adaptor->fetch_attributes($self);
292 }
293
294 return $self->{'marker_synonyms'} || [];
295 }
296  
297  
298  
299 =head2 add_MarkerSynonyms
300  
301 Arg [1] : Bio::EnsEMBL::MarkerSynonym $ms
302 Example : $marker->add_MarkerSynonym($ms);
303 Description: Associates a new synonym with this marker. Adding marker
304 synonyms to a marker which has not yet retrieved its
305 synonyms from the database will prevent the loading of these
306 from the database at request time (unless flush_MarkerSynonyms
307 is called first).
308 Returntype : none
309 Exceptions : thrown if incorrect argument is passed
310 Caller : general
311 Status : stable
312  
313 =cut
314  
315 sub add_MarkerSynonyms {
316 my ($self, @ms) = @_;
317  
318 #create the array if it does not exist it
319 $self->{'marker_synonyms'} ||= [];
320  
321 push(@{$self->{'marker_synonyms'}}, @ms);
322 }
323  
324  
325  
326 =head2 flush_MarkerSynonyms
327  
328 Arg [1] : none
329 Example : $marker->flush_MarkerSynonyms;
330 Description: clears all of the marker sysnonyms which have been added to
331 this marker.
332 Returntype : none
333 Exceptions : none
334 Caller : general
335 Status : stable
336  
337 =cut
338  
339 sub flush_MarkerSynonyms {
340 my $self = shift;
341  
342 delete $self->{'marker_synonyms'};
343 }
344  
345  
346  
347 =head2 display_MarkerSynonym
348  
349 Arg [1] : (optional) Bio::EnsEMBL::DBSQL::MarkerSynonym $ms
350 Example : none
351 Description: Getter/Setter for the 'display' synonym of this marker
352 Returntype : Bio::EnsEMBL::Map::MarkerSynonym
353 Exceptions : thrown if the argument is invalid
354 Caller : general
355 Status : stable
356  
357 =cut
358  
359 sub display_MarkerSynonym {
360 my $self = shift;
361
362 if(@_) {
363 my $ms = shift;
364 if($ms && !(ref $ms && $ms->isa('Bio::EnsEMBL::Map::MarkerSynonym'))) {
365 throw("ms arg must be Bio::EnsEMBL::Map::MarkerSynonym not [$ms]");
366 }
367 $self->{'display_marker_synonym'} = $ms;
368 }
369  
370  
371 return $self->{'display_marker_synonym'};
372 }
373  
374  
375  
376 =head2 get_all_MarkerFeatures
377  
378 Arg [1] : none
379 Example : @marker_features = @{$marker->get_all_MarkerFeatures};
380 Description: Retrieves the marker features which are associated with this
381 marker. I.e. locations where this marker has been mapped to
382 the genome via e-PCR
383 Returntype : listref of Bio::EnsEMBL::Map::MarkerFeatures
384 Exceptions : none
385 Caller : general
386 Status : stable
387  
388 =cut
389  
390 sub get_all_MarkerFeatures {
391 my $self = shift;
392  
393 my $marker_feature_adaptor = $self->adaptor->db->get_MarkerFeatureAdaptor;
394  
395 #these results are not cached to avoid a circular reference loop
396 return $marker_feature_adaptor->fetch_all_by_Marker($self);
397 }
398  
399  
400  
401 =head2 get_all_MapLocations
402  
403 Arg [1] : none
404 Example : @map_locations = @{$marker->get_all_MapLocations};
405 Description: Retrieves all map locations which are associated with this
406 marker.
407 Returntype : listref of Bio::EnsEMBL::Map::MapLocations
408 Exceptions : none
409 Caller : general
410 Status : stable
411  
412 =cut
413  
414 sub get_all_MapLocations {
415 my $self = shift;
416  
417 #lazy-load the map locations if they have not been fetched yet
418 if(!exists $self->{'map_locations'} &&
419 $self->adaptor && $self->{'dbID'}) {
420 $self->adaptor->fetch_attributes($self);
421 }
422  
423 my @out = values %{$self->{'map_locations'}};
424  
425 return \@out;
426 }
427  
428  
429  
430 =head2 get_MapLocation
431  
432 Arg [1] : string $map_name
433 Example : $map_location = $marker->get_MapLocation('genethon');
434 Description: Retrieves the location of this marker in a specified map.
435 If this marker is not defined in the specified map then
436 undef is returned.
437 Returntype : Bio::EnsEMBL::Map::MapLocation
438 Exceptions : thrown if the map_name arg is not provided
439 Caller : general
440 Status : stable
441  
442 =cut
443  
444 sub get_MapLocation {
445 my $self = shift;
446 my $map_name = shift;
447  
448 #lazy-load the map locations if they have not been fetched yet
449 if(!exists $self->{'map_locations'} &&
450 $self->adaptor && $self->{'dbID'}) {
451 $self->adaptor->fetch_attributes($self);
452 }
453  
454 unless($map_name) {
455 throw('map_name argument is required, or use get_all_MapLocations');
456 }
457  
458 return $self->{'map_locations'}->{$map_name};
459 }
460  
461  
462  
463 =head2 add_MapLocations
464  
465 Arg [1..n] : @mlocs list of Bio::EnsEMBL::MapLocations
466 Example : $marker->add_MapLocations(@mlocs);
467 Description: Associates 1 or more map locations with this marker
468 using this function to manually load map locations will prevent
469 lazy-loading of locations from the database.
470 Returntype : listref of Bio::EnsEMBL::MapLocations
471 Exceptions : throws if map location has no name
472 Caller : general
473 Status : stable
474  
475 =cut
476  
477 sub add_MapLocations {
478 my ($self, @mlocs) = @_;
479  
480 foreach my $ml (@mlocs) {
481 unless($ml && ref $ml && $ml->isa('Bio::EnsEMBL::Map::MapLocation')) {
482 throw("args must be Bio::EnsEMBL::Map::MapLocations not [$ml]");
483 }
484  
485 my $mname = $ml->map_name;
486 unless($mname) {
487 throw("map location arg [$ml] does not define a map name");
488 }
489  
490 $self->{'map_locations'}->{$mname} = $ml;
491 }
492 }
493  
494  
495  
496  
497 =head2 flush_MapLocations
498  
499 Arg [1] : none
500 Example : $marker->get_all_MapLocations;
501 Description: Removes map locations associated with this marker. Markers may
502 be lazy-loaded from the database (again) after this.
503 Returntype : none
504 Exceptions :
505 Caller :
506 Status : stable
507  
508 =cut
509  
510 sub flush_MapLocations{
511 my $self = shift;
512  
513 delete $self->{'map_locations'};
514 }
515  
516  
517 1;
518  
519  
520  
521