Mercurial > repos > dvanzessen > vep_emc
comparison dir_plugins/Downstream.pm @ 3:49397129aec0 draft
Uploaded
| author | dvanzessen |
|---|---|
| date | Mon, 15 Jul 2019 05:20:39 -0400 |
| parents | e545d0a25ffe |
| children |
comparison
equal
deleted
inserted
replaced
| 2:17c98d091710 | 3:49397129aec0 |
|---|---|
| 1 =head1 LICENSE | |
| 2 | |
| 3 Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute | |
| 4 Copyright [2016-2018] EMBL-European Bioinformatics Institute | |
| 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 =head1 CONTACT | |
| 19 | |
| 20 Ensembl <http://www.ensembl.org/info/about/contact/index.html> | |
| 21 | |
| 22 =cut | |
| 23 | |
| 24 =head1 NAME | |
| 25 | |
| 26 Downstream | |
| 27 | |
| 28 =head1 SYNOPSIS | |
| 29 | |
| 30 mv Downstream.pm ~/.vep/Plugins | |
| 31 ./vep -i variations.vcf --plugin Downstream | |
| 32 | |
| 33 =head1 DESCRIPTION | |
| 34 | |
| 35 This is a plugin for the Ensembl Variant Effect Predictor (VEP) that | |
| 36 predicts the downstream effects of a frameshift variant on the protein | |
| 37 sequence of a transcript. It provides the predicted downstream protein | |
| 38 sequence (including any amino acids overlapped by the variant itself), | |
| 39 and the change in length relative to the reference protein. | |
| 40 | |
| 41 Note that changes in splicing are not predicted - only the existing | |
| 42 translateable (i.e. spliced) sequence is used as a source of | |
| 43 translation. Any variants with a splice site consequence type are | |
| 44 ignored. | |
| 45 | |
| 46 =cut | |
| 47 | |
| 48 package Downstream; | |
| 49 | |
| 50 use strict; | |
| 51 use warnings; | |
| 52 | |
| 53 use Bio::EnsEMBL::Variation::Utils::BaseVepPlugin; | |
| 54 use POSIX qw(ceil); | |
| 55 | |
| 56 use base qw(Bio::EnsEMBL::Variation::Utils::BaseVepPlugin); | |
| 57 | |
| 58 sub version { | |
| 59 return '2.3'; | |
| 60 } | |
| 61 | |
| 62 sub feature_types { | |
| 63 return ['Transcript']; | |
| 64 } | |
| 65 | |
| 66 sub variant_feature_types { | |
| 67 return ['VariationFeature']; | |
| 68 } | |
| 69 | |
| 70 sub get_header_info { | |
| 71 return { | |
| 72 DownstreamProtein => "Predicted downstream translation for frameshift mutations", | |
| 73 ProteinLengthChange => "Predicted change in protein product length", | |
| 74 }; | |
| 75 } | |
| 76 | |
| 77 sub run { | |
| 78 my ($self, $tva) = @_; | |
| 79 | |
| 80 my @ocs = @{$tva->get_all_OverlapConsequences}; | |
| 81 | |
| 82 if(grep {$_->SO_term eq 'frameshift_variant'} @ocs) { | |
| 83 | |
| 84 # can't do it for splice sites | |
| 85 return {} if grep {$_->SO_term =~ /splice/} @ocs; | |
| 86 | |
| 87 my $tv = $tva->transcript_variation; | |
| 88 my $tr = $tv->transcript; | |
| 89 my $cds_seq = defined($tr->{_variation_effect_feature_cache}) ? $tr->{_variation_effect_feature_cache}->{translateable_seq} : $tr->translateable_seq; | |
| 90 | |
| 91 # get the sequence to translate | |
| 92 my ($low_pos, $high_pos) = sort {$a <=> $b} ($tv->cds_start, $tv->cds_end); | |
| 93 my $is_insertion = $tv->cds_start > $tv->cds_end ? 1 : 0; | |
| 94 my $last_complete_codon = (ceil($low_pos / 3) - 1) * 3; | |
| 95 my $before_var_seq = substr $cds_seq, $last_complete_codon, $low_pos - $last_complete_codon - ($is_insertion ? 0 : 1); | |
| 96 my $after_var_seq = substr $cds_seq, $high_pos - ($is_insertion ? 1 : 0); | |
| 97 my $to_translate = $before_var_seq.$tva->feature_seq.$after_var_seq; | |
| 98 my $three_prime_utr_seq = $tr->three_prime_utr->seq() if ($tr->three_prime_utr); | |
| 99 $to_translate = $to_translate.$three_prime_utr_seq if ($three_prime_utr_seq); | |
| 100 $to_translate =~ s/\-//g; | |
| 101 | |
| 102 # create a bioperl object | |
| 103 my $codon_seq = Bio::Seq->new( | |
| 104 -seq => $to_translate, | |
| 105 -moltype => 'dna', | |
| 106 -alphabet => 'dna' | |
| 107 ); | |
| 108 | |
| 109 # get codon table | |
| 110 my $codon_table; | |
| 111 if(defined($tr->{_variation_effect_feature_cache})) { | |
| 112 $codon_table = $tr->{_variation_effect_feature_cache}->{codon_table} || 1; | |
| 113 } | |
| 114 else { | |
| 115 my ($attrib) = @{$tr->slice->get_all_Attributes('codon_table')}; | |
| 116 $codon_table = $attrib ? $attrib->value || 1 : 1; | |
| 117 } | |
| 118 | |
| 119 # translate | |
| 120 my $new_pep = $codon_seq->translate(undef, undef, undef, $codon_table)->seq(); | |
| 121 $new_pep =~ s/\*.*//; | |
| 122 | |
| 123 # compare lengths | |
| 124 my $translation = defined($tr->{_variation_effect_feature_cache}) && defined($tr->{_variation_effect_feature_cache}->{peptide}) ? $tr->{_variation_effect_feature_cache}->{peptide} : $tr->translation->seq; | |
| 125 my $new_length = ($tv->translation_start < $tv->translation_end ? $tv->translation_start : $tv->translation_end) + length($new_pep); | |
| 126 | |
| 127 return { | |
| 128 DownstreamProtein => $new_pep, | |
| 129 ProteinLengthChange => $new_length - length($translation), | |
| 130 }; | |
| 131 } | |
| 132 | |
| 133 return {}; | |
| 134 } | |
| 135 | |
| 136 1; | |
| 137 |
