annotate ensemb_rep_gvl-2bc9b66ada89/variant_effect_predictor/INSTALL.pl @ 0:9c00df4b30f5 draft default tip

Uploaded
author alonie
date Thu, 06 Jun 2013 00:49:58 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
1 #!/usr/bin/perl
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
2
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
3 use Getopt::Long;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
4 use LWP::Simple qw($ua getstore get);
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
5 use File::Listing qw(parse_dir);
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
6
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
7 $| = 1;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
8 our $VERSION = 2.6;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
9
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
10 # CONFIGURE
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
11 ###########
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
12
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
13 my ($DEST_DIR, $ENS_CVS_ROOT, $API_VERSION, $BIOPERL_URL, $CACHE_URL, $help);
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
14
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
15 GetOptions(
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
16 'DESTDIR|d=s' => \$DEST_DIR,
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
17 'VERSION|v=i' => \$API_VERSION,
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
18 'BIOPERL|b=s' => \$BIOPERL_URL,
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
19 'CACHEURL|u=s' => \$CACHE_URL,
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
20 'CACHEDIR|c=s' => \$CACHE_DIR,
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
21 'HELP|h' => \$help
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
22 );
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
23
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
24 if(defined($help)) {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
25 usage();
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
26 exit(0);
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
27 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
28
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
29 my $default_dir_used;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
30
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
31 # check if $DEST_DIR is default
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
32 if(defined($DEST_DIR)) {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
33 print "Using non-default installation directory $DEST_DIR - you will probably need to add $DEST_DIR to your PERL5LIB\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
34 $default_dir_used = 0;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
35 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
36 else {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
37 $DEST_DIR ||= '.';
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
38 $default_dir_used = 1;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
39 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
40
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
41 my $lib_dir = $DEST_DIR;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
42
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
43 $DEST_DIR .= '/Bio';
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
44 $ENS_CVS_ROOT ||= 'http://cvs.sanger.ac.uk/cgi-bin/viewvc.cgi/';
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
45 $BIOPERL_URL ||= 'http://bioperl.org/DIST/old_releases/bioperl-1.2.3.tar.gz';
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
46 $API_VERSION ||= 68;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
47 $CACHE_URL ||= "ftp://ftp.ensembl.org/pub/release-$API_VERSION/variation/VEP";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
48 $CACHE_DIR ||= $ENV{HOME}.'/.vep';
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
49
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
50 our $prev_progress = 0;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
51
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
52 print "\nHello! This installer is configured to install v$API_VERSION of the Ensembl API for use by the VEP.\nIt will not affect any existing installations of the Ensembl API that you may have.\n\nIt will also download and install cache files from Ensembl's FTP server.\n\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
53
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
54
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
55 # CHECK EXISTING
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
56 ################
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
57
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
58 print "Checking for installed versions of the Ensembl API...";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
59
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
60 # test if the user has the API installed
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
61 my $has_api = {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
62 'ensembl' => 0,
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
63 'ensembl-variation' => 0,
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
64 'ensembl-functgenomics' => 0,
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
65 };
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
66
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
67 eval q{
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
68 use Bio::EnsEMBL::Registry;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
69 };
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
70
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
71 my $installed_version;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
72
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
73 unless($@) {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
74 $has_api->{ensembl} = 1;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
75
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
76 $installed_version = Bio::EnsEMBL::Registry->software_version;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
77 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
78
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
79 eval q{
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
80 use Bio::EnsEMBL::Variation::Utils::VEP;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
81 };
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
82
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
83 $has_api->{'ensembl-variation'} = 1 unless $@;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
84
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
85 eval q{
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
86 use Bio::EnsEMBL::Funcgen::RegulatoryFeature;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
87 };
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
88
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
89 $has_api->{'ensembl-functgenomics'} = 1 unless $@;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
90
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
91
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
92 print "done\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
93
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
94 my $total = 0;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
95 $total += $_ for values %$has_api;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
96
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
97 my $message;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
98
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
99 if($total == 3) {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
100
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
101 if(defined($installed_version)) {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
102 if($installed_version == $API_VERSION) {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
103 $message = "It looks like you already have v$API_VERSION of the API installed.\nYou shouldn't need to install the API";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
104 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
105
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
106 elsif($installed_version > $API_VERSION) {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
107 $message = "It looks like this installer is for an older distribution of the API than you already have";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
108 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
109
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
110 else {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
111 $message = "It looks like you have an older version (v$installed_version) of the API installed.\nThis installer will install a limited set of the API v$API_VERSION for use by the VEP only";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
112 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
113 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
114
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
115 else {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
116 $message = "It looks like you have an unidentified version of the API installed.\nThis installer will install a limited set of the API v$API_VERSION for use by the VEP only"
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
117 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
118 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
119
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
120 elsif($total > 0) {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
121 $message = "It looks like you already have the following API modules installed:\n\n".(join "\n", grep {$has_api->{$_}} keys %$has_api)."\n\nThe VEP requires the ensembl, ensembl-variation and optionally ensembl-functgenomics modules";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
122 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
123
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
124 if(defined($message)) {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
125 print "$message\n\nAre you sure you want to continue installing the API (y/n)? ";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
126
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
127 my $ok = <>;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
128
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
129 if($ok !~ /^y/i) {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
130 print " - skipping API installation\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
131 goto CACHE;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
132 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
133 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
134
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
135
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
136
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
137 # SETUP
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
138 #######
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
139
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
140 print "\nSetting up directories\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
141
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
142 # check if install dir exists
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
143 if(-e $DEST_DIR) {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
144 print "Destination directory $DEST_DIR already exists.\nDo you want to overwrite it (if updating VEP this is probably OK) (y/n)? ";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
145
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
146 my $ok = <>;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
147
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
148 if($ok !~ /^y/i) {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
149 print "Exiting\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
150 exit(0);
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
151 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
152
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
153 else {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
154 unless($default_dir_used) {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
155 print "WARNING: You are using a non-default install directory.\nPressing \"y\" again will remove $DEST_DIR and its contents!!!\nAre you really, really sure (y/n)? ";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
156 $ok = <>;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
157
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
158 if($ok !~ /^y/i) {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
159 print "Exiting\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
160 exit(0);
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
161 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
162 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
163
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
164 # try to delete the existing dir
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
165 `rm -rf $DEST_DIR`;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
166 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
167 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
168
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
169 mkdir($DEST_DIR) or die "ERROR: Could not make directory $DEST_DIR\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
170 mkdir($DEST_DIR.'/tmp') or die "ERROR: Could not make directory $DEST_DIR/tmp\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
171
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
172 # set up a user agent's proxy
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
173 $ua->env_proxy;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
174
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
175 # enable progress
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
176 eval q{
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
177 $ua->show_progress(1);
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
178 };
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
179
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
180
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
181
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
182 # API
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
183 #####
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
184
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
185 print "\nDownloading required files\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
186
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
187 # set up the URLs
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
188 my $ensembl_url_tail = '.tar.gz?root=ensembl&view=tar&only_with_tag=branch-ensembl-';
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
189
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
190 foreach my $module(qw(ensembl ensembl-variation ensembl-functgenomics)) {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
191 my $url = $ENS_CVS_ROOT.$module.$ensembl_url_tail.$API_VERSION;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
192
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
193 print " - fetching $module\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
194
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
195 my $target_file = $DEST_DIR.'/tmp/'.$module.'.tar.gz';
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
196
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
197 unless(getstore($url, $target_file) == 200) {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
198 die "ERROR: Failed to fetch $module from $url - perhaps you have a proxy/firewall? Set the http_proxy ENV variable if you do\nError code: $response\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
199 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
200
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
201 print " - unpacking $target_file\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
202 unpack_tar("$DEST_DIR/tmp/$module.tar.gz", "$DEST_DIR/tmp/");
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
203
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
204 print " - moving files\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
205
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
206 if($module eq 'ensembl') {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
207 `mv -f $DEST_DIR/tmp/$module/modules/Bio/EnsEMBL $DEST_DIR/`;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
208 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
209 elsif($module eq 'ensembl-variation') {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
210 `mv -f $DEST_DIR/tmp/$module/modules/Bio/EnsEMBL/Variation $DEST_DIR/EnsEMBL/`;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
211 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
212 elsif($module eq 'ensembl-functgenomics') {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
213 `mv -f $DEST_DIR/tmp/$module/modules/Bio/EnsEMBL/Funcgen $DEST_DIR/EnsEMBL/`;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
214 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
215
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
216 `rm -rf $DEST_DIR/tmp/$module`;# or die "ERROR: Failed to remove directory $DEST_DIR/$module\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
217 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
218
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
219
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
220
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
221 # BIOPERL
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
222 #########
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
223
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
224 # now get BioPerl
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
225 print " - fetching BioPerl\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
226
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
227 $bioperl_file = (split /\//, $BIOPERL_URL)[-1];
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
228
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
229 my $target_file = $DEST_DIR.'/tmp/'.$bioperl_file;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
230
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
231 unless(getstore($BIOPERL_URL, $target_file) == 200) {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
232 die "ERROR: Failed to fetch BioPerl from $BIOPERL_URL - perhaps you have a proxy/firewall?\nError code: $response\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
233 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
234
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
235 print " - unpacking $target_file\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
236 unpack_tar("$DEST_DIR/tmp/$bioperl_file", "$DEST_DIR/tmp/");
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
237
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
238 print " - moving files\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
239
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
240 $bioperl_file =~ /(bioperl.+?)\.tar\.gz/;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
241 my $bioperl_dir = $1;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
242 `mv -f $DEST_DIR/tmp/$bioperl_dir/Bio/* $DEST_DIR/`;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
243 `rm -rf $DEST_DIR/tmp/$bioperl_dir`;# or die "ERROR: Failed to remove directory $DEST_DIR/$bioperl_dir\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
244 `rm -rf $DEST_DIR/tmp`;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
245
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
246
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
247
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
248 # TEST
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
249 ######
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
250
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
251 print "\nTesting VEP script\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
252
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
253 my $test_vep = `perl variant_effect_predictor.pl --help 2>&1`;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
254
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
255 $test_vep =~ /ENSEMBL VARIANT EFFECT PREDICTOR/ or die "ERROR: Testing VEP script failed with the following error\n$test_vep\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
256
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
257 print " - OK!\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
258
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
259
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
260
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
261 # CACHE FILES
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
262 #############
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
263
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
264 CACHE:
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
265
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
266 print "\nThe VEP can either connect to remote or local databases, or use local cache files.\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
267 print "Cache files will be stored in $CACHE_DIR\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
268 print "Do you want to install any cache files (y/n)? ";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
269
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
270 my $ok = <>;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
271
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
272 if($ok !~ /^y/i) {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
273 print "Exiting\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
274 exit(0);
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
275 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
276
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
277 # check cache dir exists
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
278 if(!(-e $CACHE_DIR)) {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
279 print "Cache directory $CACHE_DIR does not exists - do you want to create it (y/n)? ";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
280
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
281 my $ok = <>;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
282
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
283 if($ok !~ /^y/i) {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
284 print "Exiting\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
285 exit(0);
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
286 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
287
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
288 mkdir($CACHE_DIR) or die "ERROR: Could not create directory $CACHE_DIR\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
289 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
290
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
291 mkdir($CACHE_DIR.'/tmp') unless -e $CACHE_DIR.'/tmp';
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
292
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
293 # get list of species
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
294 print "\nDownloading list of available cache files\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
295
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
296 my $num = 1;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
297 my $species_list;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
298 my @files;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
299 push @files, map {$_->[0]} grep {$_->[0] =~ /tar.gz/} @{parse_dir(get($CACHE_URL))};
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
300
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
301 # if we don't have a species list, we'll have to guess
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
302 if(!scalar(@files)) {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
303 print "Could not get current species list - using predefined list instead\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
304
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
305 @files = (
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
306 "bos_taurus_vep_$API_VERSION.tar.gz",
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
307 "danio_rerio_vep_$API_VERSION.tar.gz",
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
308 "homo_sapiens_vep_$API_VERSION.tar.gz",
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
309 "homo_sapiens_vep_$API_VERSION\_sift_polyphen.tar.gz",
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
310 "mus_musculus_vep_$API_VERSION.tar.gz",
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
311 "rattus_norvegicus_vep_$API_VERSION.tar.gz",
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
312 );
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
313 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
314
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
315 foreach my $file(@files) {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
316 $species_list .= $num++." : ".$file."\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
317 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
318
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
319 print "The following species/files are available; which do you want (can specify multiple separated by spaces): \n$species_list\n? ";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
320
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
321 foreach my $file(split /\s+/, <>) {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
322 my $file_path = $files[$file - 1];
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
323
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
324 my ($species, $file_name);
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
325
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
326 if($file_path =~ /\//) {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
327 ($species, $file_name) = (split /\//, $file_path);
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
328 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
329 else {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
330 $file_name = $file_path;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
331 $file_name =~ m/^(\w+?\_\w+?)\_vep/;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
332 $species = $1;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
333 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
334
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
335 # check if user already has this species and version
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
336 if(-e "$CACHE_DIR/$species/$API_VERSION") {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
337 print "\nWARNING: It looks like you already have the cache for $species (v$API_VERSION) installed.\nIf you continue the existing cache will be overwritten.\nAre you sure you want to continue (y/n)? ";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
338
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
339 my $ok = <>;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
340
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
341 if($ok !~ /^y/i) {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
342 print " - skipping $species\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
343 next;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
344 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
345
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
346 `rm -rf $CACHE_DIR/$species/$API_VERSION`;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
347 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
348
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
349 my $target_file = "$CACHE_DIR/tmp/$file_name";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
350
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
351 print " - downloading $CACHE_URL/$file_path\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
352
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
353 unless(getstore("$CACHE_URL/$file_path", $target_file) == 200) {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
354 die "ERROR: Failed to fetch cache file $file_name from $CACHE_URL/$file_path - perhaps you have a proxy/firewall? Set the http_proxy ENV variable if you do\nError code: $response\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
355 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
356
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
357 print " - unpacking $file_name\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
358
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
359 unpack_tar($target_file, $CACHE_DIR.'/tmp/');
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
360
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
361 # does species dir exist?
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
362 if(!-e "$CACHE_DIR/$species") {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
363 mkdir("$CACHE_DIR/$species") or die "ERROR: Could not create directory $CACHE_DIR/$species\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
364 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
365
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
366 # move files
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
367 `mv -f $CACHE_DIR/tmp/$species/$API_VERSION $CACHE_DIR/$species/`;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
368 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
369
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
370 # cleanup
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
371 `rm -rf $CACHE_DIR/tmp`;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
372
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
373 print "\nSuccess\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
374
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
375
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
376 # SUBS
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
377 ######
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
378
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
379 # unpack a tarball with progress
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
380 sub unpack_tar {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
381 my ($file, $dir) = @_;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
382
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
383 my $count = 0;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
384
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
385 open COUNT, "tar -tzvf $file 2>&1 |";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
386 $count++ while(<COUNT>);
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
387 close COUNT;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
388
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
389 my $i = 0;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
390 open EXTRACT, "tar -C $dir -xzvf $file 2>&1 |";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
391 progress($i++, $count) while(<EXTRACT>);
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
392 close EXTRACT;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
393
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
394 progress(1,1);
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
395 $prev_progress = 0;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
396 print "\n";
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
397
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
398 `rm -rf $file`;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
399 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
400
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
401 # update or initiate progress bar
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
402 sub progress {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
403 my ($i, $total) = @_;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
404
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
405 my $width = 60;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
406 my $percent = int(($i/$total) * 100);
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
407 my $numblobs = (($i/$total) * $width) - 2;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
408
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
409 return unless $numblobs != $prev_progress;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
410 $prev_progress = $numblobs;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
411
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
412 printf("\r% -${width}s% 1s% 10s", '['.('=' x $numblobs).($numblobs == $width - 2 ? '=' : '>'), ']', "[ " . $percent . "% ]");
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
413 }
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
414
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
415 sub usage {
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
416 my $usage =<<END;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
417 #---------------#
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
418 # VEP INSTALLER #
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
419 #---------------#
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
420
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
421 version $VERSION
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
422
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
423 By Will McLaren (wm2\@ebi.ac.uk)
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
424
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
425 http://www.ensembl.org/info/docs/variation/vep/vep_script.html#installer
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
426
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
427 Usage:
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
428 perl INSTALL.pl [arguments]
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
429
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
430 Options
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
431 =======
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
432
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
433 -h | --help Display this message and quit
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
434 -d | --DESTDIR Set destination directory for API install (default = './')
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
435 -v | --VERSION Set API version to install (default = 66)
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
436 -c | --CACHEDIR Set destination directory for cache files (default = '$HOME/.vep/')
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
437 END
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
438
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
439 print $usage;
9c00df4b30f5 Uploaded
alonie
parents:
diff changeset
440 }