-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerateslurm_quantify_bins.sh
executable file
·162 lines (132 loc) · 4.2 KB
/
generateslurm_quantify_bins.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/bin/bash
set -e
help_message () {
echo ""
echo "Usage: generateslurm_quantify_bins.sh -sample_tsv /path/to/samplesheet -drep /path/to/drep/genome -o /path/to/out --bowtie_index_name idx_nbame"
echo "Options:"
echo ""
echo " -sample_tsv STR path to sample tsv (5 columns: sample name<tab>fastq1 path<tab>fastq2 path<tab>fastq1 single path<tab>fastq2 single path). Generated in preprocess step."
echo " -drep STR dereplicated genome path (drep output directory). See dereplicate_bins.dRep.sh for more information."
echo " -o STR path to output dir"
echo ""
echo "Slurm options:"
echo " --slurm_alloc STR slurm allocation (default def-ilafores)"
echo " --slurm_log STR slurm log file output directory (default to output_dir/logs)"
echo " --slurm_email \"[email protected]\" Slurm email setting"
echo " --slurm_walltime STR slurm requested walltime (default 24:00:00)"
echo " --slurm_threads INT slurm requested number of threads (default 24)"
echo " --slurm_mem STR slurm requested memory (default 31G)"
echo ""
echo " -h --help Display help"
echo "";
}
export EXE_PATH=$(dirname "$0")
# initialisation
alloc="def-ilafores"
email="false"
walltime="24:00:00"
threads="24"
mem="31G"
log="false"
drep="false"
out="false"
sample_tsv="false"
SHORT_OPTS="ht:drep:o:sample_tsv:"
LONG_OPTS='help,slurm_alloc,slurm_log,slurm_email,slurm_walltime,slurm_threads,slurm_mem'
OPTS=$(getopt -o $SHORT_OPTS --long $LONG_OPTS -- "$@")
# make sure the params are entered correctly
if [ $? -ne 0 ];
then
help_message;
exit 1;
fi
while true; do
# echo "$1 -- $2"
case "$1" in
-h | --help) help_message; exit 1; shift 1;;
--slurm_alloc) alloc=$2; shift 2;;
--slurm_log) log=$2; shift 2;;
--slurm_email) email=$2; shift 2;;
--slurm_walltime) walltime=$2; shift 2;;
--slurm_threads) threads=$2; shift 2;;
--slurm_mem) mem=$2; shift 2;;
-o) out=$2; shift 2;;
-drep) drep=$2; shift 2;;
-sample_tsv) sample_tsv=$2; shift 2;;
--) help_message; exit 1; shift; break ;;
*) break;;
esac
done
echo "## Quantify parameters:"
if [ "$drep" = "false" ]; then
echo "Please provide a drep output output bin path (/path/to/drep/out/dereplicated_genomes)"
help_message; exit 1
else
echo "## Drep path: $sample_tsv"
fi
if [ "$sample_tsv" = "false" ]; then
echo "Please provide a samplesheet path. This sample sheet is generated by preprocess step. TSV columns should be sample_name<tab>/path/to/fastq1<tab>/path/to/fastq2"
help_message; exit 1
else
echo "## Samplesheet path: $sample_tsv"
fi
if [ "$out" = "false" ]; then
echo "Please provide an output path"
help_message; exit 1
else
mkdir -p $out
echo "## Results wil be stored to this path: $out/"
fi
if [ "$log" = "false" ]; then
log=$out/logs
echo "## Slurm output path not specified, will output logs in: $log"
else
echo "## Will output logs in: $log"
fi
mkdir -p $log
echo "## Number of threads: $threads"
echo "outputting annotate slurm script to $out/submit_quantify.slurm.sh"
echo '#!/bin/bash' > $out/submit_quantify.slurm.sh
echo '
#SBATCH --mail-type=END,FAIL
#SBATCH -D '${out}'
#SBATCH -o '${out}'/logs/qunatify-%A.slurm.out
#SBATCH --time='${walltime}'
#SBATCH --mem='${mem}'
#SBATCH -N 1
#SBATCH -n '${threads}'
#SBATCH -A '${alloc}'
#SBATCH -J annotate
' >> $out/submit_quantify.slurm.sh
if [ "$email" != "false" ]; then
echo '
#SBATCH --mail-user='${email}'
' >> $out/submit_quantify.slurm.sh
fi
echo '
echo "loading env"
module load StdEnv/2020 apptainer/1.1.5
if [ -z ${SLURM_TMPDIR+x} ]
then
echo "SLURM_TMPDIR is unset. Not running on compute node"
bash '${EXE_PATH}'/scripts/quantify_bins.salmon.sh \
-t '${threads}' \
-drep '$drep' \
-sample_tsv '$sample_tsv' \
-o '${out}'
else
echo "SLURM_TMPDIR is set to $SLURM_TMPDIR. Running on a compute node!"
bash '${EXE_PATH}'/scripts/quantify_bins.salmon.sh \
-t '${threads}' \
-drep '${drep}' \
-sample_tsv '${sample_tsv}' \
-o '${out}' \
-tmp $SLURM_TMPDIR
fi
' >> $out/submit_quantify.slurm.sh
echo "To run LOCALLY, execute the following command:"
echo "bash ${out}/submit_quantify.slurm.sh"
echo "---- OR -----"
echo "To submit to slurm, execute the following command:"
echo "sbatch ${out}/submit_quantify.slurm.sh"
echo "done!"