comparison dir_plugins/LOVD.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 LOVD
27
28 =head1 SYNOPSIS
29
30 mv LOVD.pm ~/.vep/Plugins
31 ./vep -i variations.vcf --plugin LOVD
32
33 =head1 DESCRIPTION
34
35 A VEP plugin that retrieves LOVD variation data from http://www.lovd.nl/.
36
37 Please be aware that LOVD is a public resource of curated variants, therefore
38 please respect this resource and avoid intensive querying of their databases
39 using this plugin, as it will impact the availability of this resource for
40 others.
41
42 =cut
43
44 package LOVD;
45
46 use strict;
47 use warnings;
48 use LWP::UserAgent;
49
50 use Bio::EnsEMBL::Variation::Utils::BaseVepPlugin;
51
52 use base qw(Bio::EnsEMBL::Variation::Utils::BaseVepPlugin);
53
54 sub version {
55 return '2.5';
56 }
57
58 sub feature_types {
59 return ['Transcript'];
60 }
61
62 sub get_header_info {
63 return {
64 LOVD => "LOVD variant ID",
65 };
66 }
67
68 sub run {
69 my ($self, $tva) = @_;
70
71 $self->{has_cache} = 1;
72
73 my %hg_assembly = ( 'grch37' => 'hg19', 'grch38' => 'hg38' );
74 my $assembly = lc($self->{config}->{assembly});
75
76 # only works on human
77 die("ERROR: LOVD plugin works only on human data") unless $self->{config}->{species} =~ /human|homo/i;
78
79 # only work on 2 human assemblies
80 die("ERROR: LOVD plugin works only on human assemblies ".join(' and ', keys(%hg_assembly))) unless $hg_assembly{$assembly};
81
82 # get the VF object
83 my $vf = $tva->variation_feature;
84 return {} unless defined $vf;
85
86 # set up a LWP UserAgent
87 my $ua = LWP::UserAgent->new;
88 $ua->env_proxy;
89
90 my $chr = $vf->{chr};
91 $chr =~ s/^chr//;
92
93 my $locus = sprintf('chr%s:%s_%s', $chr, $vf->{start}, $vf->{end});
94
95 my $data;
96
97 # check the cache
98 if(!exists($self->{lovd_cache}->{$locus})) {
99
100 # construct a LOVD URL
101 my $url = sprintf('http://www.lovd.nl/search.php?build=%s&position=%s', $hg_assembly{$assembly}, $locus);
102
103 # get the accession (only need the head to get the redirect URL that contains the accession)
104 my $response = $ua->get($url);
105
106 if($response->is_success) {
107
108 # parse the data into a hash
109 for(grep {$_ !~ /hg_build/} split /\cJ/, $response->decoded_content) {
110 s/\"//g;
111
112 my ($build, $pos, $gene, $acc, $dna, $url) = split /\t/;
113
114 $data = join(',', $gene, $acc, $dna)
115 }
116
117 $self->{lovd_cache}->{$locus} = $data;
118 }
119 }
120 else {
121 $data = $self->{lovd_cache}->{$locus};
122 }
123
124 return $data ? { LOVD => $data } : {};
125 }
126
127 1;
128