-
Notifications
You must be signed in to change notification settings - Fork 0
/
submit_snakemake.sh
executable file
·89 lines (79 loc) · 3.24 KB
/
submit_snakemake.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
#!/bin/sh
#PBS -N ngs-pipeline
#
# Author: Rajesh Patidar
#
# Usually slurm can translate the PBS varibles so no need to initialize the sbatch variables.
#set -eo pipefail
module load snakemake/5.24.1
if [[ $time == 'd' ]]; then
export TIME="20160415"
elif [[ $time == 'p' ]]; then
export TIME=$(date +"%Y%m%d")
else
export TIME=$time
# echo -e "Can not run without knowing which mode you would like to set time up\n";
# exit;
fi
if [[ ! -z $ngs ]]; then
export NGS_PIPELINE=$ngs
fi
if [[ ! -z $dataDir ]]; then
export DATA_DIR=$dataDir
fi
if [[ ! -z $workDir ]]; then
export WORK_DIR=$workDir
SAM_CONFIG=$WORK_DIR/samplesheet.json
fi
## for samplesheet
if [[ $sheet == 'samplesheet.json' ]]; then
SAM_CONFIG=$WORK_DIR/samplesheet.json
else
SAM_CONFIG=$sheet
fi
sheet_name=`basename $SAM_CONFIG .json`
export SAMPLESHEET="$sheet_name"
export CLUSTER_CONF="$cluster_conf"
#NOW=$(date +"%Y%m%d_%H%M%S")
NOW=$runTime
#export TIME=$(date +"%Y%m%d%H")
export TMP="$NOW"
if [[ `hostname` =~ "cn" ]] || [ `hostname` == 'biowulf.nih.gov' ]; then
#module load snakemake/3.5.5.nl
export HOST="biowulf.nih.gov"
elif [[ `hostname` =~ "tghighmem" ]] || [[ `hostname` =~ "tgcompute" ]] || [ `hostname` == 'login01' ] ; then
#module load snakemake/3.5.5
export HOST="login01"
else
echo -e "Host `hostname` is not recognized\n"
echo -e "This pipeline is customized to run on biowulf.nih.gov or TGen Cluster @ KhanLab\n";
echo -e "If you would like to use it on another system, you have to change config/config_cluster.json and some hardcoded system dependencies\n";
exit;
fi
cd $WORK_DIR
if [ ! -d log ]; then
mkdir log
fi
export ACT_DIR="/Actionable/"
SNAKEFILE=$NGS_PIPELINE/ngs_pipeline.rules
cmd="--directory $WORK_DIR --snakefile $SNAKEFILE --configfile $SAM_CONFIG --jobscript $NGS_PIPELINE/scripts/jobscript.sh --jobname {params.rulename}.{jobid} --nolock --latency-wait 180 --ri -k -p -r -j 3000 -T 1 --resources DeFuse=25 --resources SIFT=8 --stats ngs_pipeline_${sheet_name}_${NOW}.stats -R RNASeq -R split_vcf "
#cmd="--directory $WORK_DIR --snakefile $SNAKEFILE --configfile $SAM_CONFIG --jobscript $NGS_PIPELINE/scripts/jobscript.sh --jobname {params.rulename}.{jobid} --nolock --ri -k -p -T -r -j 3000 --resources DeFuse=25 --resources SIFT=8 --stats ngs_pipeline_${sheet_name}_${NOW}.stats -R RNASeq -O MergeFQ Khanlab_Pipeline RNASeq"
umask 022
if [ $HOST == 'biowulf.nih.gov' ]; then
echo "Host identified as $HOST"
echo "Variables are $cmd"
snakemake $cmd --cluster "sbatch -o log/{params.rulename}.%j.o -e log/{params.rulename}.%j.e {params.batch}" >& ngs_pipeline_${sheet_name}_${NOW}.log
elif [ $HOST == 'login01' ]; then
echo "Host identified as $HOST"
echo "Variables are $cmd"
snakemake $cmd --cluster "sbatchT -o log/{params.rulename}.%j.o -e log/{params.rulename}.%j.e {params.batch}" >& ngs_pipeline_${sheet_name}_${NOW}.log
rm -rf /projects/scratch/ngs_pipeline_${sheet_name}_${NOW}_*
fi
if [ -f ngs_pipeline_${sheet_name}_${NOW}.stats ]; then
python $NGS_PIPELINE/scripts/stats2Table.py ngs_pipeline_${sheet_name}_${NOW}.stats >ngs_pipeline_${sheet_name}_${NOW}.stats.txt
fi
if [ -s ngs_pipeline_${sheet_name}_${NOW}.stats.txt ]; then
echo "No job took significant time"
else
rm -rf ngs_pipeline_${sheet_name}_${NOW}.stats.txt
fi