wrapper_create_counts_matrix.sh 2.01 KB
Newer Older
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
#!/bin/ksh

### GAD PIPELINE ###
## wrapper_create_counts_matrix.sh
## Version : 2.4.0
## Description : a wrapper for qsubing create_counts_matrix.py script
## Usage : qsub -pe smp 1 -v INPUTFILE=/path/to/the/list/file>,OUTPUTFILE=</path/to/the/output/file>,[LOGFILE=/path/to/the/log/file],[CONFIGFILE=/path/to/the/config/file] wrapper_create_counts_matrix.sh
## Output : create_counts_matrix.py output
## Requirements : python 2.7

## Author : Emilie.Tisserant@u-bourgogne.fr
## Creation Date : 20170331
## last revision date : 20170331
## Known bugs : None

#$ -q batch
#$ -V


# Log file path option
if [ -z ${LOGFILE} ]
then
    LOGFILE=create_counts_matrix.$(date +"%F_%H-%M-%S").log
fi

# Config file path option
if [ -z ${CONFIGFILE} ]
then
    CONFIGFILE=analysis_config.tsv
fi

PIPELINEBASE=`grep pipelinebase $CONFIGFILE | cut -f2`
PYTHONBIN=`grep pythonbin $CONFIGFILE | cut -f2`

# Logging
exec 1>> $LOGFILE 2>&1
echo "$(date +"%F_%H-%M-%S"): START"

# Check if config file exist
if [ ! -f $CONFIGFILE ]
then
    echo "Config file does not exist"
    echo "$(date +"%F_%H-%M-%S"): END"
    touch create_counts_matrix.failed
    exit 1
fi

# Check if input file exist
if [ ! -f $INPUTFILE ]
then
    echo "Input file does not exist"
    echo "$(date +"%F_%H-%M-%S"): END"
    touch create_counts_matrix.failed
    exit 1
fi

# Check if output file is specified
if [ -z $OUTPUTFILE ]
then
    echo "Output file is not specified"
    echo "$(date +"%F_%H-%M-%S"): END"
    touch create_counts_matrix.failed
    exit 1
fi

# Launch python script command and check exit code
echo "Command: $PYTHONBIN $PIPELINEBASE/common/DE/create_counts_matrix.py -i $INPUTFILE -o $OUTPUTFILE -e $LOGFILE"
$PYTHONBIN $PIPELINEBASE/common/DE/create_counts_matrix.py -i $INPUTFILE -o $OUTPUTFILE -e $LOGFILE
creatematrix_exitcode=$?
echo "create_counts_matrix.py exit code : $creatematrix_exitcode"
if [ $creatematrix_exitcode != 0 ]
then
    echo "$(date +"%F_%H-%M-%S"): END"
    touch create_counts_matrix.failed
    exit 1
fi

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