forked from gymreklab/GangSTR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-gangstr.sh
executable file
·139 lines (119 loc) · 4.14 KB
/
install-gangstr.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
#!/bin/bash
# Copyright (C) 2017 Melissa Gymrek <[email protected]>
# and Nima Mousavi ([email protected])
#
# This file is part of GangSTR.
#
# GangSTR 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.
#
# GangSTR 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 GangSTR. If not, see <http://www.gnu.org/licenses/>.
die()
{
BASE=$(basename "$0")
echo "$BASE error: $1" >&2
exit 1
}
check_program()
{
PROG="$1"
# If the program is found in the $PATH, just return
which "$PROG" >/dev/null && return
# Otherwise, show an error with some helpful information
echo "
--- GangSTR Compilation Error ---
You are trying to install GangSTR.
A required program '$PROG' was not found.
To run this script, the following programs are needed:
wget
A C++ compiler
pkg-config
You additionally must have an internet connection
---
"
exit 1
}
usage()
{
BASE=$(basename -- "$0")
echo "Install GangSTR and dependencies
Usage:
./$BASE [PREFIX]
If a PREFIX is provided, will install GangSTR and all dependencies to that directory. Otherwise install do default directory.
IF YOU ARE INSTALLING LOCALLY, it is recommended to use your home directory as the prefix. e.g.:
./$BASE /home/<username>
IF YOU ARE INSTALLING AS ROOT, you don't need to pass a prefix, but probably need to use sudo, e,g.:
sudo ./$BASE
"
exit 0
}
for PROG in wget make pkg-config;
do
check_program $PROG
done
PREFIX=$1
if [ "x$1" == "x-h" -o "x$1" == "x--help" ]
then
usage
fi
# If PREFIX not set, use default.
if [ "x$PREFIX" == "x" ]
then
PREFIX=/usr/local
else
export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig
fi
# Check that prefix exists
if [ ! -d "$PREFIX" ]; then
die "Directory $PREFIX does not exist. Try running: ./install-gangstr.sh $HOME"
fi
echo "[install-deps.sh] Compiling GangSTR+dependencies with prefix=$PREFIX"
mkdir -p dependences || die "Could not make dependencies directory"
# Install GSL
echo "[install-deps.sh] Compiling GSL..."
cd dependences
wget -O gsl-2.5.tar.gz ftp://ftp.gnu.org/gnu/gsl/gsl-2.5.tar.gz || die "Error downloading GSL"
tar -xzvf gsl-2.5.tar.gz || die "Error unzipping GSL"
cd gsl-2.5/ || die "Error navigating to GSL directory"
./configure --prefix=$PREFIX || die "Error configuring GSL"
make || die "Error compiling GSL"
make install || die "Error installing GSL"
# Install NLOPT
echo "[install-deps.sh] Compiling NLOPT..."
cd ../ || die "Error navigating to dependencies"
wget -O nlopt-2.4.2.tar.gz http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz || die "Error downloading NLOPT"
tar -xzvf nlopt-2.4.2.tar.gz || die "Error unzipping NLOPT"
cd nlopt-2.4.2 || die "Error navigating to NLOPT directory"
./configure --prefix=$PREFIX || die "Error configuring NLOPT"
make || die "Error compiling NLOPT"
make install || die "Error installing NLOPT"
# Install HTSLIB
echo "[install-deps.sh] Compiling HTSLIB..."
cd ../ || die "Error navigating to dependencies"
wget -O htslib-1.8.tar.bz2 https://github.com/samtools/htslib/releases/download/1.8/htslib-1.8.tar.bz2 || die "Error downloading HTSLIB"
tar -xjvf htslib-1.8.tar.bz2 || die "Error unzipping HTSLIB"
cd htslib-1.8/ || die "Error navigating to HTSLIB"
./configure --disable-lzma --disable-bz2 --prefix=$PREFIX || die "Error configuring HTSLIB"
make || die "Error compiling HTSLIB"
make install || die "Error installing HTSLIB"
cd ../../
# Install GangSTR
./configure --prefix=$PREFIX || die "Error configuring GangSTR"
make || die "Error compiling GangSTR"
make install || die "Error installing GangSTR"
echo ""
echo ""
echo ""
echo ""
echo "[install-deps.sh] Success! GangSTR installed in $PREFIX/bin/"
echo "[install-deps.sh] Type GangSTR --help to make sure GangSTR is installed"
echo "[install-deps.sh] Be sure to ensure $PREFIX/bin is on your PATH"
exit 0