-
Notifications
You must be signed in to change notification settings - Fork 7
/
opt-build.sh
129 lines (112 loc) · 3.82 KB
/
opt-build.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
#! /bin/bash
set -xe
if [[ -z "${TMPDIR}" ]]; then
TMPDIR=/tmp
fi
set -u
if [ "$#" -lt "1" ] ; then
echo "Please provide an installation path such as /opt/ICGC"
exit 1
fi
# get path to this script
SCRIPT_PATH=`dirname $0`;
SCRIPT_PATH=`(cd $SCRIPT_PATH && pwd)`
# get the location to install to
INST_PATH=$1
mkdir -p $1
INST_PATH=`(cd $1 && pwd)`
echo $INST_PATH
# get current directory
INIT_DIR=`pwd`
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"
SETUP_DIR=$INIT_DIR/install_tmp
mkdir -p $SETUP_DIR/distro # don't delete the actual distro directory until the very end
mkdir -p $INST_PATH/bin
cd $SETUP_DIR
# make sure tools installed can see the install loc of libraries
set +u
export LD_LIBRARY_PATH=`echo $INST_PATH/lib:$LD_LIBRARY_PATH | perl -pe 's/:\$//;'`
export PATH=`echo $INST_PATH/bin:$PATH | perl -pe 's/:\$//;'`
export MANPATH=`echo $INST_PATH/man:$INST_PATH/share/man:$MANPATH | perl -pe 's/:\$//;'`
export PERL5LIB=`echo $INST_PATH/lib/perl5:$PERL5LIB | perl -pe 's/:\$//;'`
set -u
## INSTALL CPANMINUS
set -eux
curl -sSL https://cpanmin.us/ > $SETUP_DIR/cpanm
perl $SETUP_DIR/cpanm --no-wget --no-interactive --notest --mirror http://cpan.metacpan.org -l $INST_PATH App::cpanminus
rm -f $SETUP_DIR/cpanm
## HTSLIB (tar.bz2)
if [ ! -e $SETUP_DIR/htslib.success ]; then
rm -rf htslib
mkdir -p htslib
curl -sSL --retry 10 https://github.com/samtools/htslib/releases/download/${VER_HTSLIB}/htslib-${VER_HTSLIB}.tar.bz2 > distro.tar.bz2
tar --strip-components 1 -C htslib -jxf distro.tar.bz2
cd htslib
./configure --enable-plugins --enable-libcurl --prefix=$INST_PATH
make clean
make -j$CPU
make install
cd $SETUP_DIR
rm -rf distro.*
touch $SETUP_DIR/htslib.success
fi
## SAMTOOLS (tar.bz2)
if [ ! -e $SETUP_DIR/samtools.success ]; then
curl -sSL --retry 10 https://github.com/samtools/samtools/releases/download/${VER_SAMTOOLS}/samtools-${VER_SAMTOOLS}.tar.bz2 > distro.tar.bz2
rm -rf distro/*
tar --strip-components 1 -C distro -xjf distro.tar.bz2
cd distro
./configure --enable-plugins --enable-libcurl --with-htslib=$INST_PATH --prefix=$INST_PATH
make clean
make -j$CPU all
make install
cd $SETUP_DIR
rm -rf distro.* distro/*
touch $SETUP_DIR/samtools.success
fi
## Bio::DB::HTS (tar.gz)
if [ ! -e $SETUP_DIR/Bio-DB-HTS.success ]; then
## add perl deps
cpanm --no-wget --no-interactive --notest --mirror http://cpan.metacpan.org -l $INST_PATH Module::Build
cpanm --no-wget --no-interactive --notest --mirror http://cpan.metacpan.org -l $INST_PATH XML::Parser
cpanm --no-wget --no-interactive --notest --mirror http://cpan.metacpan.org -l $INST_PATH Bio::Root::Version
curl -sSL --retry 10 https://github.com/Ensembl/Bio-DB-HTS/archive/${VER_BIODBHTS}.tar.gz > distro.tar.gz
rm -rf distro/*
tar --strip-components 1 -C distro -zxf distro.tar.gz
cd distro
perl Build.PL --install_base=$INST_PATH --htslib=$INST_PATH
./Build
./Build test
./Build install
cd $SETUP_DIR
rm -rf distro.* distro/*
touch $SETUP_DIR/Bio-DB-HTS.success
fi
## vcftools
if [ ! -e $SETUP_DIR/vcftools.success ]; then
curl -sSL --retry 10 -o distro.tar.gz https://github.com/vcftools/vcftools/releases/download/v${VER_VCFTOOLS}/vcftools-${VER_VCFTOOLS}.tar.gz
rm -rf distro/*
tar --strip-components 2 -C distro -xzf distro.tar.gz
cd distro
./configure --prefix=$INST_PATH --with-pmdir=lib/perl5
make -j$CPU
make install
cd $SETUP_DIR
rm -rf distro.* distro/*
touch $SETUP_DIR/vcftools.success
fi
## bedtools
if [ ! -e $SETUP_DIR/bedtools.success ]; then
curl -sSL --retry 10 -o $INST_PATH/bin/bedtools https://github.com/arq5x/bedtools2/releases/download/v${VER_BEDTOOLS}/bedtools
chmod +x $INST_PATH/bin/bedtools
chmod -w $INST_PATH/bin/bedtools
touch $SETUP_DIR/bedtools.success
fi