|
0
|
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 NearestGene
|
|
|
27
|
|
|
28 =head1 SYNOPSIS
|
|
|
29
|
|
|
30 mv NearestGene.pm ~/.vep/Plugins
|
|
|
31 ./vep -i variations.vcf --cache --plugin NearestGene
|
|
|
32
|
|
|
33 =head1 DESCRIPTION
|
|
|
34
|
|
|
35 This is a plugin for the Ensembl Variant Effect Predictor (VEP) that
|
|
|
36 finds the nearest gene(s) to a non-genic variant. More than one gene
|
|
|
37 may be reported if the genes overlap the variant or if genes are
|
|
|
38 equidistant.
|
|
|
39
|
|
|
40 Various parameters can be altered by passing them to the plugin command:
|
|
|
41
|
|
|
42 - limit : limit the number of genes returned (default: 1)
|
|
|
43 - range : initial search range in bp (default: 1000)
|
|
|
44 - max_range : maximum search range in bp (default: 10000)
|
|
|
45
|
|
|
46 Parameters are passed e.g.:
|
|
|
47
|
|
|
48 --plugin NearestGene,limit=3,max_range=50000
|
|
|
49
|
|
|
50 =cut
|
|
|
51
|
|
|
52 package NearestGene;
|
|
|
53
|
|
|
54 use strict;
|
|
|
55 use warnings;
|
|
|
56
|
|
|
57 use Bio::EnsEMBL::Variation::Utils::BaseVepPlugin;
|
|
|
58
|
|
|
59 use base qw(Bio::EnsEMBL::Variation::Utils::BaseVepPlugin);
|
|
|
60
|
|
|
61 my %CONFIG = (
|
|
|
62 limit => 1,
|
|
|
63 range => 1000,
|
|
|
64 max_range => 10000,
|
|
|
65 );
|
|
|
66
|
|
|
67 sub new {
|
|
|
68 my $class = shift;
|
|
|
69
|
|
|
70 my $self = $class->SUPER::new(@_);
|
|
|
71
|
|
|
72 my $params = $self->params;
|
|
|
73
|
|
|
74 foreach my $param(@$params) {
|
|
|
75 my ($key, $val) = split('=', $param);
|
|
|
76 die("ERROR: Failed to parse parameter $param\n") unless defined($key) && defined($val);
|
|
|
77 $CONFIG{$key} = $val;
|
|
|
78 }
|
|
|
79
|
|
|
80 return $self;
|
|
|
81 }
|
|
|
82
|
|
|
83 sub feature_types {
|
|
|
84 return ['Intergenic','MotifFeature','RegulatoryFeature'];
|
|
|
85 }
|
|
|
86
|
|
|
87 sub variant_feature_types {
|
|
|
88 return ['BaseVariationFeature'];
|
|
|
89 }
|
|
|
90
|
|
|
91 sub get_header_info {
|
|
|
92 return {
|
|
|
93 NearestGene => "Ensembl identifier of nearest gene"
|
|
|
94 };
|
|
|
95 }
|
|
|
96
|
|
|
97 sub run {
|
|
|
98 my ($self, $vfoa) = @_;
|
|
|
99
|
|
|
100 my $vf = $vfoa->base_variation_feature;
|
|
|
101 my $loc_string = sprintf("%s:%i-%i", $vf->{chr} || $vf->seq_region_name, $vf->{start}, $vf->{end});
|
|
|
102
|
|
|
103 if(!exists($self->{_cache}) || !exists($self->{_cache}->{$loc_string})) {
|
|
|
104 $self->{config}->{ga} = $self->{config}->{reg}->get_adaptor($self->{config}->{species}, $self->{config}->{core_type}, 'gene');
|
|
|
105 $self->{ga} ||= $self->{config}->{ga};
|
|
|
106 die("ERROR: Could not get gene adaptor; this plugin does not work in --offline mode\n") unless $self->{ga};
|
|
|
107
|
|
|
108 my %opts = map {'-'.$_ => $CONFIG{$_}} keys %CONFIG;
|
|
|
109 $opts{-feature} = $vf;
|
|
|
110
|
|
|
111 my @result = map {$_->[0]->stable_id} @{
|
|
|
112 $self->{ga}->fetch_all_by_outward_search(%opts)
|
|
|
113 };
|
|
|
114
|
|
|
115 $self->{_cache}->{$loc_string} = scalar @result ? join(",", @result) : undef;
|
|
|
116 }
|
|
|
117
|
|
|
118 return $self->{_cache}->{$loc_string} ? { NearestGene => $self->{_cache}->{$loc_string} } : {};
|
|
|
119 }
|
|
|
120
|
|
|
121 1;
|
|
|
122
|