-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.pl
105 lines (83 loc) · 2.94 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
#!/usr/bin/perl -w
use FileHandle; # use FileHandles instead of open(),close()
use Cwd;
use Cwd 'abs_path';
######################## !!! customize settings here !!! ############################
# #
# Set installation directory of InterOmicsPRO to your unzipped InterOmicsPRO directory #
$install_dir = "/your_path/InterOmicsPRO";
######################## !!! End of customize settings !!! ##########################
if($install_dir eq "/your_path/InterOmicsPRO")
{# user forgets to set the default path of InterOmicsPRO, try to solve this problem
$install_dir = getcwd;
$install_dir=abs_path($install_dir);
}
if(!-s $install_dir)
{
die "The InterOmicsPRO directory ($install_dir) is not existing, please revise the customize settings part inside the configure.pl, set the path as your unzipped InterOmicsPRO directory\n";
}
if ( substr($install_dir, length($install_dir) - 1, 1) ne "/" )
{
$install_dir .= "/";
}
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 in the installation directory of InterOmicsPRO.\n";
}
print " OK!\n";
################Don't Change the code below##############
if (! -d $install_dir)
{
die "can't find installation directory.\n";
}
if ( substr($install_dir, length($install_dir) - 1, 1) ne "/" )
{
$install_dir .= "/";
}
if (prompt_yn("InterOmicsPRO will be installed into <$install_dir> ")){
}else{
die "The installation is cancelled!\n";
}
print "Start install InterOmicsPRO into <$install_dir>\n";
$files ="run.py,install.py,omics_scripts/Genomics.py,omics_scripts/Transcriptomics.py";
@updatelist =split(/,/,$files);
foreach my $file (@updatelist) {
$file2update=$install_dir.$file;
$check_log ='GLOBAL_PATH=';
open(IN,$file2update) || die "Failed to open file $file2update\n";
open(OUT,">$file2update.tmp") || die "Failed to open file $file2update.tmp\n";
while(<IN>)
{
$line = $_;
chomp $line;
if(index($line,$check_log)>=0)
{
print $file2update."\n";
print "Current ".$line."\n";
print "Change to ".substr($line,0,index($line, '=')+1)." \'".$install_dir."\'\n\n\n";
print OUT substr($line,0,index($line, '=')+1)."\'".$install_dir."\'\n";
}else{
print OUT $line."\n";
}
}
close IN;
close OUT;
system("mv $file2update.tmp $file2update");
system("chmod 755 $file2update");
}
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;
}