-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpipeline
executable file
·97 lines (91 loc) · 4.87 KB
/
pipeline
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
#!/usr/bin/env bash
#
# Copyright © 2022 Ye Chang yech1990@gmail.com
# Distributed under terms of the GNU license.
#
# Created: 2022-04-04 18:49
logo="
\033[1;34m ███╗ ███╗ ██████╗ █████╗ ███████╗ █████╗ ██████╗███████╗███████╗ ██████╗ \033[0m
\033[1;34m ████╗ ████║██╔════╝ ██╔══██╗ ██╔════╝██╔══██╗██╔════╝██╔════╝██╔════╝██╔═══██╗ \033[0m
\033[1;34m ██╔████╔██║███████╗ ███████║█████╗███████╗███████║██║ ███████╗█████╗ ██║ ██║ \033[0m
\033[1;34m ██║╚██╔╝██║██╔═══██╗██╔══██║╚════╝╚════██║██╔══██║██║ ╚════██║██╔══╝ ██║▄▄ ██║ \033[0m
\033[1;34m ██║ ╚═╝ ██║╚██████╔╝██║ ██║ ███████║██║ ██║╚██████╗███████║███████╗╚██████╔╝ \033[0m
\033[1;34m ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚═╝ ╚═╝ ╚═════╝╚══════╝╚══════╝ ╚══▀▀═╝ \033[0m
\033[1;34m \033[0m
\033[1;34m ██████╗ ██╗██████╗ ███████╗██╗ ██╗███╗ ██╗███████╗ \033[0m
\033[1;34m ██╔══██╗██║██╔══██╗██╔════╝██║ ██║████╗ ██║██╔════╝ \033[0m
\033[1;34m ██████╔╝██║██████╔╝█████╗ ██║ ██║██╔██╗ ██║█████╗ \033[0m
\033[1;34m ██╔═══╝ ██║██╔═══╝ ██╔══╝ ██║ ██║██║╚██╗██║██╔══╝ \033[0m
\033[1;34m ██║ ██║██║ ███████╗███████╗██║██║ ╚████║███████╗ \033[0m
\033[1;34m ╚═╝ ╚═╝╚═╝ ╚══════╝╚══════╝╚═╝╚═╝ ╚═══╝╚══════╝ \033[0m
"
printf "$logo\n"
# Set default values
snake="/opt/pipeline/Snakefile"
conf="data.yaml"
POSITIONAL_ARGS=()
while [[ $# -gt 0 ]]; do
case $1 in
-j | --jobs | --cores)
cores_cmd="$2"
shift
shift
;;
-c | --conf)
conf="$2"
shift
shift
;;
-s | --snake)
snake="$2"
shift
shift
;;
*)
POSITIONAL_ARGS+=("$1")
shift
;;
esac
done
set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters
if [ ! -f "${conf}" ]; then
echo "${conf} can not be found!"
exit 1
fi
if [ -z "${cores_cmd}" ]; then
cores_conf=$(python -c 'import yaml, sys;print(yaml.safe_load(open(sys.argv[1],"r")).get("cores",""))' ${conf})
if [ -z "${cores_conf}" ]; then
cores=48
else
cores=${cores_conf}
fi
else
cores=${cores_cmd}
fi
panoptes --ip 0.0.0.0 --port 5000 1>/dev/null 2>/dev/null &
export PANOPTES_PID=$!
# echo "PANOPTES_PID=$PANOPTES_PID"
trap 'kill -s SIGKILL $PANOPTES_PID' EXIT
while true; do
if curl -s http://127.0.0.1:5000/api/service-info | grep -q running; then
echo -e "\033[0;32mPLEASE MONITOR THE PIPELINE AT\033[0m http://127.0.0.1:5000"
echo -e "\033[0;32mIf you are running this pipeline on a remote server, \033[0m"
echo -e "\033[0;32mreplace the IP adress with server IP, or set ssh proxy on you local machine.\033[0m"
LOGFILE="SACSEQ_LOG_$(date +"%F-%H%M%S").txt"
echo -e "\033[0;32mREAD DEBUG LOG AT\033[0m ${LOGFILE}"
printf "\033[0;33m Analyzing...\033[0m"
snakemake --wms-monitor http://127.0.0.1:5000 --rerun-incomplete --jobs ${cores} --snakefile ${snake} --configfiles /opt/pipeline/config.yaml ${conf} $@ 1>${LOGFILE} 2>${LOGFILE}
if [ $? -eq 0 ]; then
printf "\033[0;33m\b\b\b\b\b\b\b\b\b\b\b\b\b\033[0m"
printf "\033[0;32m\xE2\x9C\x94\033[0m Successfully finished all jobs.\n"
else
printf "\033[0;33m\b\b\b\b\b\b\b\b\b\b\b\b\b\033[0m"
printf "\033[0;31m\xE2\x9D\x8C\033[0m Jobs exit with error!\n"
fi
# rm .panoptes.db
kill -s SIGKILL $PANOPTES_PID
break
fi
echo "$(date) waiting for service to start..."
sleep 2
done