Mercurial > repos > mahtabm > ensembl
comparison variant_effect_predictor/Bio/EnsEMBL/Variation/BaseStructuralVariation.pm @ 0:1f6dce3d34e0
Uploaded
| author | mahtabm |
|---|---|
| date | Thu, 11 Apr 2013 02:01:53 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:1f6dce3d34e0 |
|---|---|
| 1 =head1 LICENSE | |
| 2 | |
| 3 Copyright (c) 1999-2012 The European Bioinformatics Institute and | |
| 4 Genome Research Limited. All rights reserved. | |
| 5 | |
| 6 This software is distributed under a modified Apache license. | |
| 7 For license details, please see | |
| 8 | |
| 9 http://www.ensembl.org/info/about/code_licence.html | |
| 10 | |
| 11 =head1 CONTACT | |
| 12 | |
| 13 Please email comments or questions to the public Ensembl | |
| 14 developers list at <dev@ensembl.org>. | |
| 15 | |
| 16 Questions may also be sent to the Ensembl help desk at | |
| 17 <helpdesk@ensembl.org>. | |
| 18 | |
| 19 =cut | |
| 20 | |
| 21 # Ensembl module for Bio::EnsEMBL::Variation::BaseStructuralVariation | |
| 22 # | |
| 23 # Copyright (c) 2011 Ensembl | |
| 24 # | |
| 25 | |
| 26 | |
| 27 =head1 NAME | |
| 28 | |
| 29 Bio::EnsEMBL::Variation::BaseStructuralVariation - Ensembl representation of a structural variant. | |
| 30 | |
| 31 =head1 SYNOPSIS | |
| 32 | |
| 33 # Structural variation representing a CNV | |
| 34 $sv = Bio::EnsEMBL::Variation::StructuralVariation->new | |
| 35 (-variation_name => 'esv25480', | |
| 36 -class_so_term => 'structural_variant', | |
| 37 -source => 'DGVa', | |
| 38 -source_description => 'Database of Genomic Variants Archive', | |
| 39 -study_name => 'estd20', | |
| 40 -study_description => 'Conrad 2009 "Origins and functional impact of copy number variation in the human genome." PMID:19812545 [remapped from build NCBI36]', | |
| 41 -study_url => 'ftp://ftp.ebi.ac.uk/pub/databases/dgva/estd20_Conrad_et_al_2009', | |
| 42 -external_reference => 'pubmed/19812545'); | |
| 43 | |
| 44 ... | |
| 45 | |
| 46 print $sv->name(), ":", $sv->var_class(); | |
| 47 | |
| 48 =head1 DESCRIPTION | |
| 49 | |
| 50 This is a class representing a structural variation from the | |
| 51 ensembl-variation database. A structural variant may have a copy number variation, a tandem duplication, | |
| 52 an inversion of the sequence or others structural variations. | |
| 53 | |
| 54 The position of a StructuralVariation object on the Genome is represented | |
| 55 by the B<Bio::EnsEMBL::Variation::StructuralVariationFeature> class. | |
| 56 | |
| 57 =head1 METHODS | |
| 58 | |
| 59 =cut | |
| 60 | |
| 61 use strict; | |
| 62 use warnings; | |
| 63 | |
| 64 package Bio::EnsEMBL::Variation::BaseStructuralVariation; | |
| 65 | |
| 66 use Bio::EnsEMBL::Storable; | |
| 67 use Bio::EnsEMBL::Utils::Exception qw(throw warning deprecate); | |
| 68 use Bio::EnsEMBL::Utils::Argument qw(rearrange); | |
| 69 use Bio::EnsEMBL::Variation::Utils::Constants qw(%VARIATION_CLASSES); | |
| 70 use Bio::EnsEMBL::Variation::Failable; | |
| 71 our @ISA = ('Bio::EnsEMBL::Storable','Bio::EnsEMBL::Variation::Failable'); | |
| 72 | |
| 73 =head2 new | |
| 74 | |
| 75 Arg [-dbID] : | |
| 76 see superclass constructor | |
| 77 | |
| 78 Arg [-ADAPTOR] : | |
| 79 see superclass constructor | |
| 80 | |
| 81 Arg [-VARIATION_NAME] : | |
| 82 string - the name of the structural variant. | |
| 83 | |
| 84 Arg [-CLASS_SO_TERM] : | |
| 85 string - the sequence ontology term defining the class of the structural variant. | |
| 86 | |
| 87 Arg [-SOURCE] : | |
| 88 string - the name of the source where the structural variant comes from | |
| 89 | |
| 90 Arg [-SOURCE_DESCRIPTION] : | |
| 91 string - description of the source | |
| 92 | |
| 93 Arg [-TYPE] : | |
| 94 string - the class of structural variant e.g. 'copy_number_variation' | |
| 95 | |
| 96 Arg [-STUDY] : | |
| 97 object ref - the study object describing where the structural variant comes from. | |
| 98 | |
| 99 Arg [-VALIDATION_STATUS] : | |
| 100 string - the status of the structural variant (e.g. validated, not validated, ...) | |
| 101 | |
| 102 Arg [-IS_EVIDENCE] : | |
| 103 int - flag to inform whether the structural variant is a supporting evidence (1) or not (0). | |
| 104 | |
| 105 Arg [-IS_SOMATIC] : | |
| 106 int - flag to inform whether the structural variant is a somatic (1) or germline (0). | |
| 107 | |
| 108 Example for a structural variation: | |
| 109 $sv = Bio::EnsEMBL::Variation::StructuralVariation->new | |
| 110 (-variation_name => 'esv25480', | |
| 111 -class_so_term => 'copy_number_variation', | |
| 112 -source => 'DGVa', | |
| 113 -source_description => 'Database of Genomic Variants Archive', | |
| 114 | |
| 115 Description: Constructor. Instantiates a new structural variant object. | |
| 116 Returntype : Bio::EnsEMBL::Variation::StructuralVariation or | |
| 117 Bio::EnsEMBL::Variation::SupportingStructuralVariation | |
| 118 Exceptions : none | |
| 119 Caller : general | |
| 120 Status : At Risk | |
| 121 | |
| 122 =cut | |
| 123 | |
| 124 sub new { | |
| 125 my $caller = shift; | |
| 126 my $class = ref($caller) || $caller; | |
| 127 | |
| 128 my ( | |
| 129 $dbID, | |
| 130 $adaptor, | |
| 131 $var_name, | |
| 132 $source, | |
| 133 $source_version, | |
| 134 $source_description, | |
| 135 $class_so_term, | |
| 136 $study, | |
| 137 $validation_status, | |
| 138 $is_evidence, | |
| 139 $is_somatic | |
| 140 ) = rearrange([qw( | |
| 141 dbID | |
| 142 ADAPTOR | |
| 143 VARIATION_NAME | |
| 144 SOURCE | |
| 145 SOURCE_VERSION | |
| 146 SOURCE_DESCRIPTION | |
| 147 CLASS_SO_TERM | |
| 148 STUDY | |
| 149 VALIDATION_STATES | |
| 150 IS_EVIDENCE | |
| 151 IS_SOMATIC | |
| 152 )], @_); | |
| 153 | |
| 154 my $self = bless { | |
| 155 'dbID' => $dbID, | |
| 156 'adaptor' => $adaptor, | |
| 157 'variation_name' => $var_name, | |
| 158 'source' => $source, | |
| 159 'source_version' => $source_version, | |
| 160 'source_description' => $source_description, | |
| 161 'class_SO_term' => $class_so_term, | |
| 162 'study' => $study, | |
| 163 'validation_status' => $validation_status, | |
| 164 'is_evidence' => $is_evidence || 0, | |
| 165 'is_somatic' => $is_somatic || 0, | |
| 166 }; | |
| 167 return $self; | |
| 168 } | |
| 169 | |
| 170 | |
| 171 | |
| 172 sub new_fast { | |
| 173 my $class = shift; | |
| 174 my $hashref = shift; | |
| 175 return bless $hashref, $class; | |
| 176 } | |
| 177 | |
| 178 | |
| 179 =head2 display_id | |
| 180 | |
| 181 Arg [1] : none | |
| 182 Example : print $sv->display_id(), "\n"; | |
| 183 Description: Returns the 'display' identifier for this structural variant. | |
| 184 Returntype : string | |
| 185 Exceptions : none | |
| 186 Caller : webcode | |
| 187 Status : At Risk | |
| 188 | |
| 189 =cut | |
| 190 | |
| 191 sub display_id { | |
| 192 my $self = shift; | |
| 193 return $self->{'variation_name'} || ''; | |
| 194 } | |
| 195 | |
| 196 | |
| 197 | |
| 198 =head2 variation_name | |
| 199 | |
| 200 Arg [1] : string $newval (optional) | |
| 201 The new value to set the variation_name attribute to | |
| 202 Example : $variation_name = $obj->variation_name() | |
| 203 Description: Getter/Setter for the variation_name attribute. This is the | |
| 204 name of the variation associated with this feature. | |
| 205 Returntype : string | |
| 206 Exceptions : none | |
| 207 Caller : general | |
| 208 Status : Stable | |
| 209 | |
| 210 =cut | |
| 211 | |
| 212 sub variation_name{ | |
| 213 my $self = shift; | |
| 214 return $self->{'variation_name'} = shift if(@_); | |
| 215 return $self->{'variation_name'}; | |
| 216 } | |
| 217 | |
| 218 =head2 var_class | |
| 219 | |
| 220 Args : None | |
| 221 Example : my $sv_class = $sv->var_class() | |
| 222 Description : Getter/setter for the class of structural variant | |
| 223 ReturnType : String | |
| 224 Exceptions : none | |
| 225 Caller : General | |
| 226 Status : At Risk | |
| 227 | |
| 228 =cut | |
| 229 | |
| 230 sub var_class { | |
| 231 my $self = shift; | |
| 232 | |
| 233 unless ($self->{class_display_term}) { | |
| 234 my $display_term = $VARIATION_CLASSES{$self->{class_SO_term}}->{display_term}; | |
| 235 | |
| 236 warn "No display term for SO term: ".$self->{class_SO_term} unless $display_term; | |
| 237 | |
| 238 $self->{class_display_term} = $display_term || $self->{class_SO_term}; | |
| 239 } | |
| 240 | |
| 241 return $self->{class_display_term}; | |
| 242 } | |
| 243 | |
| 244 | |
| 245 =head2 class_SO_term | |
| 246 | |
| 247 Args : None | |
| 248 Example : my $sv_so_term = $svf->class_SO_term() | |
| 249 Description : Getter for the class of structural variant, returning the SO term | |
| 250 ReturnType : String | |
| 251 Exceptions : none | |
| 252 Caller : General | |
| 253 Status : At Risk | |
| 254 | |
| 255 =cut | |
| 256 | |
| 257 sub class_SO_term { | |
| 258 my $self = shift; | |
| 259 | |
| 260 return $self->{class_SO_term}; | |
| 261 } | |
| 262 | |
| 263 | |
| 264 =head2 source | |
| 265 | |
| 266 Arg [1] : string $source (optional) | |
| 267 The new value to set the source attribute to | |
| 268 Example : $source = $svf->source() | |
| 269 Description: Getter/Setter for the source attribute | |
| 270 Returntype : string | |
| 271 Exceptions : none | |
| 272 Caller : general | |
| 273 Status : At Risk | |
| 274 | |
| 275 =cut | |
| 276 | |
| 277 sub source { | |
| 278 my $self = shift; | |
| 279 return $self->{'source'} = shift if(@_); | |
| 280 return $self->{'source'}; | |
| 281 } | |
| 282 | |
| 283 | |
| 284 =head2 source_version | |
| 285 | |
| 286 Arg [1] : string $source_version (optional) | |
| 287 The new value to set the source_version attribute to | |
| 288 Example : $source_version = $svf->source_version() | |
| 289 Description: Getter/Setter for the source_version attribute | |
| 290 Returntype : string | |
| 291 Exceptions : none | |
| 292 Caller : general | |
| 293 Status : At Risk | |
| 294 | |
| 295 =cut | |
| 296 | |
| 297 sub source_version { | |
| 298 my $self = shift; | |
| 299 return $self->{'source_version'} = shift if(@_); | |
| 300 return $self->{'source_version'}; | |
| 301 } | |
| 302 | |
| 303 | |
| 304 =head2 source_description | |
| 305 | |
| 306 Arg [1] : string $source_description (optional) | |
| 307 The new value to set the source_description attribute to | |
| 308 Example : $source_description = $svf->source_description() | |
| 309 Description: Getter/Setter for the source_description attribute | |
| 310 Returntype : string | |
| 311 Exceptions : none | |
| 312 Caller : general | |
| 313 Status : At Risk | |
| 314 | |
| 315 =cut | |
| 316 | |
| 317 sub source_description { | |
| 318 my $self = shift; | |
| 319 return $self->{'source_description'} = shift if(@_); | |
| 320 return $self->{'source_description'}; | |
| 321 } | |
| 322 | |
| 323 | |
| 324 =head2 get_all_validation_states | |
| 325 | |
| 326 Arg [1] : none | |
| 327 Example : my @vstates = @{$v->get_all_validation_states()}; | |
| 328 Description: Retrieves all validation states for this structural variation. Current | |
| 329 possible validation statuses are 'validated','not validated', | |
| 330 'high quality' | |
| 331 Returntype : reference to list of strings | |
| 332 Exceptions : none | |
| 333 Caller : general | |
| 334 Status : At Risk | |
| 335 | |
| 336 =cut | |
| 337 | |
| 338 sub get_all_validation_states { | |
| 339 my $self = shift; | |
| 340 | |
| 341 return $self->{'validation_status'} || []; | |
| 342 } | |
| 343 | |
| 344 | |
| 345 =head2 is_evidence | |
| 346 | |
| 347 Arg [1] : int $flag (optional) | |
| 348 Example : $is_evidence = $obj->is_evidence() | |
| 349 Description: Getter/Setter of a flag to inform whether the structural variant is a | |
| 350 supporting evidence (1) or not (0). | |
| 351 Returntype : int | |
| 352 Exceptions : none | |
| 353 Caller : general | |
| 354 Status : Stable | |
| 355 | |
| 356 =cut | |
| 357 | |
| 358 sub is_evidence{ | |
| 359 my $self = shift; | |
| 360 return $self->{'is_evidence'} = shift if(@_); | |
| 361 return $self->{'is_evidence'}; | |
| 362 } | |
| 363 | |
| 364 =head2 is_somatic | |
| 365 | |
| 366 Arg [1] : int $flag (optional) | |
| 367 Example : $is_somatic = $obj->is_somatic() | |
| 368 Description: Getter/Setter of a flag to inform whether the structural variant is somatic (1) or germline (0). | |
| 369 Returntype : int | |
| 370 Exceptions : none | |
| 371 Caller : general | |
| 372 Status : Stable | |
| 373 | |
| 374 =cut | |
| 375 | |
| 376 sub is_somatic{ | |
| 377 my $self = shift; | |
| 378 return $self->{'is_somatic'} = shift if(@_); | |
| 379 return $self->{'is_somatic'}; | |
| 380 } | |
| 381 | |
| 382 | |
| 383 =head2 study | |
| 384 | |
| 385 Arg [1] : Bio::EnsEMBL::Variation::Study (optional) | |
| 386 Example : $study = $sv->study() | |
| 387 Description: Getter/Setter for the study object | |
| 388 Returntype : Bio::EnsEMBL::Variation::Study | |
| 389 Exceptions : none | |
| 390 Caller : general | |
| 391 Status : At Risk | |
| 392 | |
| 393 =cut | |
| 394 | |
| 395 sub study { | |
| 396 my $self = shift; | |
| 397 return $self->{'study'} = shift if(@_); | |
| 398 return $self->{'study'}; | |
| 399 } | |
| 400 | |
| 401 | |
| 402 =head2 study_name | |
| 403 | |
| 404 Arg [1] : string $study (optional) | |
| 405 The new value to set the study attribute to | |
| 406 Example : $study = $sv->study() | |
| 407 Description: Getter/Setter for the study attribute | |
| 408 Returntype : string | |
| 409 Exceptions : none | |
| 410 Caller : general | |
| 411 Status : Deprecated | |
| 412 | |
| 413 =cut | |
| 414 | |
| 415 sub study_name { | |
| 416 my $self = shift; | |
| 417 deprecate('Use the method "study" instead (returns a Bio::EnsEMBL::Variation::Study object).'); | |
| 418 return undef if (!$self->study); | |
| 419 return $self->study->name = shift if(@_); | |
| 420 return $self->study->name; | |
| 421 } | |
| 422 | |
| 423 | |
| 424 | |
| 425 =head2 study_description | |
| 426 | |
| 427 Arg [1] : string $study_description (optional) | |
| 428 The new value to set the study_description attribute to | |
| 429 Example : $study_description = $sv->study_description() | |
| 430 Description: Getter/Setter for the study_description attribute | |
| 431 Returntype : string | |
| 432 Exceptions : none | |
| 433 Caller : general | |
| 434 Status : Deprecated | |
| 435 | |
| 436 =cut | |
| 437 | |
| 438 sub study_description { | |
| 439 my $self = shift; | |
| 440 deprecate('Use the method "study" instead (returns a Bio::EnsEMBL::Variation::Study object).'); | |
| 441 return undef if (!$self->study); | |
| 442 return $self->study->description = shift if(@_); | |
| 443 return $self->study->description; | |
| 444 } | |
| 445 | |
| 446 =head2 study_url | |
| 447 | |
| 448 Arg [1] : string $newval (optional) | |
| 449 The new value to set the study_url attribute to | |
| 450 Example : $paper = $obj->study_url() | |
| 451 Description: Getter/Setter for the study_url attribute.This is the link to the website where the data are stored. | |
| 452 Returntype : string | |
| 453 Exceptions : none | |
| 454 Caller : general | |
| 455 Status : Deprecated | |
| 456 | |
| 457 =cut | |
| 458 | |
| 459 sub study_url{ | |
| 460 my $self = shift; | |
| 461 deprecate('Use the method "study" instead (returns a Bio::EnsEMBL::Variation::Study object).'); | |
| 462 return undef if (!$self->study); | |
| 463 return $self->study->url = shift if(@_); | |
| 464 return $self->study->url; | |
| 465 } | |
| 466 | |
| 467 | |
| 468 =head2 external_reference | |
| 469 | |
| 470 Arg [1] : string $newval (optional) | |
| 471 The new value to set the external reference attribute to | |
| 472 Example : $paper = $obj->external_reference() | |
| 473 Description: Getter/Setter for the external reference attribute. This is the | |
| 474 pubmed/id or project name associated with this study. | |
| 475 Returntype : string | |
| 476 Exceptions : none | |
| 477 Caller : general | |
| 478 Status : Deprecated | |
| 479 | |
| 480 =cut | |
| 481 | |
| 482 sub external_reference{ | |
| 483 my $self = shift; | |
| 484 deprecate('Use the method "study" instead (returns a Bio::EnsEMBL::Variation::Study object).'); | |
| 485 return undef if (!$self->study); | |
| 486 return $self->study->external_reference = shift if(@_); | |
| 487 return $self->study->external_reference; | |
| 488 } | |
| 489 | |
| 490 | |
| 491 =head2 get_all_StructuralVariationFeatures | |
| 492 | |
| 493 Args : None | |
| 494 Example : $svfs = $sv->get_all_StructuralVariationFeatures(); | |
| 495 Description : Retrieves all StructuralVariationFeature for this structural variant | |
| 496 ReturnType : reference to list of Bio::EnsEMBL::Variation::StructuralVariationFeature | |
| 497 Exceptions : None | |
| 498 Caller : general | |
| 499 Status : At Risk | |
| 500 | |
| 501 =cut | |
| 502 | |
| 503 sub get_all_StructuralVariationFeatures{ | |
| 504 my $self = shift; | |
| 505 | |
| 506 if(defined $self->{'adaptor'}) { | |
| 507 | |
| 508 # get structural variation feature adaptor | |
| 509 my $svf_adaptor = $self->{'adaptor'}->db()->get_StructuralVariationFeatureAdaptor(); | |
| 510 | |
| 511 return $svf_adaptor->fetch_all_by_StructuralVariation($self); | |
| 512 } | |
| 513 else { | |
| 514 warn("No variation database attached"); | |
| 515 return []; | |
| 516 } | |
| 517 } | |
| 518 | |
| 519 | |
| 520 =head2 get_all_StructuralVariationAnnotations | |
| 521 | |
| 522 Args : None | |
| 523 Example : $svas = $sv->get_all_StructuralVariationAnnotations(); | |
| 524 Description : Retrieves all get_all_StructuralVariationAnnotation for this structural variant | |
| 525 ReturnType : reference to list of Bio::EnsEMBL::Variation::StructuralVariationAnnotation | |
| 526 Exceptions : None | |
| 527 Caller : general | |
| 528 Status : At Risk | |
| 529 | |
| 530 =cut | |
| 531 | |
| 532 sub get_all_StructuralVariationAnnotations{ | |
| 533 my $self = shift; | |
| 534 | |
| 535 if(defined $self->{'adaptor'}) { | |
| 536 | |
| 537 # get structural variation annotation adaptor | |
| 538 my $sva_adaptor = $self->{'adaptor'}->db()->get_StructuralVariationAnnotationAdaptor(); | |
| 539 | |
| 540 return $sva_adaptor->fetch_all_by_StructuralVariation($self); | |
| 541 } | |
| 542 else { | |
| 543 warn("No variation database attached"); | |
| 544 return []; | |
| 545 } | |
| 546 } | |
| 547 | |
| 548 | |
| 549 =head2 summary_as_hash | |
| 550 | |
| 551 Example : $sv_summary = $sv->summary_as_hash(); | |
| 552 Description : Retrieves a textual summary of this StructuralVariation object. | |
| 553 Returns : hashref of descriptive strings | |
| 554 | |
| 555 =cut | |
| 556 | |
| 557 sub summary_as_hash { | |
| 558 my $self = shift; | |
| 559 my %summary; | |
| 560 $summary{'display_id'} = $self->display_id; | |
| 561 $summary{'study_name'} = $self->study_name; | |
| 562 $summary{'study_description'} = $self->study_description; | |
| 563 $summary{'class'} = $self->var_class; | |
| 564 return \%summary; | |
| 565 | |
| 566 } | |
| 567 | |
| 568 1; |
