wrapper_stretch.sh 1.88 KB
Newer Older
1 2 3
#! /bin/sh

### ASDP PIPELINE ###
4
## wrapper_stretch.sh
5 6
## Version : 0.0.1
## Licence : FIXME
7 8
## Description : a wrapper for qsubing STRetch 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_stretch.sh
9 10 11 12
## Output : FIXME
## Requirements : FIXME

## Author : anne-sophie.denomme-pichon@u-bourgogne.fr
13 14
## Creation Date : 20191118
## last revision date : 20191118
15 16 17 18 19 20
## Known bugs : None


# Log file path option
if [ -z "$LOGFILE" ]
then
21
    LOGFILE=stretch.$(date +"%F_%H-%M-%S").log
22 23 24 25 26 27 28 29 30 31 32 33
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"
34
    touch stretch.failed
35 36 37 38 39 40 41 42
    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"
43
    touch stretch.failed
44 45 46 47
    exit 1
fi

# Launch script command and check exit code
48 49
echo "cd "$OUTPUTDIR"
/work/gad/shared/bin/stretch/STRetch-20190602/tools/bin/bpipe \
50
    run -p input_regions=/work/gad/shared/bin/stretch/STRetch-20190602/reference-data/hg19.STR_disease_loci.bed \
51 52
    /work/gad/shared/bin/stretch/STRetch-20190602/pipelines/STRetch_wgs_bam_pipeline.groovy \
    "$INPUTFILE""
53

54 55
cd "$OUTPUTDIR"
/work/gad/shared/bin/stretch/STRetch-20190602/tools/bin/bpipe \
56
    run -p input_regions=/work/gad/shared/bin/stretch/STRetch-20190602/reference-data/hg19.STR_disease_loci.bed \
57 58
    /work/gad/shared/bin/stretch/STRetch-20190602/pipelines/STRetch_wgs_bam_pipeline.groovy \
    "$INPUTFILE"
59

60
stretch_exitcode=$?
61

62 63
echo "stretch exit code : $stretch_exitcode"
if [ $stretch_exitcode != 0 ]
64 65
then
    echo "$(date +"%F_%H-%M-%S"): END"
66
    touch stretch.failed
67 68 69 70
    exit 1
fi

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