forked from Ensembl/VEP_plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdbscSNV.pm
192 lines (133 loc) · 4.77 KB
/
dbscSNV.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
=head1 LICENSE
Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
Copyright [2016] EMBL-European Bioinformatics Institute
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=head1 CONTACT
Will McLaren <[email protected]>
=cut
=head1 NAME
dbscSNV
=head1 SYNOPSIS
mv dbscSNV.pm ~/.vep/Plugins
perl variant_effect_predictor.pl -i variations.vcf --plugin dbscSNV,/path/to/dbscSNV.txt.gz
=head1 DESCRIPTION
A VEP plugin that retrieves data for splicing variants from a tabix-indexed
dbscSNV file.
Please cite the dbscSNV publication alongside the VEP if you use this resource:
http://nar.oxfordjournals.org/content/42/22/13534
The tabix utility must be installed in your path to use this plugin. The dbscSNV
data file can be downloaded from
https://sites.google.com/site/jpopgen/dbNSFP.
The file must be processed and indexed by tabix before use by this plugin:
> wget ftp://dbscsnv:[email protected]/dbscSNV.zip
> unzip dbscSNV.zip
> head -n1 dbscSNV.chr1 > h
> cat dbscSNV.chr* | grep -v ^chr | cat h - | bgzip -c > dbscSNV.txt.gz
> tabix -s 1 -b 2 -e 2 -c c dbscSNV.txt.gz
Note that in the last command we tell tabix that the header line starts with "c";
this may change to the default of "#" in future versions of dbscSNV.
Tabix also allows the data file to be hosted on a remote server. This plugin is
fully compatible with such a setup - simply use the URL of the remote file:
--plugin dbscSNV,http://my.files.com/dbscSNV.txt.gz
Note that transcript sequences referred to in dbscSNV may be out of sync with
those in the latest release of Ensembl; this may lead to discrepancies with
scores retrieved from other sources.
=cut
package dbscSNV;
use strict;
use warnings;
use Bio::EnsEMBL::Utils::Sequence qw(reverse_comp);
use Bio::EnsEMBL::Variation::Utils::BaseVepTabixPlugin;
use base qw(Bio::EnsEMBL::Variation::Utils::BaseVepTabixPlugin);
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
$self->expand_left(0);
$self->expand_right(0);
# get dbNSFP file
my $file = $self->params->[0];
$self->add_file($file);
# get headers
open HEAD, "tabix -fh $file 1:1-1 2>&1 | ";
while(<HEAD>) {
chomp;
$self->{headers} = [split];
}
close HEAD;
# check alt and Ensembl_transcriptid headers
foreach my $h(qw(alt Ensembl_gene)) {
die "ERROR: Could not find required column $h in $file\n" unless grep {$_ eq $h} @{$self->{headers}};
}
$self->{cols} = {
'ada_score' => 1,
'rf_score' => 1
};
return $self;
}
sub feature_types {
return ['Transcript'];
}
sub variation_feature_types {
return ['VariationFeature'];
}
sub get_header_info {
return {
ada_score => 'dbscSNV ADA score',
rf_score => 'dbscSNV RF score'
}
}
sub run {
my ($self, $tva) = @_;
my $vf = $tva->variation_feature;
return {} unless $vf->{start} eq $vf->{end};
# return {} unless grep {$_->SO_term =~ /splic/} @{$tva->get_all_OverlapConsequences};
# get allele, reverse comp if needed
my $allele = $tva->variation_feature_seq;
reverse_comp(\$allele) if $vf->{strand} < 0;
return {} unless $allele =~ /^[ACGT]$/;
# get gene stable ID
my $g_id = $tva->transcript->{_gene_stable_id} || $tva->transcript->gene->stable_id;
my $data;
foreach my $tmp_data(@{$self->get_data($vf->{chr}, $vf->{start} - 1, $vf->{end})}) {
# compare allele and transcript
next unless
$tmp_data->{'pos'} == $vf->{start} &&
defined($tmp_data->{alt}) &&
$tmp_data->{alt} eq $allele; # &&
# defined($tmp_data->{Ensembl_gene}) &&
# $tmp_data->{Ensembl_gene} =~ /$g_id($|;)/;
$data = $tmp_data;
last;
}
return {} unless scalar keys %$data;
# get required data
my %return =
map {$_ => $data->{$_}}
grep {$data->{$_} ne '.'} # ignore missing data
grep {defined($self->{cols}->{$_})} # only include selected cols
keys %$data;
return \%return;
}
sub parse_data {
my ($self, $line) = @_;
$line =~ s/\r$//g;
my @split = split /\t/, $line;
# parse data into hash of col names and values
my %data = map {$self->{headers}->[$_] => $split[$_]} (0..(scalar @{$self->{headers}} - 1));
return \%data;
}
sub get_start {
return $_[1]->{'pos'};
}
sub get_end {
return $_[1]->{'pos'};
}
1;