-
Notifications
You must be signed in to change notification settings - Fork 1
/
lsfTophat
executable file
·96 lines (84 loc) · 2.26 KB
/
lsfTophat
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
#!/bin/bash
set -e -o pipefail
# Tommaso Leonardi, tl344@ebi.ac.uk
# This script allows to run Tophat on an LSF system with a shared filesystem
# It runs Tophat on a node using a temporary local folder to store output.
# Upon completion, it copies the output back to a user-specified path
usage()
{
cat << EOF
usage: $0 [-dnh] -p <params list> -o <out folder> -i <genome index> -f <fastq> -t <tophat binary>
This script makes your life easier when you have to run Tophat over LSF.
Tophat's output is stored in a temporary directory on the node (under /tmp)
and upon colpletion the results are copied back to an output folder
specified with the -o option.
If the -n option is specified the results are directly stored in the output
directory rather than in /tmp. This is useful if the tophat tmp data exceeds
the size available on /tmp.
OPTIONS:
-h Show this message
-p List of parameters to be passed to Tophat
-o Path where to save Tophat output (it's created if it doesn't exist)
-i Path to genome index
-f Path to Fastq file
-t Path to Tophat binary
-d Dry run
-n Write directly to the folder specified by -o
EOF
}
while getopts “hnp:o:i:f:t:d” OPTION
do
case $OPTION in
h)
usage
exit 1
;;
p)
PARAMS=$OPTARG
;;
o)
OUT=$OPTARG
;;
i)
INDEX=$OPTARG
;;
f)
FASTQ=$OPTARG
;;
t)
TOPHAT=$OPTARG
;;
d)
DRY=1
;;
n)
NOTMP=1
esac
done
if [ -z "$PARAMS" ] || [ -z "$OUT" ] || [ -z "$INDEX" ] || [ -z "$FASTQ" ] || [ -z "$TOPHAT" ]; then
usage;
exit 1;
fi
if [ -d "$OUT" ]; then
echo "Error: Output directory $OUT already exists";
exit 1;
fi
if [ -z "$NOTMP" ]; then
TMP=$(mktemp -d --tmpdir=/tmp)
else
TMP=$OUT
mkdir -p $TMP
fi
echo -e "$0: Running Tophat with :\n$TOPHAT $PARAMS -o $TMP $INDEX $FASTQ" | tee $TMP/tophat_command.txt;
if [ -z "$DRY" ]; then
$TOPHAT $PARAMS -o $TMP $INDEX $FASTQ;
fi
if [ -z "$NOTMP" ]; then
echo "$0: Creating output directory $OUT"
mkdir -p $OUT
echo "$0: Copying Tophat results to $OUT"
cp -R $TMP/* $OUT
echo "$0: Cleaning up $TMP"
rm -rf $TMP
fi
echo "$0: Done"