forked from cancerit/cgpCaVEManPostProcessing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·175 lines (149 loc) · 4.25 KB
/
setup.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
#!/bin/bash
##########LICENCE##########
# Copyright (c) 2014-2018 Genome Research Ltd.
#
# Author: CASM/Cancer IT <[email protected]>
#
# This file is part of cgpCaVEManPostProcessing.
#
# cgpCaVEManPostProcessing is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero 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 Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
##########LICENCE##########
SOURCE_BEDTOOLS="https://github.com/arq5x/bedtools2/releases/download/v2.21.0/bedtools-2.21.0.tar.gz"
EXP_BTV="2.21.0"
version_gt () {
test $(printf '%s\n' $@ | sort -V | head -n 1) == "$1";
}
get_distro () {
if hash curl 2>/dev/null; then
curl -sSL -o $1.tar.gz -C - --retry 10 $2
else
wget -nv -O $1.tar.gz $2
fi
mkdir -p $1
tar --strip-components 1 -C $1 -zxf $1.tar.gz
}
if [ "$#" -ne "1" ] ; then
echo "Please provide an installation path such as /opt/ICGC"
exit 0
fi
INST_PATH=$1
# get current directory
INIT_DIR=`pwd`
# cleanup inst_path
mkdir -p $INST_PATH/bin
cd $INST_PATH
INST_PATH=`pwd`
cd $INIT_DIR
# make sure that build is self contained
unset PERL5LIB
ARCHNAME=`perl -e 'use Config; print $Config{archname};'`
PERLROOT=$INST_PATH/lib/perl5
export PERL5LIB="$PERLROOT"
export PATH="$INST_PATH/bin:$PATH"
#create a location to build dependencies
SETUP_DIR=$INIT_DIR/install_tmp
mkdir -p $SETUP_DIR
# re-initialise log file
echo > $INIT_DIR/setup.log
# log information about this system
(
echo '============== System information ===='
set -x
lsb_release -a
uname -a
sw_vers
system_profiler
grep MemTotal /proc/meminfo
set +x
echo
) >>$INIT_DIR/setup.log 2>&1
CGPVCF=`perl -le 'eval "require $ARGV[0]" and print $ARGV[0]->VERSION' Sanger::CGP::Vcf`
if [[ "x$CGPVCF" == "x" ]] ; then
echo "PREREQUISITE: Please install cgpVcf before proceeding:"
echo " https://github.com/cancerit/cgpVcf/releases"
exit 1;
fi
BIODBHTS=`perl -le 'eval "require $ARGV[0]" and print $ARGV[0]->VERSION' Bio::DB::HTS`
if [[ "x$BIODBHTS" == "x" ]] ; then
echo "PREREQUISITE: Please install Bio::DB::HTS before proceeding"
exit 1;
fi
CPU=`grep -c ^processor /proc/cpuinfo`
if [ $? -eq 0 ]; then
if [ "$CPU" -gt "6" ]; then
CPU=6
fi
else
CPU=1
fi
echo "Max compilation CPUs set to $CPU"
set -e
#add bin path for install tests
export PATH="$INST_PATH/bin:$PATH"
BTV=`bedtools --version | cut -d v -f 2`
echo -n "Building bedtools ..."
if [ -e $SETUP_DIR/bedtools.success ]; then
echo -n " previously installed ...";
else
if [[ "x$BTV" == "x" ]] ; then
echo "PREREQUISITE: bedtools version >= $EXP_BTV. Installing... "
set -x
cd $SETUP_DIR
if [ ! -e bedtools ]; then
get_distro "bedtools2" $SOURCE_BEDTOOLS
fi
make -C bedtools2 -j$CPU
cp bedtools2/bin/* $INST_PATH/bin/.
set +x
touch $SETUP_DIR/bedtools.success
else
if version_gt $BTV $EXP_BTV; then
echo " bedtools version is good ($BTV)"
touch $SETUP_DIR/bedtools.success
else
echo "PREREQUISITE: bedtools version >= $EXP_BTV but found version $BTV). Installing ..."
set -x
cd $SETUP_DIR
if [ ! -e bedtools ]; then
get_distro "bedtools2" $SOURCE_BEDTOOLS
fi
make -C bedtools2 -j$CPU
cp bedtools2/bin/* $INST_PATH/bin/.
set +x
touch $SETUP_DIR/bedtools.success
fi
fi
fi
cd $INIT_DIR
echo -n "Installing Perl prerequisites ..."
set -x
perl $INST_PATH/bin/cpanm -v --mirror http://cpan.metacpan.org -l $INST_PATH/ --installdeps .
set +x
echo -n "Installing cgpCaVEManPostProcessing ..."
set -xe
perl Makefile.PL INSTALL_BASE=$INST_PATH
make
make test
make install
set +x
# cleanup all junk
rm -rf $SETUP_DIR
echo
echo
echo "Please add the following to beginning of path:"
echo " $INST_PATH/bin"
echo "Please add the following to beginning of PERL5LIB:"
echo " $PERLROOT"
echo
exit 0