-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_all_QTLs_parallel.sh
executable file
·76 lines (60 loc) · 2.48 KB
/
run_all_QTLs_parallel.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
# do all QTLs from list of config files
# send off separate snakemake job to HPC
# this will allow me to run all analyses in parallel
script=~/bin/snakejob_HPC
# use bash getopt to use short flags
config='config.yaml'
snakefile='Snakefile'
dryrun=""
mode="eQTL"
print_usage() {
printf "Usage: ./run_all_QTLs.sh [-h] [-c] config list [-s] Snakefile\nOptions:\n\t-c path to config file; OR path to file listing paths to config files\n\t-s Snakefile\n\t-n dry run mode\n\t-m mode [eQTL/sQTL]\n"
}
while getopts 'c:s:m:nh' flag; do
case "${flag}" in
c) configList="${OPTARG}" ;;
s) snakefile="${OPTARG}" ;;
m) mode="${OPTARG}" ;;
n) dryrun="-n" ;;
h) print_usage
exit 1 ;;
esac
done
echo config list used is $configList
echo snakefile used is $snakefile
echo mode is $mode
if [ ! -z "$dryrun" ];then
echo "dry run mode"
fi
if [ ! -e $configList ]; then
echo "error: config file does not exist"
exit 0
fi
if [ ! -e $snakefile ]; then
echo "error: snakefile does not exist"
exit 0
fi
# CONFIG can be either a file containing a list of configs or just a single config.yaml
#conda activate snakemake
if grep -q "yaml" <<< "$configList"; then
echo using $configList
configLabel=$(basename ${configList%_config.yaml})
if [ $mode == "eQTL" ]; then
bsub -J eQTL_${configList} -P acc_als-omics -W 24:00 -n 1 -q premium -o cluster/eQTL_${configLabel}.stdout -e cluster/eQTL_${configLabel}.stderr -L /bin/bash "sh $script -s Snakefile -c $configList -m eQTL"
fi
if [ $mode == "sQTL" ]; then
bsub -J sQTL_${configList} -P acc_als-omics -W 24:00 -n 1 -q premium -o cluster/sQTL_${configLabel}.stdout -e cluster/sQTL_${configLabel}.stderr -L /bin/bash "sh $script -s Snakefile -c $configList -m sQTL"
fi
exit 0
elif [ -f $configList ]; then
for config in $(cat $configList);do
echo $config
configLabel=$(basename ${config%_config.yaml})
if [ $mode == "eQTL" ]; then
bsub -J eQTL_${configLabel} -P acc_als-omics -W 24:00 -n 1 -q premium -o cluster/eQTL_${configLabel}.stdout -e cluster/eQTL_${configLabel}.stderr -L /bin/bash "sh $script -s Snakefile -c $config -m eQTL"
fi
if [ $mode == "sQTL" ]; then
bsub -J sQTL_${configLabel} -P acc_als-omics -W 24:00 -n 1 -q premium -o cluster/sQTL_${configLabel}.stdout -e cluster/sQTL_${configLabel}.stderr -L /bin/bash "sh $script -s Snakefile -c $config -m sQTL"
fi
done
fi