-
Notifications
You must be signed in to change notification settings - Fork 0
/
duxhund.sh
executable file
·106 lines (93 loc) · 2.75 KB
/
duxhund.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
#!/bin/bash
set -eu
readonly BWA=${BWA:-bwa}
readonly SAMTOOLS=${SAMTOOLS:-samtools}
readonly FUSIONFUSION=${FUSIONFUSION:-fusionfusion}
readonly DUXHUND_JAR=${DUXHUND_JAR:-/opt/duxhund/duxhund.jar}
readonly BWA_OPTS=${BWA_OPTS:-'-t 8 -T 0 -Y'}
readonly SAMTOOLS_OPTS=${SAMTOOLS_OPTS:-'-@ 8'}
readonly FUSIONFUSION_OPTS=${FUSIONFUSION_OPTS:-'--no_blat --grc --genome_id hg38'}
readonly DUXHUND_GENERATE_OPTS=${DUXHUND_GENERATE_OPTS:-'--min-softclip-len 20'}
readonly DUXHUND_FIXUP_OPTS=${DUXHUND_FIXUP_OPTS:-''}
reference=''
masked_reference=''
target=''
r1=''
r2=''
outdir=''
while getopts ":-:" optchr; do
case "$optchr" in
-)
case "$OPTARG" in
reference)
reference="${!OPTIND}"
OPTIND=$((OPTIND + 1))
;;
masked-reference)
masked_reference="${!OPTIND}"
OPTIND=$((OPTIND + 1))
;;
target)
target="${!OPTIND}"
OPTIND=$((OPTIND + 1))
;;
r1)
r1="${!OPTIND}"
OPTIND=$((OPTIND + 1))
;;
r2)
r2="${!OPTIND}"
OPTIND=$((OPTIND + 1))
;;
output)
outdir="${!OPTIND}"
OPTIND=$((OPTIND + 1))
;;
*)
echo "Undefined option: ${!OPTIND}"
exit 1
;;
esac
;;
*)
;;
esac
done
if [ -z $reference ] || [ -z $masked_reference ] || [ -z $target ] || [ -z $r1 ] || [ -z $r2 ] || [ -z $outdir ]; then
echo "Error: Missing required arguments: --reference, --masked-reference, --target, --r1, --r2 or --output"
exit 1
fi
mkdir -p "$outdir"
# shellcheck disable=SC2086
"$BWA" mem $BWA_OPTS -a "$reference" "$r1" "$r2" | "$SAMTOOLS" view $SAMTOOLS_OPTS -b > "$outdir/aligned.bam"
# shellcheck disable=SC2086
java -cp "$DUXHUND_JAR" duxhund.cli generate-fastq \
--input "$outdir/aligned.bam" \
--target "$target" \
--output "$outdir" \
$DUXHUND_GENERATE_OPTS
# shellcheck disable=SC2086
"$BWA" mem $BWA_OPTS -a -p -C "$masked_reference" "$outdir/out.fastq" > "$outdir/realigned.sam"
# shellcheck disable=SC2086
java -cp "$DUXHUND_JAR" duxhund.cli fixup-sam \
--input "$outdir/realigned.sam" \
--saved-seqs "$outdir/saved-seqs.edn" \
--output "$outdir/realigned.fixed.sam" \
$DUXHUND_FIXUP_OPTS
fusion_opts="$FUSIONFUSION_OPTS"
if [ -n "${DEBUG-}" ]; then
fusion_opts="$fusion_opts --debug"
fi
# shellcheck disable=SC2086
"$FUSIONFUSION" $fusion_opts \
--reference_genome "$masked_reference" \
--star "$outdir/realigned.fixed.sam" \
--out "$outdir/fusionfusion"
cp "$outdir/fusionfusion/fusion_fusion.result.txt" "$outdir/result.txt"
if [ -z "${DEBUG-}" ]; then
rm -rf "$outdir/aligned.bam" \
"$outdir/out.fastq" \
"$outdir/saved-seqs.edn" \
"$outdir/realigned.sam" \
"$outdir/fusionfusion"
fi