annotate 2.4/install.pl @ 18:1163c16cb3c0 draft

Uploaded
author plus91-technologies-pvt-ltd
date Mon, 02 Jun 2014 07:35:53 -0400
parents e3609c8714fb
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
1 #!/usr/bin/perl
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
2
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
3 =head1 NAME
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
4 install.pl
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
5
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
6 =head1 SYNOPSIS
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
7 USAGE: install.pl --prefix=/location/of/install/dir
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
8
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
9 =head1 OPTIONS
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
10
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
11 B<--prefix, -p>
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
12 Required. Prefix location where package will be installed.
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
13
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
14 B<--perl_exec, -e>
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
15 Optional. If perl exec is other than /usr/bin/perl please specify location of perl install
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
16
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
17 B<--help,-h>
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
18
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
19
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
20 =head1 DESCRIPTION
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
21 Install package
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
22
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
23 =head1 INPUT
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
24
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
25 =head1 OUTPUT
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
26
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
27
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
28 =head1 CONTACT
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
29 bjaysheel@gmail.com
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
30
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
31
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
32 ==head1 EXAMPLE
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
33 ./install.pl --prefix=/prefix
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
34
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
35 =cut
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
36
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
37 use strict;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
38 use warnings;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
39 use Cwd;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
40 use Data::Dumper;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
41 use Pod::Usage;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
42 use Getopt::Long qw(:config no_ignore_case no_auto_abbrev pass_through);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
43
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
44 my %options = ();
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
45 my $results = GetOptions (\%options,
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
46 'prefix|p=s',
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
47 'perl_exec|e=s',
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
48 'help|h') || pod2usage();
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
49
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
50 ## display documentation
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
51 if( $options{'help'} ){
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
52 pod2usage( {-exitval => 0, -verbose => 2, -output => \*STDERR} );
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
53 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
54
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
55 #############################################################################
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
56 #### make sure everything passed was peachy
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
57 &check_parameters(\%options);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
58
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
59 #### print time now.
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
60 timestamp();
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
61
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
62 my $this = {};
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
63 my $progress = {};
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
64 my $cmd = "";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
65
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
66 #### get current working dir
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
67 $this->{source} = getcwd();
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
68
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
69 $progress = getProgress();
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
70
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
71 #### make logs dir
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
72 $cmd = "mkdir -p $options{prefix}/logs";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
73 execute_cmd($cmd);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
74
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
75 #### installling libraries required for successfull run
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
76 install_libraries();
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
77
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
78 #### unpack binary dir containing all binary to be installed
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
79 #### which are required for successfull run
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
80 print STDERR "\n\nInstalling binaries...\n";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
81
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
82 #### install each package in binary folder.
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
83 my @packages = qw(stringApprox levD);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
84
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
85 foreach my $tool (@packages) {
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
86 if ((exists $progress->{$tool}) && ($progress->{$tool})){
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
87 print STDERR "\t$tool already installed. Skipping...\n";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
88 } else {
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
89 print STDERR "\tInstalling $tool...\n";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
90
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
91 #### unpack and install each tool
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
92 eval("install_${tool}()");
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
93 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
94 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
95
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
96 #### copy source code and update paths for perl and libs
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
97 install_source();
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
98
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
99 #### completion message
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
100 print "\n\n\tSoftSearch installation complete. Use following command to initiate a test run\n";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
101 print "\n\tperl $options{prefix}/src/SoftSearch.pl -f {GENOME} -b {BAM_FILE}\n\n";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
102
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
103 #### print time now
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
104 timestamp();
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
105
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
106 #############################################################################
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
107 sub check_parameters {
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
108 my $options = shift;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
109
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
110 my @required = qw(prefix);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
111
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
112 foreach my $key (@required) {
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
113 unless ($options{$key}) {
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
114 print STDERR "ARG: $key is required\n";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
115 pod2usage({-exitval => 2, -message => "error message", -verbose => 1, -output => \*STDERR});
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
116 exit(-1);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
117 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
118 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
119
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
120 $options{'perl_exec'} = "/usr/bin/perl" unless($options{'perl_exec'});
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
121 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
122
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
123 #############################################################################
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
124 sub getProgress {
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
125 my $hash = {};
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
126 my @sofar;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
127
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
128 #### if file exists get progress so far.
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
129 if (-s "$options{prefix}/progress.txt") {
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
130 open(FHD, "<", "$options{prefix}/progress.txt") or die "Could not open file to read $options{prefix}/progress.txt";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
131 while(<FHD>){
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
132 chomp $_;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
133 push @sofar, $_;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
134 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
135 close(FHD);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
136
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
137 map { $hash->{$1} = $2 if( /([^=]+)\s*=\s*([^=]+)/ ) } @sofar;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
138 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
139
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
140 #### return hash
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
141 return $hash;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
142 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
143
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
144 #############################################################################
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
145 sub setProgress {
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
146 my $hash = shift;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
147
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
148 open(OUT, ">", "$options{prefix}/progress.txt") or die "Could not open file to write $options{prefix}/progress.txt";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
149
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
150 foreach my $key (keys %{$hash}){
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
151 print OUT $key."=".$hash->{$key}."\n";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
152 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
153
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
154 close(OUT);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
155 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
156
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
157 #############################################################################
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
158 sub install_libraries {
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
159 if ((exists $progress->{libraries}) && ($progress->{libraries})){
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
160 print STDERR "\tLibraries already installed. Skipping...\n";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
161 return;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
162 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
163
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
164 print STDERR "\n\nInstalling libraries...\n\n";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
165 chdir($this->{source});
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
166
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
167 $cmd = "cp -r $this->{source}/library $options{prefix}/lib";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
168 execute_cmd($cmd);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
169
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
170 $progress->{libraries} = 1;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
171 setProgress($progress);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
172 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
173
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
174 #############################################################################
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
175 sub install_stringApprox {
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
176 #### check and install dir
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
177 my $dir = "$options{prefix}/lib";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
178 my $cmd = "";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
179
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
180 $cmd = "mkdir -p $dir";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
181 execute_cmd($cmd);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
182
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
183 $cmd = "tar -zxvf $this->{source}/binary/String-Approx-3.27.tar.gz -C $this->{source}/binary";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
184 execute_cmd($cmd);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
185
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
186 chdir("$this->{source}/binary/String-Approx-3.27");
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
187 $cmd = "perl Makefile.PL INSTALL_BASE=$options{prefix}";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
188 $cmd .= " 1>$options{prefix}/logs/StringApprox.out";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
189 $cmd .= " 2>$options{prefix}/logs/StringApprox.err";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
190 execute_cmd($cmd);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
191
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
192 $cmd = "make && make install";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
193 $cmd .= " 1>>$options{prefix}/logs/StringApprox.out";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
194 $cmd .= " 2>>$options{prefix}/logs/StringApprox.err";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
195 execute_cmd($cmd);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
196
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
197 $cmd = "make install";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
198 $cmd .= " 1>>$options{prefix}/logs/StringApprox.out";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
199 $cmd .= " 2>>$options{prefix}/logs/StringApprox.err";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
200 execute_cmd($cmd);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
201
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
202
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
203 chdir("$this->{source}/binary");
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
204 $cmd = "rm -rf $this->{source}/binary/String-Approx-3.27";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
205 execute_cmd($cmd);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
206
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
207 $progress->{stringApprox} = 1;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
208 setProgress($progress);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
209 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
210
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
211 #############################################################################
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
212 sub install_levD {
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
213 #### check and install dir
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
214 my $dir = "$options{prefix}/lib";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
215 my $cmd = "";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
216
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
217 $cmd = "mkdir -p $dir";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
218 execute_cmd($cmd);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
219
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
220 $cmd = "tar -zxvf $this->{source}/binary/Text-LevenshteinXS-0.03.tar.gz -C $this->{source}/binary";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
221 execute_cmd($cmd);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
222
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
223 chdir("$this->{source}/binary/Text-LevenshteinXS-0.03");
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
224 $cmd = "perl Makefile.PL INSTALL_BASE=$options{prefix}";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
225 $cmd .= " 1>$options{prefix}/logs/levD.out";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
226 $cmd .= " 2>$options{prefix}/logs/levD.err";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
227 execute_cmd($cmd);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
228
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
229 $cmd = "make";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
230 $cmd .= " 1>>$options{prefix}/logs/levD.out";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
231 $cmd .= " 2>>$options{prefix}/logs/levD.err";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
232 execute_cmd($cmd);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
233
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
234 $cmd .= "make install";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
235 $cmd .= " 1>>$options{prefix}/logs/levD.out";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
236 $cmd .= " 2>>$options{prefix}/logs/levD.err";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
237 execute_cmd($cmd);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
238
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
239 chdir("$this->{source}/binary");
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
240 $cmd = "rm -rf $this->{source}/binary/Text-LevenshteinXS-0.03";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
241 execute_cmd($cmd);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
242
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
243 $progress->{levD} = 1;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
244 setProgress($progress);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
245 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
246
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
247 #############################################################################
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
248 sub install_source {
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
249 if ((exists $progress->{source}) && ($progress->{source})){
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
250 print STDERR "\tSource already installed. Skipping...\n";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
251 return;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
252 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
253
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
254 print STDERR "\n\nInstalling source...\n\n";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
255
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
256 #### create dir to store source code
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
257 $cmd = "mkdir -p $options{prefix}/src";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
258 execute_cmd($cmd);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
259
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
260 $cmd = "cp -r $this->{source}/script/* $options{prefix}/src/.";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
261 execute_cmd($cmd);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
262
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
263 #### make sure all scripts are executable
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
264 $cmd = "chmod -R +x $options{prefix}/src";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
265 execute_cmd($cmd);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
266
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
267 #### replace /usr/local/biotools/perl/5.10.0/bin/perl with perl_exec
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
268 $options{perl_exec} =~ s/\//\\\//g;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
269 $cmd = "find $options{prefix}/src -name \"*.pl\" -print";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
270 $cmd .= " -exec sed -i 's/#!\\/usr\\/local\\/biotools\\/perl\\/5.10.0\\/bin\\/perl/#!$options{perl_exec}/' {} \\;";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
271 execute_cmd($cmd);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
272
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
273 #### check if perl exec location is other than /usr/bin/perl
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
274 if ($options{perl_exec} !~ /^\/usr\/bin\/perl$/) {
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
275 $cmd = "find $options{prefix}/src -name \"*.pl\" -print";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
276 $cmd .= " -exec sed -i 's/#!\\/usr\\/bin\\/perl/#!$options{perl_exec}/' {} \\;";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
277 execute_cmd($cmd);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
278 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
279
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
280 #### replace library references to local install
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
281 my $lib = "$options{prefix}/lib";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
282 $lib =~ s/\//\\\//g;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
283
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
284 $cmd = "find $options{prefix}/src -name \"*.pl\" -print";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
285 $cmd .= " -exec sed -i 's/\\/data2\\/bsi\\/reference\\/softsearch\\/lib/$lib/' {} \\;";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
286 execute_cmd($cmd);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
287
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
288 $cmd = "find $options{prefix}/lib -name \"LevD.pm\" -print";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
289 $cmd .= " -exec sed -i 's/\\/data2\\/bsi\\/reference\\/softsearch\\/lib/$lib/' {} \\;";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
290 execute_cmd($cmd);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
291
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
292 $progress->{source} = 1;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
293 setProgress($progress);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
294 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
295
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
296 #############################################################################
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
297 sub execute_cmd {
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
298 my $cmd = shift;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
299
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
300 system($cmd);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
301
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
302 #while (( $? >> 8 ) != 0 ){
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
303 # print STDERR "ERROR: Following command failed to execute. Exiting execution of workflow\n$cmd\n";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
304 # exit(-1);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
305 #}
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
306 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
307
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
308 #############################################################################
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
309 sub timestamp {
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
310 my @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
311 my @weekDays = qw(Sun Mon Tue Wed Thu Fri Sat Sun);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
312 my ($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime();
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
313 my $year = 1900 + $yearOffset;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
314 my $theTime = "$hour:$minute:$second, $weekDays[$dayOfWeek] $months[$month] $dayOfMonth, $year";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
315 print "Time now: " . $theTime."\n";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
316 }