-
Notifications
You must be signed in to change notification settings - Fork 43
/
install_krakenuniq.sh
executable file
·122 lines (104 loc) · 3.95 KB
/
install_krakenuniq.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
#!/bin/bash
# Portions (c) 2017-2018, Florian Breitwieser <fbreitwieser@jhu.edu>
# Copyright 2013-2015, Derrick Wood <dwood@cs.jhu.edu>
#
# Kraken 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.
#
# Kraken 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 Kraken. If not, see <http://www.gnu.org/licenses/>.
set -e
DIR=$(dirname $0)
VERSION=`cat $(dirname $0)/VERSION`
INSTALL_JELLYFISH=0
MAKE_ARGS=
MAKE_CLEAN="clean"
ADD_DEBUG_INFO=0
LINK_DIR=
USAGE="Usage: $(basename $0) [OPTIONS] INSTALL_DIR
OPTIONS:
-l BIN_DIR Link KrakenUniq executables to BIN_DIR, e.g /usr/local/bin or ~/bin.
-j Install jellyfish v1.1 in INSTALL_DIR.
-c BIN Use compiler BIN instead of g++.
-g Add debug info
-h This help message
On MacOS, if you experience the error \"clang: fatal error: unsupported option '-fopenmp'\" on OSX, try installing g++ with brew, and using the option \"-c g++-7\".
"
while getopts "Chjc:gl:" OPTION; do
case $OPTION in
c) MAKE_ARGS="CXX=\"$OPTARG\"" ;;
C) MAKE_CLEAN="" ;;
g) ADD_DEBUG_INFO=1 ;;
j) INSTALL_JELLYFISH=1 ;;
l) LINK_DIR="$OPTARG" ;;
h) echo "$USAGE"; exit 0 ;;
*) echo "Incorrect options provided. $USAGE"
exit 1 ;;
esac
done
shift $((OPTIND -1))
if [ -z "$1" ]
then
echo "$USAGE"
exit 0
fi
if [ "$1" = "KRAKEN_DIR" ]
then
echo "Please replace \"KRAKEN_DIR\" with the name of the directory"
echo "that you want to install Kraken in."
exit 1
fi
# Perl cmd used to canonicalize dirname - "readlink -f" doesn't work
# on OS X.
export KRAKEN_DIR=$(perl -MCwd=abs_path -le 'print abs_path(shift)' "$1")
mkdir -p "$KRAKEN_DIR"
if [ "$INSTALL_JELLYFISH" == "1" ]; then
(cd $KRAKEN_DIR
if [ ! -e jellyfish-install/bin/jellyfish ]; then
echo "Installing jellyfish"
wget https://github.com/gmarcais/Jellyfish/releases/download/v1.1.12/jellyfish-1.1.12.tar.gz
tar xzf jellyfish-1.1.12.tar.gz && rm -rf jellyfish-1.1.12.tar.gz
mv jellyfish-1.1.12 jellyfish-install
cd jellyfish-install && ./configure --prefix=$PWD && make -j install || echo "Jellyfish 1 installation failed, building new database may not work properly"
fi)
fi
[[ "$ADD_DEBUG_INFO" == 1 ]] && MAKE_ARGS="$MAKE_ARGS NDEBUG=-g"
echo make -C $DIR/src $MAKE_CLEAN install $MAKE_ARGS
make -C $DIR/src $MAKE_CLEAN install $MAKE_ARGS || { echo "Error building KrakenUniq. See $(basename $0) -h for options." >&2; exit 1; }
for file in $DIR/scripts/*
do
[[ -f $file ]] || continue;
perl -pl -e 'BEGIN { while (@ARGV) { $_ = shift; ($k,$v) = split /=/, $_, 2; $H{$k} = $v } }'\
-e 's/#####=(\w+)=#####/$H{$1}/g' \
"KRAKEN_DIR=$KRAKEN_DIR" "VERSION=$VERSION" \
< "$file" > "$KRAKEN_DIR/$(basename $file)"
if [ -x "$file" ]
then
chmod +x "$KRAKEN_DIR/$(basename $file)"
fi
done
mkdir -p $KRAKEN_DIR/File
cp -r $DIR/scripts/File/* $KRAKEN_DIR/File
echo "Installed KrakenUniq in $KRAKEN_DIR."
if [[ "$LINK_DIR" != "" ]]; then
[[ -d "$LINK_DIR" ]] || mkdir -p $LINK_DIR
for file in $KRAKEN_DIR/krakenuniq*; do
[ -x "$file" ] && ln -sf $file $LINK_DIR/`basename $file`
done
ln -sf $KRAKEN_DIR/jellyfish-install $LINK_DIR/jellyfish-install
echo "Linked KrakenUniq files to $LINK_DIR."
else
echo "You may want to link KrakenUniq scripts to /usr/bin or another directory for executables, or add the install directory to the PATH environment variable. Main executables: "
for file in $KRAKEN_DIR/krakenuniq*; do
[ -x "$file" ] && echo $file
done
fi
echo "KrakenUniq installation complete."
exit 0