forked from icbi-lab/NeoFuse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NeoFuse
executable file
·365 lines (339 loc) · 12.2 KB
/
NeoFuse
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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
#! /bin/bash
realpath2 ()
{
relpath=$1
cpath=`pwd`
reldir=`dirname $relpath`
relfile=`basename $relpath`
cd $reldir
abspath=`pwd`
abspath=$abspath"/"$relfile
cd $cpath
echo $abspath
}
OUTDIR="./"
declare -i PEPMAX
declare -i PEPMIN
PEPMIN=8
declare -i CORES
CORES=1
declare -i RAMLIMIT
RAMLIMIT=0
THRESHOLD=""
RANK=""
CONF="L"
NETMHCPAN="false"
BUILD="false"
BUILDREF="false"
VERSION="GRCh38"
while getopts ":1::2::d::i::o::m::M::n::t::T::c::s::g::a::l::-::N::BRV::h" opt;
do
case $opt in
1) READ1="$OPTARG";;
2) READ2="$OPTARG";;
d) ID="$OPTARG";;
i) IN="$OPTARG";;
o) OUTDIR="$OPTARG";;
m) PEPMIN="$OPTARG";;
M) PEPMAX="$OPTARG";;
n) CORES="$OPTARG";;
t) THRESHOLD="$OPTARG";;
T) RANK="$OPTARG";;
c) CONF="$OPTARG";;
s) STARINDEX="$OPTARG";;
g) GENOMEDIR="$OPTARG";;
a) ANNOTATION="$OPTARG";;
N) NETMHCPAN="$OPTARG";;
l) RAMLIMIT="$OPTARG";;
-) IMAGE="$OPTARG";;
B) BUILD="true";;
R) BUILDREF="true";;
V) VERSION="$OPTARG";;
h) HELP="true";;
esac
done
if [ "$BUILD" == "false" ]; then
if [ "$READ1" == "" ] && [ "$IN" == "" ] && [ "$BUILDREF" == "false" ] || [ "$HELP" == "true" ]; then
echo "Usage: NeoFuse <arguments> [options]
<Arguments>
-1: Path to read 1 FASTQ file (mandatory only for single sample analysis)
-2: Path to read 2 FASTQ fie (optional for single-end reads)
-i: Path to TSV file (mandatory only for multiple sample analysis)
-s: Path to STAR index directory
-g: Path to reference genome FASTA file
-a: Path to annotation GTF file
-o: Output directory (default: "./")
-d: Run ID (default: input filename)
-B: Build singularity/docker image
-R: Build indexes
[Options]
-m: Minimum peptide length (8, 9, 10, or 11; default: 8)
-M: Maximum peptide length (8, 9, 10, or 11; default: 8)
-n: Number of cores (default: 1)
-t: IC50 binding affinity threshold (default: 500)
-T: Percentile rank threshold (default: Inf)
-c: Mimimum confidence score (H, M or L; default: L)
--singularity: NeoFuse will use the Singularity image
--docker: NeoFuse will use the Docker image
For more information please refer to https://icbi.i-med.ac.at/software/NeoFuse/
"
exit 0
else
:
fi
if [ "$BUILDREF" == "true" ]; then
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE is a relative symlink, resolve it relative to the path where the symlink file is located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
OUTDIR=`realpath2 $OUTDIR`
mkdir -p $OUTDIR
if [ "$IMAGE" == "docker" ]; then
DMOUNT="-v $OUTDIR:/mnt/out/$(echo ${OUTDIR##*/})"
OUTDIR="/mnt/out/$(echo ${OUTDIR##*/})"
docker run $DMOUNT icbi/neofuse NeoFuse-download -o $OUTDIR -t $CORES -v $VERSION
exit 0
elif [ "$IMAGE" == "singularity" ]; then
SMOUNT="-B $OUTDIR:/mnt/out/$(echo ${OUTDIR##*/})"
OUTDIR="/mnt/out/$(echo ${OUTDIR##*/})"
singularity exec $SMOUNT $DIR"/NeoFuse.sif" NeoFuse-download -o $OUTDIR -t $CORES -v $VERSION
exit 0
else
echo "You must specify '--docker' or '--singularity'"
echo "Exiting ..."
exit 1
fi
else
:
fi
if [ "$THRESHOLD" == "" ] && [ "$RANK" == "" ]; then
THRESHOLD=500
RANK=inf
elif [ "$THRESHOLD" != "" ] && [ "$RANK" == "" ]; then
RANK=inf
elif [ "$THRESHOLD" == "" ] && [ "$RANK" != "" ]; then
THRESHOLD=inf
fi
if [ "$NETMHCPAN" == "false" ]; then
:
else
NETMHCPAN=`realpath2 $NETMHCPAN`
if [ ! -d "$NETMHCPAN" ]; then
echo "No local netMHCpan instalation found"
echo "Install netMHCpan and try again"
echo "Exiting ..."
exit 1
else
:
fi
fi
if test $ID; then
:
else
ID=$(echo ${READ1##*/} | sed s/_.*fastq.*//)
fi
if [ "$PEPMAX" == "" ]; then
PEPMAX=$PEPMIN
fi
if [ "$IN" != "" ] && [ "$READ1" != "" ]; then
echo " You may specify as input a TSV file OR FASTQ file(s), but not both "
echo "Exiting ..."
exit 1
fi
if [ "$IN" != "" ] && [ "$READ2" != "" ]; then
echo " You may specify as input a TSV file OR FASTQ file(s), but not both "
echo "Exiting ..."
exit 1
fi
if [ "$STARINDEX" == "" ]; then
echo "You must specify a STAR index directory"
echo "Exiting ..."
exit 1
elif [ "$GENOMEDIR" == "" ]; then
echo "You must specify a FASTA reference file"
echo "Exiting ..."
exit 1
elif [ "$ANNOTATION" == "" ]; then
echo "You must specify an annotation GTF file"
echo "Exiting ..."
exit 1
fi
# Convert relative to absolute paths
if [ "$IN" != "" ]; then
IN=`realpath2 $IN`
fi
if [ "$READ1" != "" ]; then
READ1=`realpath2 $READ1`
fi
if [ "$READ2" != "" ]; then
READ2=`realpath2 $READ2`
fi
mkdir -p $OUTDIR
OUTDIR=`realpath2 $OUTDIR`
STARINDEX=`realpath2 $STARINDEX`
GENOMEDIR=`realpath2 $GENOMEDIR`
ANNOTATION=`realpath2 $ANNOTATION`
# Get the source dir
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE is a relative symlink, resolve it relative to the path where the symlink file is located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
if [ "$IMAGE" == "docker" ] || [ "$IMAGE" == "singularity" ] || [ "$IMAGE" == "" ]; then
:
else
echo "Invalid parameter, accepted values are: [--singularity], [--docker], []"
echo "Exiting ..."
exit 1
fi
if [ "$IMAGE" == "docker" ] || [ "$IMAGE" == "singularity" ] ; then
# If user calls for Docker/singularity:
## Change realpaths to mount points
if [ "$IN" != "" ]; then
cat $IN > $(echo $IN | sed s/.tsv//)_temp.tsv
IN=$(echo $IN | sed s/.tsv//)_temp.tsv
INDIR=$(awk '{if(NR==2){ print $2; }}' < "$IN")
INDIR=$(dirname "${INDIR}")
sed -i "s%$INDIR%/mnt/data%g" $IN
INDIR=`realpath2 $INDIR`
SMOUNT="-B $INDIR:/mnt/data,$IN:/mnt/$(echo ${IN##*/}),$OUTDIR:/mnt/out/$(echo ${OUTDIR##*/}),$STARINDEX:/mnt/genome/$(echo ${STARINDEX##*/}),$GENOMEDIR:/mnt/genome/$(echo ${GENOMEDIR##*/}),$ANNOTATION:/mnt/genome/$(echo ${ANNOTATION##*/})"
DMOUNT="-v $INDIR:/mnt/data -v $IN:/mnt/$(echo ${IN##*/}) -v $OUTDIR:/mnt/out/$(echo ${OUTDIR##*/}) -v $STARINDEX:/mnt/genome/$(echo ${STARINDEX##*/}) -v $GENOMEDIR:/mnt/genome/$(echo ${GENOMEDIR##*/}) -v $ANNOTATION:/mnt/genome/$(echo ${ANNOTATION##*/})"
if [ "$NETMHCPAN" == "false" ]; then
:
else
SMOUNT=$SMOUNT",$NETMHCPAN:/usr/local/bin/source/$(echo ${NETMHCPAN##*/})"
DMOUNT=$DMOUNT" -v $NETMHCPAN:/usr/local/bin/source/$(echo ${NETMHCPAN##*/})"
fi
IN="/mnt/$(echo ${IN##*/})"
fi
if [ "$READ1" != "" ]; then
SMOUNT="-B $READ1:/mnt/data/$(echo ${READ1##*/}),$OUTDIR:/mnt/out/$(echo ${OUTDIR##*/}),$STARINDEX:/mnt/genome/$(echo ${STARINDEX##*/}),$GENOMEDIR:/mnt/genome/$(echo ${GENOMEDIR##*/}),$ANNOTATION:/mnt/genome/$(echo ${ANNOTATION##*/})"
DMOUNT="-v $READ1:/mnt/data/$(echo ${READ1##*/}) -v $OUTDIR:/mnt/out/$(echo ${OUTDIR##*/}) -v $STARINDEX:/mnt/genome/$(echo ${STARINDEX##*/}) -v $GENOMEDIR:/mnt/genome/$(echo ${GENOMEDIR##*/}) -v $ANNOTATION:/mnt/genome/$(echo ${ANNOTATION##*/})"
if [ "$NETMHCPAN" == "false" ]; then
:
else
SMOUNT=$SMOUNT",$NETMHCPAN:/usr/local/bin/source/$(echo ${NETMHCPAN##*/})"
DMOUNT=$DMOUNT" -v $NETMHCPAN:/usr/local/bin/source/$(echo ${NETMHCPAN##*/})"
fi
fi
if [ "$READ2" != "" ]; then
SMOUNT=$SMOUNT",$READ2:/mnt/data/$(echo ${READ2##*/})"
DMOUNT=$DMOUNT" -v $READ2:/mnt/data/$(echo ${READ2##*/})"
READ2="/mnt/data/$(echo ${READ2##*/})"
fi
mkdir -p $OUTDIR
REALOUT=$OUTDIR
OUTDIR="/mnt/out/$(echo ${OUTDIR##*/})"
STARINDEX="/mnt/genome/$(echo ${STARINDEX##*/})"
GENOMEDIR="/mnt/genome/$(echo ${GENOMEDIR##*/})"
ANNOTATION="/mnt/genome/$(echo ${ANNOTATION##*/})"
READ1="/mnt/data/$(echo ${READ1##*/})"
if [ "$NETMHCPAN" == "false" ]; then
:
else
NETMHCPAN="/usr/local/bin/source/$(echo ${NETMHCPAN##*/})"
fi
## Check for Docker/singularity installation and launch
if [ "$IMAGE" == "docker" ]; then
if [ -x "$(command -v docker)" ]; then
if [ "$IN" != "" ]; then
docker run -rm $DMOUNT icbi/neofuse NeoFuse_multi -i $IN -o $OUTDIR -m $PEPMIN -M $PEPMAX -n $CORES -t $THRESHOLD -T $RANK -c $CONF -s $STARINDEX -g $GENOMEDIR -a $ANNOTATION -N $NETMHCPAN -l $RAMLIMIT -r $REALOUT
elif [ "$READ1" != "" ]; then
if [ "$READ2" == "" ]; then
docker run -rm $DMOUNT icbi/neofuse NeoFuse_single -1 $READ1 -d $ID -o $OUTDIR -m $PEPMIN -M $PEPMAX -n $CORES -t $THRESHOLD -T $RANK -c $CONF -s $STARINDEX -g $GENOMEDIR -a $ANNOTATION -N $NETMHCPAN -l $RAMLIMIT -r $REALOUT
else
docker run -rm $DMOUNT icbi/neofuse NeoFuse_single -1 $READ1 -2 $READ2 -d $ID -o $OUTDIR -m $PEPMIN -M $PEPMAX -n $CORES -t $THRESHOLD -T $RANK -c $CONF -s $STARINDEX -g $GENOMEDIR -a $ANNOTATION -N $NETMHCPAN -l $RAMLIMIT -r $REALOUT
fi
else
echo "Invalid arguments"
echo "Please check your input files"
echo "Exiting ..."
rm $IN
exit 1
fi
else
echo "No Docker instalation found on the machine"
echo "Install Docker and try again"
echo "Exiting ..."
rm $IN
exit 1
fi
elif [ "$IMAGE" == "singularity" ]; then
if [ -x "$(command -v singularity)" ]; then
if [ ! -e $DIR/NeoFuse.sif ]; then
echo "No NeoFuse singularity image found locally"
echo 'Try running: $ NeoFuse -B --singularity'
exit 1
fi
if [ "$IN" != "" ]; then
singularity exec $SMOUNT $DIR"/NeoFuse.sif" NeoFuse_multi -i $IN -o $OUTDIR -m $PEPMIN -M $PEPMAX -n $CORES -t $THRESHOLD -T $RANK -c $CONF -s $STARINDEX -g $GENOMEDIR -a $ANNOTATION -N $NETMHCPAN -l $RAMLIMIT -r $REALOUT
elif [ "$READ1" != "" ]; then
if [ "$READ2" == "" ]; then
singularity exec $SMOUNT $DIR"/NeoFuse.sif" NeoFuse_single -1 $READ1 -d $ID -o $OUTDIR -m $PEPMIN -M $PEPMAX -n $CORES -t $THRESHOLD -T $RANK -c $CONF -s $STARINDEX -g $GENOMEDIR -a $ANNOTATION -N $NETMHCPAN -l $RAMLIMIT -r $REALOUT
else
singularity exec $SMOUNT $DIR"/NeoFuse.sif" NeoFuse_single -1 $READ1 -2 $READ2 -d $ID -o $OUTDIR -m $PEPMIN -M $PEPMAX -n $CORES -T $RANK -t $THRESHOLD -c $CONF -s $STARINDEX -g $GENOMEDIR -a $ANNOTATION -N $NETMHCPAN -l $RAMLIMIT -r $REALOUT
fi
else
echo "Invalid arguments"
echo "Please check your input files"
echo "Exiting ..."
rm $IN
exit 1
fi
else
echo "No singularity instalation found on the machine"
echo "Install singularity and try again"
echo "Exiting ..."
rm $IN
exit 1
fi
elif [ "$IMAGE" == "" ]; then
:
else
echo "Invalid paramater: accepted arguments are --docker or --singularity"
echo "Exiting ..."
rm $IN
exit 1
fi
else
# Check for multiple or single sample(s) - call the appropriate script
# if [ "$IN" != "" ]; then
# bash $DIR"/source/"NeoFuse_multi.sh -i $IN -o $OUTDIR -m $PEPMIN -M $PEPMAX -n $CORES -t $THRESHOLD -T $RANK -c $CONF -s $STARINDEX -g $GENOMEDIR -a $ANNOTATION -N $NETMHCPAN
# elif [ "$READ1" != "" ]; then
# bash $DIR"/source/"NeoFuse_single.sh -1 $READ1 -2 $READ2 -d $ID -o $OUTDIR -m $PEPMIN -M $PEPMAX -n $CORES -t $THRESHOLD -T $RANK -c $CONF -s $STARINDEX -g $GENOMEDIR -a $ANNOTATION -N $NETMHCPAN
# else
# echo "Invalid arguments"
# echo "Please check your input files"
# echo "Exiting ..."
# exit 1
# fi
echo "Missing argument: '--docker' or '--singularity'"
echo "Exiting ..."
exit 1
fi
elif [ "$BUILD" == "true" ]; then
# Get the source dir
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE is a relative symlink, resolve it relative to the path where the symlink file is located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
if [ "$IMAGE" == "docker" ]; then
echo "Pulling NeoFuse Docker image from icbi repository"
docker pull icbi/neofuse
elif [ "$IMAGE" == "singularity" ]; then
echo "Building NeoFuse Singularity image"
singularity build $DIR"/NeoFuse.sif" docker://icbi/neofuse
else
echo "You must specify '--docker' or '--singularity'"
echo "Exiting ..."
exit 1
fi
fi