wrapper_expansionhunter.sh 2.47 KB
Newer Older
1 2 3 4 5 6 7
#! /bin/sh

### ASDP PIPELINE ###
## wrapper_expansionhunter.sh
## Version : 0.0.1
## Licence : FIXME
## Description : a wrapper for qsubing ExpansionHunter script for STR detection
8
## Usage : qsub -pe smp 1 -v INPUTFILE=<path to the bam file>,OUTPUTPREFIX=<output prefix>,[LOGFILE=<path to the log file>] wrapper_expansionhunter.sh
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
## Output : FIXME
## Requirements : FIXME

## Author : anne-sophie.denomme-pichon@u-bourgogne.fr
## Creation Date : 20191102
## last revision date : 20191102
## Known bugs : None


# Log file path option
if [ -z "$LOGFILE" ]
then
    LOGFILE=expansionhunter.$(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
32
    echo "Input file '$INPUTFILE' does not exist"
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
    echo "$(date +"%F_%H-%M-%S"): END"
    touch expansionhunter.failed
    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"
    touch expansionhunter.failed
    exit 1
fi

# Create .bam and .bai symbolic links
TMPDIR="$(mktemp -d)"
49
ln -s "$INPUTFILE" "$TMPDIR/$(basename "$INPUTFILE")"
50 51 52 53
ln -s "$(echo "$INPUTFILE" | sed 's/\.bam$/.bai/')" "$TMPDIR/$(basename "$INPUTFILE").bai"

# Launch script command and check exit code
echo "command : /work/gad/shared/bin/expansionhunter/ExpansionHunter-v3.1.2-linux_x86_64/bin/ExpansionHunter \
54
    --reads "$TMPDIR/$(basename "$INPUTFILE")" \
55 56
    --reference /work/gad/shared/pipeline/hg19/index/hg19_essential.fa \
    --variant-catalog /work/gad/shared/bin/expansionhunter/ExpansionHunter-v3.1.2-linux_x86_64/variant_catalog/hg19/variant_catalog.json \
57
    --output-prefix $OUTPUTPREFIX"
58
/work/gad/shared/bin/expansionhunter/ExpansionHunter-v3.1.2-linux_x86_64/bin/ExpansionHunter \
59
    --reads "$TMPDIR/$(basename "$INPUTFILE")" \
60 61 62 63 64 65 66
    --reference /work/gad/shared/pipeline/hg19/index/hg19_essential.fa \
    --variant-catalog /work/gad/shared/bin/expansionhunter/ExpansionHunter-v3.1.2-linux_x86_64/variant_catalog/hg19/variant_catalog.json \
    --output-prefix "$OUTPUTPREFIX"

expansionhunter_exitcode=$?

# Remove .bam and .bai symbolic links
67
rm "$TMPDIR/$(basename "$INPUTFILE")"
68 69 70 71 72 73 74 75 76 77 78 79
rm "$TMPDIR/$(basename "$INPUTFILE").bai"
rmdir "$TMPDIR"

echo "expansionhunter exit code : $expansionhunter_exitcode"
if [ $expansionhunter_exitcode != 0 ]
then
    echo "$(date +"%F_%H-%M-%S"): END"
    touch expansionhunter.failed
    exit 1
fi

echo "$(date +"%F_%H-%M-%S"): END"