-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.pl
90 lines (64 loc) · 2.81 KB
/
install.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
#!/usr/bin/perl
#Dea - A complete tool for transcriptomes annotation
#Copyright (C) <2014> <Francesco Musacchia>
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program. If not, see <http://www.gnu.org/licenses/>.
use strict;
use warnings;
use Cwd;
use File::Copy;
my $configUserFile = "config_user.txt";
print "This script will prepare DEA to work in your directory.\n";
# Are you sure you want to insert all here?
# If YES folders are created here and we can write a file for Annocript where are written the two paths of the folders.
# Finish!
my $sure= getInput("Are you sure you want to enjoy this software?(y or n)",'^[YynN]$');
if ( ($sure eq "y") or ($sure eq "Y")){
#Asks to the user what is the directory where he wants to work
my $workDir = '';
while ( !(-e $workDir) ){
print "\nWrite an existing complete path where you want to play with DEA (/home/username/dea_works): ";
$workDir= <STDIN>;
chomp $workDir; #to cancel the return
}
#print "working dir: $workDir\n";
#I take the folder path of DEA
my $annDir = getcwd;
chmod 0755,"the_annocript.pl";
#Writing a file with the paths to the current folder and the Annocript one
open (FOLD, ">$workDir/folders.txt") or die "Cannot create file folders.txt. Exiting.. \n";
print FOLD "$workDir $annDir";
close(FOLD);
#Moving the User configuration file in the working directory
chmod 0755,$annDir."/$configUserFile";
copy($annDir."/CONFIGURATION/$configUserFile",$workDir."/$configUserFile") or die "Unable to copy $annDir/$configUserFile in $workDir/$configUserFile\n";
print "Done! Now you can start from this folder!\n";
}else {die "Change directory and start again the install script.\n";}
=head2 getInput
Title : getInput
Usage : getInput( - sentence: a sentence that will printed in input to ask something to the user;
- regex: what the answer of the user have to respect
);
Function: Takes in input a sentence and a regex. Asks to the user the sentence and controls its input with regex
Returns : input given by the user
=cut
sub getInput{
my $sentence = shift;
my $regex = shift;
my $input='';
while (!($input =~ /$regex/) or ($input eq "")){
print $sentence." ";
$input = <STDIN>;
chomp $input;
print "\n";
}
return $input;
}