/
configure.pl
333 lines (276 loc) · 8.42 KB
/
configure.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
#!/usr/bin/perl -w
use FileHandle; # use FileHandles instead of open(),close()
use Cwd;
use Cwd 'abs_path';
######################## !!! Don't Change the code below##############
$install_dir = getcwd;
$install_dir=abs_path($install_dir);
if(!-d $install_dir)
{
die "The SAXSDom directory ($install_dir) is not existing, please revise the customize settings part inside the configure.pl, set the path as your unzipped SAXSDom directory\n";
}
$SAXSDom_db_tools_dir = "$install_dir/db_tools";
if(!-d $SAXSDom_db_tools_dir)
{
die "The SAXSDom databases/tools folder ($SAXSDom_db_tools_dir) is not existing\n";
}
if ( substr($install_dir, length($install_dir) - 1, 1) ne "/" )
{
$install_dir .= "/";
}
if ( substr($SAXSDom_db_tools_dir, length($SAXSDom_db_tools_dir) - 1, 1) ne "/" )
{
$SAXSDom_db_tools_dir .= "/";
}
##### check gcc version
$check_gcc = system("gcc -dumpversion");
if($check_gcc)
{
print "Failed to find gcc in system, please check gcc version";
exit;
}
$gcc_v = `gcc -dumpversion`;
chomp $gcc_v;
@gcc_version = split(/\./,$gcc_v);
if($gcc_version[0] != 4)
{
print "!!!! Warning: gcc 4.X.X is recommended for boost installation, currently is $gcc_v\n\n";
sleep(2);
}
print "checking whether the configuration file run in the installation folder ...";
$cur_dir = `pwd`;
chomp $cur_dir;
$configure_file = "$cur_dir/configure.pl";
if (! -f $configure_file || $install_dir ne "$cur_dir/")
{
die "\nPlease check the installation directory setting and run the configure program under the main directory of SAXSDom.\n";
}
print " OK!\n";
if (! -d $install_dir)
{
die "can't find installation directory.\n";
}
if ( substr($install_dir, length($install_dir) - 1, 1) ne "/" )
{
$install_dir .= "/";
}
######### check the SAXSDom database and tools
$tools_dir = "$SAXSDom_db_tools_dir/tools";
if(!(-d $tools_dir))
{
die "Failed to find tools under $SAXSDom_db_tools_dir/\n";
}
if($SAXSDom_db_tools_dir eq "$cur_dir/")
{
die "Same directory as SAXSDom main folder. Differnt path for original databases/tools folder $SAXSDom_db_tools_dir is recommended.\n";
}
#create link for databases and tools
if(-d "${install_dir}tools")
{
`rm ${install_dir}tools`;
}
`ln -s $tools_dir ${install_dir}tools`;
=pod
if (prompt_yn("SAXSDom will be installed into <$install_dir> ")){
}else{
die "The installation is cancelled!\n";
}
print "Start install SAXSDom into <$install_dir>\n";
=cut
print "######### (1) Configuring option files\n";
$option_list = "$install_dir/installation/configure_list";
if (! -f $option_list)
{
die "\nOption file $option_list not exists.\n";
}
configure_file2($option_list,'bin');
configure_file2($option_list,'installation');
configure_file2($option_list,'scripts');
configure_file2($option_list,'examples');
print "######### Configuring option files, done\n\n\n";
### compress benchmark dataset
$benchmark_dir = "$install_dir/installation";
chdir($benchmark_dir);
if(-e "Mocapy++-1.07.tar.gz")
{
`tar -zxf Mocapy++-1.07.tar.gz`;
`cp -ar Mocapy_src/* Mocapy++-1.07/`;
`cp -ar $install_dir/src/SAXSDom.cpp Mocapy++-1.07/examples`;
if($gcc_version[0] ==4 and $gcc_version[1]<6) #gcc 4.6
{
#### install Mocapy using boost 1.38
open(OUT,">$install_dir/compile_SAXSDom.sh") || die "Failed to open file $install_dir/compile_SAXSDom\n";
print OUT "#!/bin/bash -e\n\n";
print OUT "echo \" Start compile SAXSDom (will take ~10 min)\"\n\n";
print OUT "cd $install_dir/installation/Mocapy++-1.07\n\n";
print OUT "export LD_LIBRARY_PATH=$install_dir/tools/boost_1_38_0/lib:\$LD_LIBRARY_PATH\n\n";
print OUT "$install_dir/tools/cmake-2.8.12.2/bin/cmake -DBOOST_ROOT='$install_dir/tools/boost_1_38_0/' -DLAPACK_LIBRARY:FILEPATH='$install_dir/tools/lapack-3.4.1/liblapack.a' .\n\n";
print OUT "make\n\n";
print OUT "cp $install_dir/installation/Mocapy++-1.07/examples/SAXSDom $install_dir/bin\n\n";
close OUT;
}else{
#### install Mocapy using boost 1.55
open(OUT,">$install_dir/compile_SAXSDom.sh") || die "Failed to open file $install_dir/compile_SAXSDom\n";
print OUT "#!/bin/bash -e\n\n";
print OUT "echo \" Start compile SAXSDom (will take ~10 min)\"\n\n";
print OUT "cd $install_dir/installation/Mocapy++-1.07\n\n";
print OUT "export LD_LIBRARY_PATH=$install_dir/tools/boost_1_55_0/lib:\$LD_LIBRARY_PATH\n\n";
print OUT "$install_dir/tools/cmake-2.8.12.2/bin/cmake -DBOOST_ROOT='$install_dir/tools/boost_1_55_0/' -DLAPACK_LIBRARY:FILEPATH='$install_dir/tools/lapack-3.4.1/liblapack.a' .\n\n";
print OUT "make\n\n";
print OUT "cp $install_dir/installation/Mocapy++-1.07/examples/SAXSDom $install_dir/bin\n\n";
close OUT;
}
}else{
die "Failed to find Mocapy++-1.07.tar.gz, contact us\n";
}
chdir($install_dir);
=pod
print "Updating benchmark dataset in $benchmark_dir\n\n";
if(-e "benchmark.tar.gz")
{
`rm benchmark.tar.gz`;
}
`wget http://sysbio.rnet.missouri.edu/bdm_download/test/benchmark.tar.gz`;
`tar -zxf benchmark.tar.gz`;
`rm benchmark.tar.gz`;
if(! -d "benchmark")
{
die "Failed to download benchmark.tar.gz from http://sysbio.rnet.missouri.edu/bdm_download/test/benchmark.tar.gz, please contact chengji\@missouri.edu\n";
}
=cut
system("mv $install_dir/installation/SAXSDom_test_files/T*run*.sh $install_dir/examples");
system("chmod +x $install_dir/examples/*.sh");
sub prompt_yn {
my ($query) = @_;
my $answer = prompt("$query (Y/N): ");
return lc($answer) eq 'y';
}
sub prompt {
my ($query) = @_; # take a prompt string as argument
local $| = 1; # activate autoflush to immediately show the prompt
print $query;
chomp(my $answer = <STDIN>);
return $answer;
}
sub configure_file{
my ($option_list,$prefix) = @_;
open(IN,$option_list) || die "Failed to open file $option_list\n";
$file_indx=0;
while(<IN>)
{
$file = $_;
chomp $file;
if ($file =~ /^$prefix/)
{
$option_default = $install_dir.$file.'.default';
$option_new = $install_dir.$file;
$file_indx++;
print "$file_indx: Configuring $option_new\n";
if (! -f $option_default)
{
die "\nOption file $option_default not exists.\n";
}
open(IN1,$option_default) || die "Failed to open file $option_default\n";
open(OUT1,">$option_new") || die "Failed to open file $option_new\n";
while(<IN1>)
{
$line = $_;
chomp $line;
if(index($line,'SOFTWARE_PATH')>=0)
{
$line =~ s/SOFTWARE_PATH/$install_dir/g;
$line =~ s/\/\//\//g;
print OUT1 $line."\n";
}else{
print OUT1 $line."\n";
}
}
close IN1;
close OUT1;
}
}
close IN;
}
sub configure_tools{
my ($option_list,$prefix,$DBtool_path) = @_;
open(IN,$option_list) || die "Failed to open file $option_list\n";
$file_indx=0;
while(<IN>)
{
$file = $_;
chomp $file;
if ($file =~ /^$prefix/)
{
$option_default = $DBtool_path.$file.'.default';
$option_new = $DBtool_path.$file;
$file_indx++;
print "$file_indx: Configuring $option_new\n";
if (! -f $option_default)
{
next;
#die "\nOption file $option_default not exists.\n";
}
open(IN1,$option_default) || die "Failed to open file $option_default\n";
open(OUT1,">$option_new") || die "Failed to open file $option_new\n";
while(<IN1>)
{
$line = $_;
chomp $line;
if(index($line,'SOFTWARE_PATH')>=0)
{
$line =~ s/SOFTWARE_PATH/$DBtool_path/g;
$line =~ s/\/\//\//g;
print OUT1 $line."\n";
}else{
print OUT1 $line."\n";
}
}
close IN1;
close OUT1;
}
}
close IN;
}
sub configure_file2{
my ($option_list,$prefix) = @_;
open(IN,$option_list) || die "Failed to open file $option_list\n";
$file_indx=0;
while(<IN>)
{
$file = $_;
chomp $file;
if ($file =~ /^$prefix/)
{
@tmparr = split('/',$file);
$filename = pop @tmparr;
chomp $filename;
$filepath = join('/',@tmparr);
$option_default = $install_dir.$filepath.'/.'.$filename.'.default';
$option_new = $install_dir.$file;
$file_indx++;
print "$file_indx: Configuring $option_new\n";
if (! -f $option_default)
{
die "\nOption file $option_default not exists.\n";
}
open(IN1,$option_default) || die "Failed to open file $option_default\n";
open(OUT1,">$option_new") || die "Failed to open file $option_new\n";
while(<IN1>)
{
$line = $_;
chomp $line;
if(index($line,'SOFTWARE_PATH')>=0)
{
$line =~ s/SOFTWARE_PATH/$install_dir/g;
$line =~ s/\/\//\//g;
print OUT1 $line."\n";
}else{
print OUT1 $line."\n";
}
}
close IN1;
close OUT1;
}
}
close IN;
}