Mercurial > repos > dvanzessen > vep_emc
comparison dir_plugins/FATHMM.pm @ 0:e545d0a25ffe draft
Uploaded
| author | dvanzessen |
|---|---|
| date | Mon, 15 Jul 2019 05:17:17 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:e545d0a25ffe |
|---|---|
| 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 FATHMM | |
| 27 | |
| 28 =head1 SYNOPSIS | |
| 29 | |
| 30 mv FATHMM.pm ~/.vep/Plugins | |
| 31 ./vep -i variations.vcf --plugin FATHMM,"python /path/to/fathmm/fathmm.py" | |
| 32 | |
| 33 =head1 DESCRIPTION | |
| 34 | |
| 35 A VEP plugin that gets FATHMM scores and predictions for missense variants. | |
| 36 | |
| 37 You will need the fathmm.py script and its dependencies (Python, Python | |
| 38 MySQLdb). You should create a "config.ini" file in the same directory as the | |
| 39 fathmm.py script with the database connection options. More information about | |
| 40 how to set up FATHMM can be found on the FATHMM website at | |
| 41 https://github.com/HAShihab/fathmm. | |
| 42 | |
| 43 A typical installation could consist of: | |
| 44 | |
| 45 > wget https://raw.github.com/HAShihab/fathmm/master/cgi-bin/fathmm.py | |
| 46 > wget ftp://supfam2.cs.bris.ac.uk/FATHMM/database/fathmm.v2.1.SQL | |
| 47 > mysql -h[host] -P[port] -u[user] -p[pass] -e"CREATE DATABASE fathmm" | |
| 48 > mysql -h[host] -P[port] -u[user] -p[pass] -Dfathmm < fathmm.v2.1.SQL | |
| 49 > echo "[DATABASE]\nHOST = [host]\nPORT = [port]\nUSER = [user]\nPASSWD = [pass]\nDB = fathmm\n" > config.ini | |
| 50 | |
| 51 =cut | |
| 52 | |
| 53 package FATHMM; | |
| 54 | |
| 55 use strict; | |
| 56 use warnings; | |
| 57 | |
| 58 use Bio::EnsEMBL::Variation::Utils::BaseVepPlugin; | |
| 59 | |
| 60 use base qw(Bio::EnsEMBL::Variation::Utils::BaseVepPlugin); | |
| 61 | |
| 62 sub new { | |
| 63 my $class = shift; | |
| 64 | |
| 65 my $self = $class->SUPER::new(@_); | |
| 66 | |
| 67 # get command | |
| 68 my $command = $self->params->[0]; | |
| 69 | |
| 70 die 'ERROR: No FATHMM command specified. Specify path to FATHMM with e.g. --plugin FATHMM,"python /path/to/fathmm/fathmm.py"\n' unless defined($command); | |
| 71 | |
| 72 die 'ERROR: Your FATHMM command does not look correct; it should looks something like "python /path/to/fathmm/fathmm.py"\n' unless $command =~ /python.+fathmm\.py/; | |
| 73 | |
| 74 $self->{command} = $command; | |
| 75 | |
| 76 die 'ERROR: Temporary directory '.$self->{config}->{tmpdir}.' not found - specify an existing directory with --tmpdir [dir]\n' unless -d $self->{config}->{tmpdir}; | |
| 77 | |
| 78 return $self; | |
| 79 } | |
| 80 | |
| 81 sub version { | |
| 82 return 71; | |
| 83 } | |
| 84 | |
| 85 sub feature_types { | |
| 86 return ['Transcript']; | |
| 87 } | |
| 88 | |
| 89 sub get_header_info { | |
| 90 return { | |
| 91 FATHMM => "FATHMM prediction (score)", | |
| 92 }; | |
| 93 } | |
| 94 | |
| 95 sub run { | |
| 96 my ($self, $tva) = @_; | |
| 97 | |
| 98 # only for missense variants | |
| 99 return {} unless grep {$_->SO_term eq 'missense_variant'} @{$tva->get_all_OverlapConsequences}; | |
| 100 | |
| 101 # configure command | |
| 102 my $command = $self->{command}; | |
| 103 $command =~ m/(\s.+)\/.+/; | |
| 104 my $command_dir = $1; | |
| 105 | |
| 106 # configure tmp dir and in/out files for FATHMM | |
| 107 my $tmp_dir = $self->{config}->{tmpdir}; | |
| 108 my $tmp_in_file = $tmp_dir."/fathmm_$$\.in"; | |
| 109 my $tmp_out_file = $tmp_dir."/fatmm_$$\.out"; | |
| 110 | |
| 111 # get required input data from TVA | |
| 112 my $protein = $tva->transcript->{_protein} || $tva->transcript->translation->stable_id; | |
| 113 my $aa_change = $tva->pep_allele_string; | |
| 114 my $aa_pos = $tva->transcript_variation->translation_start; | |
| 115 $aa_change =~ s/\//$aa_pos/; | |
| 116 | |
| 117 # check we have valid strings | |
| 118 return {} unless $protein && $aa_change =~ /^[A-Z]\d+[A-Z]$/; | |
| 119 | |
| 120 # write input file | |
| 121 open IN, ">$tmp_in_file" or die "ERROR: Could not write to file $tmp_in_file\n"; | |
| 122 print IN "$protein $aa_change\n"; | |
| 123 close IN; | |
| 124 | |
| 125 # run command | |
| 126 my $fathmm_err = `cd $command_dir; $command $tmp_in_file $tmp_out_file;`; | |
| 127 | |
| 128 # read output file | |
| 129 open OUT, $tmp_out_file or die "ERROR: Could not read from file $tmp_out_file\n"; | |
| 130 | |
| 131 my ($pred, $score); | |
| 132 while(<OUT>) { | |
| 133 next if /^\#/; | |
| 134 chomp; | |
| 135 my @data = split; | |
| 136 ($pred, $score) = ($data[4], $data[5]); | |
| 137 } | |
| 138 close OUT; | |
| 139 | |
| 140 # delete temporary files | |
| 141 unlink($tmp_in_file, $tmp_out_file); | |
| 142 | |
| 143 return $pred && $score ? { | |
| 144 FATHMM => "$pred($score)", | |
| 145 } : {}; | |
| 146 } | |
| 147 | |
| 148 1; | |
| 149 |
