Mercurial > repos > mahtabm > ensembl
comparison variant_effect_predictor/Bio/EnsEMBL/Variation/ExternalFeatureVariation.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 package Bio::EnsEMBL::Variation::ExternalFeatureVariation; | |
| 22 | |
| 23 use strict; | |
| 24 use warnings; | |
| 25 | |
| 26 use Bio::EnsEMBL::Variation::ExternalFeatureVariationAllele; | |
| 27 use Bio::EnsEMBL::Variation::Utils::VariationEffect qw(overlap); | |
| 28 | |
| 29 use base qw(Bio::EnsEMBL::Variation::RegulationVariation); | |
| 30 | |
| 31 sub new { | |
| 32 my $class = shift; | |
| 33 | |
| 34 my %args = @_; | |
| 35 | |
| 36 # swap a '-external_feature' argument for a '-feature' one for the superclass | |
| 37 | |
| 38 for my $arg (keys %args) { | |
| 39 if (lc($arg) eq '-external_feature') { | |
| 40 $args{'-feature'} = delete $args{$arg}; | |
| 41 } | |
| 42 } | |
| 43 | |
| 44 # call the superclass constructor | |
| 45 my $self = $class->SUPER::new(%args) || return undef; | |
| 46 | |
| 47 # rebless the alleles from vfoas to efvas | |
| 48 map { bless $_, 'Bio::EnsEMBL::Variation::ExternalFeatureVariationAllele' } | |
| 49 @{ $self->get_all_ExternalFeatureVariationAlleles }; | |
| 50 | |
| 51 return $self; | |
| 52 } | |
| 53 | |
| 54 sub external_feature_stable_id { | |
| 55 my $self = shift; | |
| 56 return $self->SUPER::feature_stable_id(@_); | |
| 57 } | |
| 58 | |
| 59 sub external_feature { | |
| 60 my ($self, $ef) = @_; | |
| 61 return $self->SUPER::feature($ef, 'ExternalFeature'); | |
| 62 } | |
| 63 | |
| 64 sub add_ExternalFeatureVariationAllele { | |
| 65 my $self = shift; | |
| 66 return $self->SUPER::add_VariationFeatureOverlapAllele(@_); | |
| 67 } | |
| 68 | |
| 69 sub get_reference_ExternalFeatureVariationAllele { | |
| 70 my $self = shift; | |
| 71 return $self->SUPER::get_reference_VariationFeatureOverlapAllele(@_); | |
| 72 } | |
| 73 | |
| 74 sub get_all_alternate_ExternalFeatureVariationAlleles { | |
| 75 my $self = shift; | |
| 76 return $self->SUPER::get_all_alternate_VariationFeatureOverlapAlleles(@_); | |
| 77 } | |
| 78 | |
| 79 sub get_all_ExternalFeatureVariationAlleles { | |
| 80 my $self = shift; | |
| 81 return $self->SUPER::get_all_VariationFeatureOverlapAlleles(@_); | |
| 82 } | |
| 83 | |
| 84 sub target_feature_stable_id { | |
| 85 my ($self, $target_feature_stable_id) = @_; | |
| 86 | |
| 87 $self->{target_feature_stable_id} = $target_feature_stable_id if $target_feature_stable_id; | |
| 88 | |
| 89 unless ($self->{target_feature_stable_id}) { | |
| 90 | |
| 91 # try to fetch it from the funcgen database | |
| 92 | |
| 93 if (my $species = $self->{adaptor}->db->species) { | |
| 94 for my $entry ( | |
| 95 @{ $self->external_feature->get_all_DBEntries($species.'_core_Transcript') }, | |
| 96 @{ $self->external_feature->get_all_DBEntries($species.'_core_Gene') } ) { | |
| 97 if (my $id = $entry->primary_id) { | |
| 98 | |
| 99 $self->{target_feature_stable_id} = $id; | |
| 100 | |
| 101 # there should never be more than one, so we last out of the loop | |
| 102 | |
| 103 last; | |
| 104 } | |
| 105 } | |
| 106 } | |
| 107 else { | |
| 108 warn "Failed to get species from adaptor"; | |
| 109 } | |
| 110 } | |
| 111 | |
| 112 return $self->{target_feature_stable_id}; | |
| 113 } | |
| 114 | |
| 115 1; |
