| 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'; | ||
| 49 | use strict; | ||
| 50 | use vars qw(@ISA); | ||
| 51 | |||
| 52 | use Bio::EnsEMBL::Storable; | ||
| 53 | use Bio::EnsEMBL::Utils::Exception qw(throw); | ||
| 54 | |||
| 55 | @ISA = qw(Bio::EnsEMBL::Storable); | ||
| 56 | |||
| 57 | |||
| 58 | |||
| 59 | =head2 new | ||
| 60 | |||
| 61 | Arg [1] : (optional) int $dbID | ||
| 62 | Arg [2] : (optional) Bio::EnsEMBL::Map::DBSQL::MarkerAdaptor $adaptor | ||
| 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 | ||
| 68 | Arg [8] : (optional) Bio::EnsEMBL::Map::MarkerSynonym $display_synonym | ||
| 69 | Arg [9] : (optional) listref of Bio::EnsEMBL::Map::MarkerSynonyms $syns | ||
| 70 | Arg [10] : (optional) listref of Bio::EnsEMBL::Map::MapLocations $locs | ||
| 71 | Example : $marker = Bio::EnsEMBL::Map::MarkerSynonym->new | ||
| 72 | (123, $adaptor, | ||
| 73 | $left_primer, $right_primer, 400, | ||
| 74 | 80, $ms1, [$ms1, $ms2], [$mloc1, $mloc2]); | ||
| 75 | Description: Creates a new Marker | ||
| 76 | Returntype : Bio::EnsEMBL::Map::Marker | ||
| 77 | Exceptions : none | ||
| 78 | Caller : general | ||
| 79 | Status : stable | ||
| 80 | |||
| 81 | =cut | ||
| 82 | |||
| 83 | sub new { | ||
| 84 | my ($caller, $dbID, $adaptor, $left_primer, $right_primer, | ||
| 85 | $min_primer_dist, $max_primer_dist, $priority, $type, $display_synonym, | ||
| 86 | $syns, $mlocs) = @_; | ||
| 87 | |||
| 88 | my $class = ref($caller) || $caller; | ||
| 89 | |||
| 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, | ||
| 96 | 'type' => $type, | ||
| 97 | 'display_marker_synonym' => $display_synonym | ||
| 98 | }, $class); | ||
| 99 | |||
| 100 | $self->adaptor($adaptor); | ||
| 101 | |||
| 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; | ||
| 106 | } | ||
| 107 | |||
| 108 | #only load the map_locations if they were supplied, otherwise they will | ||
| 109 | # be lazy-loaded | ||
| 110 | if($mlocs) { | ||
| 111 | foreach my $ml (@$mlocs) { | ||
| 112 | $self->add_MapLocation($ml); | ||
| 113 | } | ||
| 114 | } | ||
| 115 | |||
| 116 | return $self; | ||
| 117 | } | ||
| 118 | |||
| 119 | |||
| 120 | =head2 left_primer | ||
| 121 | |||
| 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 | ||
| 125 | Returntype : string | ||
| 126 | Exceptions : none | ||
| 127 | Caller : general | ||
| 128 | Status : stable | ||
| 129 | |||
| 130 | =cut | ||
| 131 | |||
| 132 | sub left_primer { | ||
| 133 | my $self = shift; | ||
| 134 | |||
| 135 | if(@_) { | ||
| 136 | $self->{'left_primer'} = shift; | ||
| 137 | } | ||
| 138 | |||
| 139 | return $self->{'left_primer'}; | ||
| 140 | } | ||
| 141 | |||
| 142 | |||
| 143 | |||
| 144 | =head2 right_primer | ||
| 145 | |||
| 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 | ||
| 149 | Returntype : string | ||
| 150 | Exceptions : none | ||
| 151 | Caller : general | ||
| 152 | Status : stable | ||
| 153 | |||
| 154 | =cut | ||
| 155 | |||
| 156 | sub right_primer { | ||
| 157 | my $self = shift; | ||
| 158 | |||
| 159 | if(@_) { | ||
| 160 | $self->{'right_primer'} = shift; | ||
| 161 | } | ||
| 162 | |||
| 163 | return $self->{'right_primer'}; | ||
| 164 | } | ||
| 165 | |||
| 166 | |||
| 167 | |||
| 168 | =head2 min_primer_dist | ||
| 169 | |||
| 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 | ||
| 174 | Returntype : int | ||
| 175 | Exceptions : none | ||
| 176 | Caller : general | ||
| 177 | Status : stable | ||
| 178 | |||
| 179 | =cut | ||
| 180 | |||
| 181 | sub min_primer_dist { | ||
| 182 | my $self = shift; | ||
| 183 | |||
| 184 | if(@_) { | ||
| 185 | $self->{'min_primer_dist'} = shift; | ||
| 186 | } | ||
| 187 | |||
| 188 | return $self->{'min_primer_dist'}; | ||
| 189 | } | ||
| 190 | |||
| 191 | |||
| 192 | =head2 max_primer_dist | ||
| 193 | |||
| 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 | ||
| 198 | Returntype : int | ||
| 199 | Exceptions : none | ||
| 200 | Caller : general | ||
| 201 | Status : stable | ||
| 202 | |||
| 203 | =cut | ||
| 204 | |||
| 205 | sub max_primer_dist { | ||
| 206 | my $self = shift; | ||
| 207 | |||
| 208 | if(@_) { | ||
| 209 | $self->{'max_primer_dist'} = shift; | ||
| 210 | } | ||
| 211 | |||
| 212 | return $self->{'max_primer_dist'}; | ||
| 213 | } | ||
| 214 | |||
| 215 | |||
| 216 | |||
| 217 | =head2 priority | ||
| 218 | |||
| 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. | ||
| 223 | Returntype : int | ||
| 224 | Exceptions : none | ||
| 225 | Caller : general | ||
| 226 | Status : stable | ||
| 227 | |||
| 228 | =cut | ||
| 229 | |||
| 230 | sub priority { | ||
| 231 | my $self = shift; | ||
| 232 | |||
| 233 | if(@_) { | ||
| 234 | $self->{'priority'} = shift; | ||
| 235 | } | ||
| 236 | |||
| 237 | return $self->{'priority'}; | ||
| 238 | } | ||
| 239 | |||
| 240 | |||
| 241 | |||
| 242 | |||
| 243 | =head2 type | ||
| 244 | |||
| 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 | ||
| 249 | defined types. | ||
| 250 | Returntype : string | ||
| 251 | Exceptions : none | ||
| 252 | Caller : general | ||
| 253 | Status : stable | ||
| 254 | |||
| 255 | =cut | ||
| 256 | |||
| 257 | sub type { | ||
| 258 | my $self = shift; | ||
| 259 | |||
| 260 | if(@_) { | ||
| 261 | $self->{'type'} = shift; | ||
| 262 | } | ||
| 263 | |||
| 264 | return $self->{'type'}; | ||
| 265 | } | ||
| 266 | |||
| 267 | |||
| 268 | |||
| 269 | |||
| 270 | =head2 get_all_MarkerSynonyms | ||
| 271 | |||
| 272 | Arg [1] : none | ||
| 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 | ||
| 276 | has an adaptor and | ||
| 277 | Returntype : listref of Bio::EnsEMBL::Map::MarkerSynonyms | ||
| 278 | Exceptions : none | ||
| 279 | Caller : general | ||
| 280 | Status : stable | ||
| 281 | |||
| 282 | =cut | ||
| 283 | |||
| 284 | sub get_all_MarkerSynonyms { | ||
| 285 | my $self = shift; | ||
| 286 | |||
| 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); | ||
| 291 | } | ||
| 292 | |||
| 293 | return $self->{'marker_synonyms'} || []; | ||
| 294 | } | ||
| 295 | |||
| 296 | |||
| 297 | |||
| 298 | =head2 add_MarkerSynonyms | ||
| 299 | |||
| 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 | ||
| 306 | is called first). | ||
| 307 | Returntype : none | ||
| 308 | Exceptions : thrown if incorrect argument is passed | ||
| 309 | Caller : general | ||
| 310 | Status : stable | ||
| 311 | |||
| 312 | =cut | ||
| 313 | |||
| 314 | sub add_MarkerSynonyms { | ||
| 315 | my ($self, @ms) = @_; | ||
| 316 | |||
| 317 | #create the array if it does not exist it | ||
| 318 | $self->{'marker_synonyms'} ||= []; | ||
| 319 | |||
| 320 | push(@{$self->{'marker_synonyms'}}, @ms); | ||
| 321 | } | ||
| 322 | |||
| 323 | |||
| 324 | |||
| 325 | =head2 flush_MarkerSynonyms | ||
| 326 | |||
| 327 | Arg [1] : none | ||
| 328 | Example : $marker->flush_MarkerSynonyms; | ||
| 329 | Description: clears all of the marker sysnonyms which have been added to | ||
| 330 | this marker. | ||
| 331 | Returntype : none | ||
| 332 | Exceptions : none | ||
| 333 | Caller : general | ||
| 334 | Status : stable | ||
| 335 | |||
| 336 | =cut | ||
| 337 | |||
| 338 | sub flush_MarkerSynonyms { | ||
| 339 | my $self = shift; | ||
| 340 | |||
| 341 | delete $self->{'marker_synonyms'}; | ||
| 342 | } | ||
| 343 | |||
| 344 | |||
| 345 | |||
| 346 | =head2 display_MarkerSynonym | ||
| 347 | |||
| 348 | Arg [1] : (optional) Bio::EnsEMBL::DBSQL::MarkerSynonym $ms | ||
| 349 | Example : none | ||
| 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 | ||
| 353 | Caller : general | ||
| 354 | Status : stable | ||
| 355 | |||
| 356 | =cut | ||
| 357 | |||
| 358 | sub display_MarkerSynonym { | ||
| 359 | my $self = shift; | ||
| 360 | |||
| 361 | if(@_) { | ||
| 362 | my $ms = shift; | ||
| 363 | if($ms && !(ref $ms && $ms->isa('Bio::EnsEMBL::Map::MarkerSynonym'))) { | ||
| 364 | throw("ms arg must be Bio::EnsEMBL::Map::MarkerSynonym not [$ms]"); | ||
| 365 | } | ||
| 366 | $self->{'display_marker_synonym'} = $ms; | ||
| 367 | } | ||
| 368 | |||
| 369 | |||
| 370 | return $self->{'display_marker_synonym'}; | ||
| 371 | } | ||
| 372 | |||
| 373 | |||
| 374 | |||
| 375 | =head2 get_all_MarkerFeatures | ||
| 376 | |||
| 377 | Arg [1] : none | ||
| 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 | ||
| 381 | the genome via e-PCR | ||
| 382 | Returntype : listref of Bio::EnsEMBL::Map::MarkerFeatures | ||
| 383 | Exceptions : none | ||
| 384 | Caller : general | ||
| 385 | Status : stable | ||
| 386 | |||
| 387 | =cut | ||
| 388 | |||
| 389 | sub get_all_MarkerFeatures { | ||
| 390 | my $self = shift; | ||
| 391 | |||
| 392 | my $marker_feature_adaptor = $self->adaptor->db->get_MarkerFeatureAdaptor; | ||
| 393 | |||
| 394 | #these results are not cached to avoid a circular reference loop | ||
| 395 | return $marker_feature_adaptor->fetch_all_by_Marker($self); | ||
| 396 | } | ||
| 397 | |||
| 398 | |||
| 399 | |||
| 400 | =head2 get_all_MapLocations | ||
| 401 | |||
| 402 | Arg [1] : none | ||
| 403 | Example : @map_locations = @{$marker->get_all_MapLocations}; | ||
| 404 | Description: Retrieves all map locations which are associated with this | ||
| 405 | marker. | ||
| 406 | Returntype : listref of Bio::EnsEMBL::Map::MapLocations | ||
| 407 | Exceptions : none | ||
| 408 | Caller : general | ||
| 409 | Status : stable | ||
| 410 | |||
| 411 | =cut | ||
| 412 | |||
| 413 | sub get_all_MapLocations { | ||
| 414 | my $self = shift; | ||
| 415 | |||
| 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); | ||
| 420 | } | ||
| 421 | |||
| 422 | my @out = values %{$self->{'map_locations'}}; | ||
| 423 | |||
| 424 | return \@out; | ||
| 425 | } | ||
| 426 | |||
| 427 | |||
| 428 | |||
| 429 | =head2 get_MapLocation | ||
| 430 | |||
| 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 | ||
| 435 | undef is returned. | ||
| 436 | Returntype : Bio::EnsEMBL::Map::MapLocation | ||
| 437 | Exceptions : thrown if the map_name arg is not provided | ||
| 438 | Caller : general | ||
| 439 | Status : stable | ||
| 440 | |||
| 441 | =cut | ||
| 442 | |||
| 443 | sub get_MapLocation { | ||
| 444 | my $self = shift; | ||
| 445 | my $map_name = shift; | ||
| 446 | |||
| 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); | ||
| 451 | } | ||
| 452 | |||
| 453 | unless($map_name) { | ||
| 454 | throw('map_name argument is required, or use get_all_MapLocations'); | ||
| 455 | } | ||
| 456 | |||
| 457 | return $self->{'map_locations'}->{$map_name}; | ||
| 458 | } | ||
| 459 | |||
| 460 | |||
| 461 | |||
| 462 | =head2 add_MapLocations | ||
| 463 | |||
| 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 | ||
| 471 | Caller : general | ||
| 472 | Status : stable | ||
| 473 | |||
| 474 | =cut | ||
| 475 | |||
| 476 | sub add_MapLocations { | ||
| 477 | my ($self, @mlocs) = @_; | ||
| 478 | |||
| 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]"); | ||
| 482 | } | ||
| 483 | |||
| 484 | my $mname = $ml->map_name; | ||
| 485 | unless($mname) { | ||
| 486 | throw("map location arg [$ml] does not define a map name"); | ||
| 487 | } | ||
| 488 | |||
| 489 | $self->{'map_locations'}->{$mname} = $ml; | ||
| 490 | } | ||
| 491 | } | ||
| 492 | |||
| 493 | |||
| 494 | |||
| 495 | |||
| 496 | =head2 flush_MapLocations | ||
| 497 | |||
| 498 | Arg [1] : none | ||
| 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. | ||
| 502 | Returntype : none | ||
| 503 | Exceptions : | ||
| 504 | Caller : | ||
| 505 | Status : stable | ||
| 506 | |||
| 507 | =cut | ||
| 508 | |||
| 509 | sub flush_MapLocations{ | ||
| 510 | my $self = shift; | ||
| 511 | |||
| 512 | delete $self->{'map_locations'}; | ||
| 513 | } | ||
| 514 | |||
| 515 | |||
| 516 | 1; | ||
| 517 | |||
| 518 | |||
| 519 | |||
| 520 |