3 See the NOTICE file distributed with
this work
for additional information
4 regarding copyright ownership.
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
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.
23 Please email comments or questions to the
public Ensembl
24 developers list at <http:
26 Questions may also be sent to the Ensembl help desk at
39 Represents a marker in the
EnsEMBL database. The marker
object
40 is unpositioned on the genome. Markers which are positioned are
47 package Bio::EnsEMBL::Map::Marker;
61 Arg [1] : (optional)
int $dbID
63 Arg [3] : (optional)
string $left_primer
64 Arg [4] : (optional)
string $right_primer
65 Arg [5] : (optional)
int $primer_distance
66 Arg [6] : (optional)
int $priority
67 Arg [7] : (optional)
string $type
69 Arg [9] : (optional) listref of Bio::EnsEMBL::Map::MarkerSynonyms $syns
70 Arg [10] : (optional) listref of Bio::EnsEMBL::Map::MapLocations $locs
73 $left_primer, $right_primer, 400,
74 80, $ms1, [$ms1, $ms2], [$mloc1, $mloc2]);
75 Description: Creates a
new Marker
84 my ($caller, $dbID, $adaptor, $left_primer, $right_primer,
85 $min_primer_dist, $max_primer_dist, $priority, $type, $display_synonym,
88 my $class = ref($caller) || $caller;
90 my $self = bless( {
'dbID' => $dbID,
91 'left_primer' => $left_primer,
92 'right_primer' => $right_primer,
93 'min_primer_dist' => $min_primer_dist,
94 'max_primer_dist' => $max_primer_dist,
95 'priority' => $priority,
97 'display_marker_synonym' => $display_synonym
102 #only load the marker synononyms if they were supplied, otherwise they
103 # will be lazy-loaded
104 if($syns && @$syns) {
105 $self->{
'marker_synonyms'} = $syns;
108 #only load the map_locations if they were supplied, otherwise they will
111 foreach my $ml (@$mlocs) {
112 $self->add_MapLocation($ml);
122 Arg [1] : (optional)
string $left_primer
123 Example : $left_primer = $marker->left_primer;
124 Description: Getter/Setter
for the left primer sequence of
this marker
136 $self->{
'left_primer'} = shift;
139 return $self->{
'left_primer'};
146 Arg [1] : (optional)
string $right_primer
147 Example : $right_primer = $marker->right_primer;
148 Description: Getter/Setter
for the right primer sequence of
this marker
160 $self->{
'right_primer'} = shift;
163 return $self->{
'right_primer'};
168 =head2 min_primer_dist
170 Arg [1] : (optional)
string $min
171 Example : $dist = $marker->min_primer_dist;
172 Description: Getter/Setter
for the minimum seperation distance between the
173 left and right primers of
this marker
181 sub min_primer_dist {
185 $self->{
'min_primer_dist'} = shift;
188 return $self->{
'min_primer_dist'};
192 =head2 max_primer_dist
194 Arg [1] : (optional)
string $max
195 Example : $dist = $marker->max_primer_dist;
196 Description: Getter/Setter
for the maximum seperation distance between the
197 left and right primers of
this marker
205 sub max_primer_dist {
209 $self->{
'max_primer_dist'} = shift;
212 return $self->{
'max_primer_dist'};
219 Arg [1] : (optional)
int $priority
220 Example : $priority = $marker->priority;
221 Description: Getter/Setter
for priority of
this marker which can be used to
222 determine which markers are displayed.
234 $self->{
'priority'} = shift;
237 return $self->{
'priority'};
245 Arg [1] : (optional)
string $type
246 Example : $type = $marker->type;
247 Description: Getter/Setter
for type of
this marker. Rat markers are typed
248 as
'est' or
'microsatellite'. Other markers may not have
261 $self->{
'type'} = shift;
264 return $self->{
'type'};
270 =head2 get_all_MarkerSynonyms
273 Example : @synonyms = @{$marker->get_all_MarkerSynonyms};
274 Description: Retrieves a list of marker synonyms associated with
this
275 marker. If
this marker is connected to the datbase (i.e. it
277 Returntype : listref of Bio::EnsEMBL::Map::MarkerSynonyms
284 sub get_all_MarkerSynonyms {
287 #lazy-load the marker synonyms if they haven
't been retrieved
288 if(!exists $self->{'marker_synonyms
'} &&
289 $self->adaptor && $self->{'dbID
'}) {
290 $self->adaptor->fetch_attributes($self);
293 return $self->{'marker_synonyms
'} || [];
298 =head2 add_MarkerSynonyms
300 Arg [1] : Bio::EnsEMBL::MarkerSynonym $ms
301 Example : $marker->add_MarkerSynonym($ms);
302 Description: Associates a new synonym with this marker. Adding marker
303 synonyms to a marker which has not yet retrieved its
304 synonyms from the database will prevent the loading of these
305 from the database at request time (unless flush_MarkerSynonyms
308 Exceptions : thrown if incorrect argument is passed
314 sub add_MarkerSynonyms {
315 my ($self, @ms) = @_;
317 #create the array if it does not exist it
318 $self->{'marker_synonyms
'} ||= [];
320 push(@{$self->{'marker_synonyms
'}}, @ms);
325 =head2 flush_MarkerSynonyms
328 Example : $marker->flush_MarkerSynonyms;
329 Description: clears all of the marker sysnonyms which have been added to
338 sub flush_MarkerSynonyms {
341 delete $self->{'marker_synonyms
'};
346 =head2 display_MarkerSynonym
348 Arg [1] : (optional) Bio::EnsEMBL::DBSQL::MarkerSynonym $ms
350 Description: Getter/Setter for the 'display
' synonym of this marker
351 Returntype : Bio::EnsEMBL::Map::MarkerSynonym
352 Exceptions : thrown if the argument is invalid
358 sub display_MarkerSynonym {
363 if($ms && !(ref $ms && $ms->isa('Bio::EnsEMBL::Map::MarkerSynonym
'))) {
364 throw("ms arg must be Bio::EnsEMBL::Map::MarkerSynonym not [$ms]");
366 $self->{'display_marker_synonym
'} = $ms;
370 return $self->{'display_marker_synonym
'};
375 =head2 get_all_MarkerFeatures
378 Example : @marker_features = @{$marker->get_all_MarkerFeatures};
379 Description: Retrieves the marker features which are associated with this
380 marker. I.e. locations where this marker has been mapped to
382 Returntype : listref of Bio::EnsEMBL::Map::MarkerFeatures
389 sub get_all_MarkerFeatures {
392 my $marker_feature_adaptor = $self->adaptor->db->get_MarkerFeatureAdaptor;
394 #these results are not cached to avoid a circular reference loop
395 return $marker_feature_adaptor->fetch_all_by_Marker($self);
400 =head2 get_all_MapLocations
403 Example : @map_locations = @{$marker->get_all_MapLocations};
404 Description: Retrieves all map locations which are associated with this
406 Returntype : listref of Bio::EnsEMBL::Map::MapLocations
413 sub get_all_MapLocations {
416 #lazy-load the map locations if they have not been fetched yet
417 if(!exists $self->{'map_locations
'} &&
418 $self->adaptor && $self->{'dbID
'}) {
419 $self->adaptor->fetch_attributes($self);
422 my @out = values %{$self->{'map_locations
'}};
429 =head2 get_MapLocation
431 Arg [1] : string $map_name
432 Example : $map_location = $marker->get_MapLocation('genethon
');
433 Description: Retrieves the location of this marker in a specified map.
434 If this marker is not defined in the specified map then
436 Returntype : Bio::EnsEMBL::Map::MapLocation
437 Exceptions : thrown if the map_name arg is not provided
443 sub get_MapLocation {
445 my $map_name = shift;
447 #lazy-load the map locations if they have not been fetched yet
448 if(!exists $self->{'map_locations
'} &&
449 $self->adaptor && $self->{'dbID
'}) {
450 $self->adaptor->fetch_attributes($self);
454 throw('map_name argument is required, or use get_all_MapLocations
');
457 return $self->{'map_locations
'}->{$map_name};
462 =head2 add_MapLocations
464 Arg [1..n] : @mlocs list of Bio::EnsEMBL::MapLocations
465 Example : $marker->add_MapLocations(@mlocs);
466 Description: Associates 1 or more map locations with this marker
467 using this function to manually load map locations will prevent
468 lazy-loading of locations from the database.
469 Returntype : listref of Bio::EnsEMBL::MapLocations
470 Exceptions : throws if map location has no name
476 sub add_MapLocations {
477 my ($self, @mlocs) = @_;
479 foreach my $ml (@mlocs) {
480 unless($ml && ref $ml && $ml->isa('Bio::EnsEMBL::Map::MapLocation
')) {
481 throw("args must be Bio::EnsEMBL::Map::MapLocations not [$ml]");
484 my $mname = $ml->map_name;
486 throw("map location arg [$ml] does not define a map name");
489 $self->{'map_locations
'}->{$mname} = $ml;
496 =head2 flush_MapLocations
499 Example : $marker->get_all_MapLocations;
500 Description: Removes map locations associated with this marker. Markers may
501 be lazy-loaded from the database (again) after this.
509 sub flush_MapLocations{
512 delete $self->{'map_locations
'};