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
#! /bin/sh
### ASDP PIPELINE ###
## Version: 0.0.1
## Licence: AGPLv3
## Author: anne-sophie.denomme-pichon@u-bourgogne.fr
## Description: a wrapper for qsubing ExpansionHunter denovo script for STR detection
## Usage: qsub -pe smp 1 -v INPUTFILE=<path to the bam file>,OUTPUTPREFIX=<output prefix>,[LOGFILE=<path to the log file>] wrapper_ehdn_profile.sh
# Source the configuration file
. "$(dirname "$0")/config.sh"
# Log file path option
if [ -z "$LOGFILE" ]
then
LOGFILE=ehdn.$(date +"%F_%H-%M-%S").log
fi
# Logging
exec 1>> "$LOGFILE" 2>&1
echo "$(date +"%F_%H-%M-%S"): START"
# Check if input file exists
if [ ! -f "$INPUTFILE" ]
then
echo "Input file '$INPUTFILE' does not exist"
echo "$(date +"%F_%H-%M-%S"): END"
exit 1
fi
# Check if output prefix is specified
if [ -z "$OUTPUTPREFIX" ]
then
echo "Output prefix is not specified"
echo "$(date +"%F_%H-%M-%S"): END"
exit 1
fi
# Create .bam and .bai symbolic links (EHDN expects .bam.bai)
TMPDIR="$(mktemp -d)"
ln -s "$INPUTFILE" "$TMPDIR/$(basename "$INPUTFILE")"
if [ -f "$INPUTFILE.bai" ]
then
ln -s "$INPUTFILE.bai" "$TMPDIR/$(basename "$INPUTFILE").bai"
else
ln -s "$(echo "$INPUTFILE" | sed 's/\.bam$/.bai/')" "$TMPDIR/$(basename "$INPUTFILE").bai"
fi
# Launch script command and check exit code
echo "command : $EHDN profile \
--reads $TMPDIR/$(basename "$INPUTFILE") \
--reference $REF \
--output-prefix $OUTPUTPREFIX \
--min-anchor-mapq 50 \
--max-irr-mapq 40"
"$EHDN" profile \
--reads "$TMPDIR/$(basename "$INPUTFILE")" \
--reference "$REF" \
--output-prefix "$OUTPUTPREFIX" \
--min-anchor-mapq 50 \
--max-irr-mapq 40
ehdn_exitcode=$?
# Remove .bam and .bai symbolic links
rm "$TMPDIR/$(basename "$INPUTFILE")"
rm "$TMPDIR/$(basename "$INPUTFILE").bai"
rmdir "$TMPDIR"
echo "ehdn exit code : $ehdn_exitcode"
if [ $ehdn_exitcode != 0 ]
then
echo "$(date +"%F_%H-%M-%S"): END"
exit 1
fi
echo "$(date +"%F_%H-%M-%S"): END"