forked from DockstoreTestUser/ampa-nf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nextflow
executable file
·242 lines (216 loc) · 7.19 KB
/
nextflow
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
#!/bin/bash
#
# Copyright (c) 2013-2014, Centre for Genomic Regulation (CRG).
# Copyright (c) 2013-2014, Paolo Di Tommaso and the respective authors.
#
# This file is part of Nextflow.
#
# Nextflow 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.
#
# Nextflow 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 Nextflow. If not, see <http://www.gnu.org/licenses/>.
if [[ $TERM && $TERM != 'dumb' ]]; then
NORMAL=$(tput sgr0)
GREEN=$(tput setaf 2; tput bold)
YELLOW=$(tput setaf 3)
RED=$(tput setaf 1)
fi
function echo_red() {
echo -e "$RED$*$NORMAL"
}
function echo_green() {
echo -e "$GREEN$*$NORMAL"
}
function echo_yellow() {
echo -e "$YELLOW$*$NORMAL"
}
function die() {
echo_red "$*"
exit 1
}
get_abs_filename() {
echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
}
function get() {
if command -v wget &>/dev/null; then
GET="wget -q $1 -O $2"
elif command -v curl &>/dev/null; then
GET="curl -fsSL $1 -o $2"
else
echo_red "Error: cannot find 'curl' nor 'wget' utility -- please install one of them"
exit 1
fi
printf "Downloading nextflow dependencies. It may require some seconds, please wait .. "
$GET; status=$?
printf "\r\033[K"
if [ $status -ne 0 ]; then
echo_red "Error: cannot download nextflow required file -- make sure you can connect the internet"
echo ""
echo "Alternatively you can download the file:"
echo " $1"
echo ""
echo "And save it as:"
echo " ${3:-$2}"
echo ""
exit 1
fi
}
function install() {
if [ "$(uname)" = 'Darwin' ]; then tmpfile=$(mktemp $PWD/XXXXX) || exit $?
else tmpfile=$(mktemp -t XXXXX --tmpdir=$PWD) || exit $?
fi
get "http://www.nextflow.io/releases/latest/nextflow" "$tmpfile" "$1" || exit $?
mv $tmpfile $1 || exit $?
chmod +x $1 || exit $?
bash $1 -download || exit $?
echo ''
echo -e $'Nextflow installation completed. Please note:'
echo -e $'- the executable file \'nextflow\' has been created in the folder:' $(dirname $1)
echo -e $'- you may complete the installation copying it to directory in your $PATH'
echo ''
}
# check self-install
if [ "$0" = "bash" ] || [ "$0" = "/bin/bash" ]; then
if [ -d nextflow ]; then
echo 'Please note:'
echo "- The install procedure needs to create a file named 'nextflow' in this folder, but a directory with this name already exists."
echo "- Please renamed/delete that directory, or execute the Nextflow install procedure in another folder."
echo ''
exit 1
fi
install "$PWD/nextflow"
exit 0
fi
NXF_HOME=${NXF_HOME:-$HOME/.nextflow}
NXF_VER=${NXF_VER:-'0.12.0'}
NXF_ORG=${NXF_ORG:-'nextflow-io'}
NXF_ASSETS=${NXF_ASSETS:-$NXF_HOME/assets}
NXF_CLI="$0 $@"
export NXF_CLI
export NXF_ORG
export NXF_HOME
# Check if it is required to run in background
bg=''
declare -a args=("$@")
declare -a cli=(clone config drop help history info ls pull run view node console)
cmd=''
while [[ $# != 0 ]]; do
case $1 in
-bg)
bg=1
;;
-download)
if [[ ! "$cmd" ]]; then
rm -rf $NXF_HOME/framework/$NXF_VER || exit $?
$0 -version || exit $?
exit 0
fi
;;
-self-update|self-update)
if [[ ! "$cmd" ]]; then
install $0;
exit 0
fi
;;
-process.executor|-executor.name)
if [[ $2 && $2 == 'gridgain' ]]; then
NXF_PACKAGE='gg'; shift;
fi
;;
-with-extrae)
export EXTRAE_CONFIG_FILE=${EXTRAE_CONFIG_FILE:-$NXF_HOME/extrae/config}
rm -f TRACE.*
rm -rf set-0
;;
-with-drmaa)
if [[ $2 && $2 != -* ]];
then NXF_DRMAA=$2; shift;
else NXF_DRMAA='us.levk:drmaa-gridengine:6.2u5'; fi
;;
*)
[[ $1 && $1 != -* && ! "$cmd" && ${cli[*]} =~ $1 ]] && cmd=$1
;;
esac
shift
done
[[ "$cmd" == "console" ]] && NXF_PACKAGE='console'
[[ "$cmd" == "node" && ! "$NXF_PACKAGE" ]] && NXF_PACKAGE='gg'
NXF_PACKAGE=${NXF_PACKAGE:-one}
NXF_JAR=${NXF_JAR:-nextflow-$NXF_VER-$NXF_PACKAGE.jar}
NXF_BIN=${NXF_BIN:-$NXF_HOME/framework/$NXF_VER/$NXF_JAR}
NXF_BASE=${NXF_BASE:-http://www.nextflow.io/releases}
NXF_PATH=$(dirname $NXF_BIN)
NXF_URL=${NXF_URL:-$NXF_BASE/v$NXF_VER/$NXF_JAR}
NXF_GRAB=${NXF_GRAB:-''}
NXF_CLASSPATH=${NXF_CLASSPATH:-''}
# define the path when dependencies jars will be extracted
export CAPSULE_CACHE_DIR=${CAPSULE_CACHE_DIR:=$NXF_HOME/capsule}
CAPSULE_LOG=${CAPSULE_LOG:-'none'}
# Determine the Java command to use to start the JVM.
if [ ! -x "$JAVA_CMD" ] ; then
if [ -d "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVA_CMD="$JAVA_HOME/jre/sh/java"
else
JAVA_CMD="$JAVA_HOME/bin/java"
fi
else
JAVA_CMD="`which java`"
fi
fi
# Verify installed Java version
if [ ! -f "$NXF_BIN" ]; then # <-- only the first time
$JAVA_CMD -version 2>&1 | awk '/version/ {print $3}' | grep '"1\.[7|8]\..*"' > /dev/null
if [ $? -ne 0 ]; then
echo_red "Error: cannot find Java or it's a wrong version -- please make sure that Java 7 or higher it's installed"
echo_red "Note: Nextflow is trying to use the Java VM defined by the following environment variables:\n JAVA_CMD: $JAVA_CMD\n JAVA_HOME: $JAVA_HOME\n"
exit 1
fi
[ -f "$NXF_PATH" ] && rm "$NXF_PATH"
mkdir -p $NXF_PATH || exit $?
get "$NXF_URL" "$NXF_BIN"
fi
check=".+:.+:.+"
if [[ "$NXF_DRMAA" =~ $check ]]; then
# add drmaa library downloadable from maven to dependencies list
NXF_GRAB+=" $NXF_DRMAA"
elif [[ "$NXF_DRMAA" && -f "$NXF_DRMAA" ]]; then
# add drmaa jar file to custom classpath
NXF_CLASSPATH+=":$NXF_DRMAA"
elif [[ "$NXF_DRMAA" ]]; then
echo_red "Cannot find specified DRMAA library file: $NXF_DRMAA"
exit 1
fi
COLUMNS=${COLUMNS:-`tty -s && tput cols 2>/dev/null || true`}
JAVA_OPTS="-noverify -Dcapsule.trampoline"
if [[ $cmd == console ]]; then bg=1;
else JAVA_OPTS+=" -Djava.awt.headless=true"
fi
[[ "$JAVA_HOME" ]] && JAVA_OPTS+=" -Dcapsule.java.home=$JAVA_HOME"
[[ "$cmd" != "run" && "$cmd" != "node" ]] && JAVA_OPTS+=" -XX:+TieredCompilation -XX:TieredStopAtLevel=1"
[[ "$NXF_OPTS" ]] && JAVA_OPTS+=" $NXF_OPTS"
[[ "$NXF_CLASSPATH" ]] && export NXF_CLASSPATH
[[ "$NXF_GRAB" ]] && export NXF_GRAB
[[ "$COLUMNS" ]] && export COLUMNS
# use drip to speedup startup time -- https://github.com/ninjudd/drip
[[ "$NXF_DRIP" ]] && export DRIP_INIT='' && export DRIP_INIT_CLASS='nextflow.cli.DripMain'
export JAVA_CMD
# Start in daemon mode
if [[ "$bg" ]]; then
NXF_PID_FILE=${NXF_PID_FILE:-'.nextflow.pid'}
`"$JAVA_CMD" $JAVA_OPTS -jar "$NXF_BIN"` "${args[@]}" &
disown
printf $! > $NXF_PID_FILE
exit 0
fi
exec `"$JAVA_CMD" $JAVA_OPTS -jar "$NXF_BIN"` "${args[@]}"
exit 1