-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure.sh
executable file
·193 lines (159 loc) · 5.61 KB
/
configure.sh
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
#!/bin/bash
## Ensure that sudo is used, not su
if [ "`whoami`" = "root" ] && [ -z "$SUDO_USER" ]
then
echo '##########################################'
echo "## ERROR ##"
echo "Please run configure.sh using sudo, not su"
echo '##########################################'
exit 1
fi
if [ "`whoami`" != "root" ]
then
echo '##################################'
echo "## ERROR ##"
echo "Please run configure.sh using sudo"
echo '##################################'
exit 1
fi
## Define default paths
INSTALLPATH='/home/'$SUDO_USER'/SSDS_pipeline_1.0.0/'
GENOMESPATH='/home/'$SUDO_USER'/SSDS_pipeline_1.0.0/genomes'
## Check args
while [[ $# -gt 1 ]]
do
key="$1"
case $key in
-g|--genomes)
GENOMESPATH="$2"
shift # past argument
;;
-i|--install_dir)
INSTALLPATH="$2"
shift # past argument
;;
*)
# unknown option
;;
esac
shift # past argument or value
done
echo INSTALL PATH = "${INSTALLPATH}"
echo GENOMES FOLDER = "${GENOMESPATH}"
sleep 3
# Warn users if root-accessible folders are selected
installParentDir="$(dirname "$INSTALLPATH")"
iOwner=`ls -ld $installParentDir |awk '{print $3}'`
if [ "$iOwner" = "root" ]
then
echo "##### WARNING ##### : Installation folder ["$INSTALLPATH"] is only writable by root user"
sleep 3
fi
## Create Installation Folder
mkdir -p $INSTALLPATH || exit 1
chmod a+rw $INSTALLPATH || exit 1
genomeParentDir="$(dirname "$GENOMESPATH")"
gOwner=`ls -ld $genomeParentDir |awk '{print $3}'`
if [ "$gOwner" = "root" ]
then
echo "##### WARNING ##### : SSDS Genomes folder ["$GENOMESPATH"] is only writable by root user"
sleep 3
fi
## Create Genomes Folder
mkdir -p $GENOMESPATH || exit 1
chmod a+rw $GENOMESPATH || exit 1
######################## DONE ARGS ######################
## Copy git folder to install location
RUNDIR=`pwd`
FLDNAME=`basename $RUNDIR`
# Check start dir
TSTFILE=$RUNDIR'/run_ssDNAPipeline'
if [ -f $TSTFILE ]; then
echo "OK ... configuring SSDS alignment pipeline ..."
else
echo "** ERROR **"
echo "Cannot execute config script from $RUNDIR"
echo "Please run configure.sh from the call hotspots pipeline folder."
echo "This folder contains the run_ssDNAPipeline script."
exit
fi
cp -r $RUNDIR/* $INSTALLPATH || exit 1
if [ "$iOwner" != "root" ]
then
chown -R $SUDO_USER $INSTALLPATH || exit 1
fi
# Check install dir
RUNDIR=$INSTALLPATH
TSTFILE=$RUNDIR'/run_ssDNAPipeline'
if [ -f $TSTFILE ]; then
echo "OK ... configuring SSDS alignment pipeline ..."
else
echo "** ERROR **"
echo "Cannot execute config script from $RUNDIR"
echo "Please ensure that the installation folder ["$INSTALLPATH"]can be created."
exit
fi
## Get packages
#apt-get install -y default-jre zlib1g-dev bioperl || exit 1
## KB 07-24-19: Added some pkgs not in default Ubuntu 18+ distros
apt-get install -y make libncurses5 libncurses5-dev build-essential default-jre zlib1g-dev bioperl || exit 1
## Get perl modules
export PERL_MM_USE_DEFAULT=1
cpan File::Temp || exit 1
cpan Getopt::Long || exit 1
cpan Math::Round || exit 1
cpan Statistics::Descriptive || exit 1
cpan Switch || exit 1
cpan Module::Build || exit 1
perl $RUNDIR/Bio-SamTools-1.43/INSTALL.pl
## Add environment vars to .bashrc
for thisBASHRC in `find /home -maxdepth 2 -name '.bashrc'` '/root/.bashrc'; do
cp $thisBASHRC $thisBASHRC\.SSDSpipeline.bak || exit 1
grep -vP '##SSDSPIPELINE_ENVIRONMENT_VARS' $thisBASHRC\.SSDSpipeline.bak >$thisBASHRC ||exit 1
echo '##SSDSPIPELINE_ENVIRONMENT_VARS' >>$thisBASHRC || exit 1
echo 'export SSDSPIPELINEPATH='$RUNDIR' ##SSDSPIPELINE_ENVIRONMENT_VARS' >>$thisBASHRC || exit 1
echo 'export SSDSPICARDPATH='$RUNDIR'/picard-tools-2.3.0 ##SSDSPIPELINE_ENVIRONMENT_VARS' >>$thisBASHRC || exit 1
echo 'export SSDSFASTXPATH='$RUNDIR >>$thisBASHRC' ##SSDSPIPELINE_ENVIRONMENT_VARS' || exit 1
echo 'export SSDSSAMTOOLSPATH='$RUNDIR'/samtools-0.1.17 ##SSDSPIPELINE_ENVIRONMENT_VARS' >>$thisBASHRC || exit 1
echo 'export SSDSGENOMESPATH='$GENOMESPATH' ##SSDSPIPELINE_ENVIRONMENT_VARS' >>$thisBASHRC || exit 1
echo 'export SSDSTMPPATH=/tmp ##SSDSPIPELINE_ENVIRONMENT_VARS' >>$thisBASHRC || exit 1
echo 'export PERL5LIB='$PERL5LIB':'$RUNDIR' ##SSDSPIPELINE_ENVIRONMENT_VARS' >>$thisBASHRC || exit 1
done
## Export environment vars for current session
export SSDSPIPELINEPATH=$RUNDIR >>$thisBASHRC || exit 1
export SSDSPICARDPATH=$RUNDIR'/picard-tools-2.3.0' >>$thisBASHRC || exit 1
export SSDSFASTXPATH=$RUNDIR >>$thisBASHRC || exit 1
export SSDSSAMTOOLSPATH=$RUNDIR'/samtools-0.1.17' >>$thisBASHRC || exit 1
export SSDSGENOMESPATH=$GENOMESPATH >>$thisBASHRC || exit 1
export SSDSTMPPATH=/tmp >>$thisBASHRC || exit 1
export PERL5LIB=$PERL5LIB':'$RUNDIR >>$thisBASHRC || exit 1
## Output some info
echo ''
echo $SSDSPIPELINEPATH' ... OK SSDS PIPELINE PATH?'
echo $SSDSPICARDPATH' ... OK SSDS PICARD PATH?'
echo $SSDSFASTXPATH' ... OK SSDS FASTX PATH?'
echo $SSDSSAMTOOLSPATH' ... OK SSDS SAMTOOLS PATH?'
echo $SSDSGENOMESPATH' ... OK SSDS GENOMES PATH?'
echo $SSDSTMPPATH' ... OK TMP PATH?'
echo $PERL5LIB' ... OK PERL PATH?'
echo ''
echo '-------------------------------------------------'
echo "Configuration complete ... running unit tests ..."
echo '-------------------------------------------------'
resetOwnership () {
# Reset all ownership to current user
# unless installed to admin location
if [ "$1" != "root" ]
then
chown -R $SUDO_USER $2 || exit 1
chgrp -R $SUDO_GID $2 || exit 1
fi
}
resetOwnership $iOwner $INSTALLPATH
resetOwnership $gOwner $GENOMESPATH
## Run tests
su $SUDO_USER -c 'sh $SSDSPIPELINEPATH/unitTest/runTest.sh' || exit 1
## Give the ALL OK !!
echo "Tests complete ..."
echo "SSDS alignment pipeline installed to "$SSDSPIPELINEPATH
echo 'Restart computer or logout/login to use ..'