forked from AgResearch/wgs_prism
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautostart_wgs_qc
executable file
·144 lines (123 loc) · 3.64 KB
/
autostart_wgs_qc
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
#!/bin/sh
POLL_INTERVAL=900 # seconds - i.e. 15 minutes
function read_answer_with_default() {
read answer
if [ -z "$answer" ]; then
answer=$@
fi
}
function get_opts() {
help_text="
usage example (currently run in a screen session) :\n
autostart_wgs_qc 230307_A01439_0152_AHVWF2DRX2 | tee /dataset/2024_illumina_sequencing_d/scratch/postprocessing/autostart_logs/230623_A01439_0188_AHFFGNDRX3.log \n
"
while getopts ":h" opt; do
case $opt in
h)
echo -e $help_text
exit 0
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
shift $((OPTIND-1))
if [ -z "$1" ]; then
echo "must supply a run name "
exit 1
fi
ARGRUN=$1
get_run_folder
}
function get_pipeline() {
wgs_version=$1
RUN=$2
export WGS_PRISM_BIN=~/wgs_prism2
cd $WGS_PRISM_BIN
echo "running wgs qc pipeline version $wgs_version"
is_alpha=`echo $wgs_version | grep alpha`
if [ $is_alpha ]; then
#git checkout -q $wgs_version
echo
if [ $? != 0 ]; then
echo "unable to checkout pipeline version $wgs_version"
exit 1
fi
echo "running exec ./_run_wgs_qc -r $RUN $wgs_version "
#send_mail
exec ./_run_wgs_qc -r $RUN $wgs_version
else
echo "(no checkout for alpha versions, just running in current branch)"
echo "running exec ./_run_wgs_qc -r $RUN $wgs_version "
send_mail
exec ./_run_wgs_qc -r $RUN $wgs_version
fi
}
function send_mail() {
echo "sending mail to vanstijnt , mccullocha, bairdh, perrybe, andersonr, andrewsa, henryh, frenchm, hicklandm "
echo "(please check results carefully, non-GBS flowcells often need custom processing, mostly involving customising the sample-sheet)" | mutt -s "FYI - looks like upload of (non GBS) $RUN is complete so auto-starting processing" vanstijnt , mccullocha, bairdh, perrybe, andersonr, andrewsa, henryh, frenchm, hicklandm
}
function get_run_folder() {
#try novaseq
RUN_FOLDER=/dataset/2024_illumina_sequencing_d/active/$ARGRUN
if [ ! -d $RUN_FOLDER ]; then
# try iseq
RUN_FOLDER=/dataset/2024_illumina_sequencing_d/active/$ARGRUN
if [ ! -d $RUN_FOLDER ]; then
# try miseq
RUN_FOLDER=/dataset/2024_illumina_sequencing_d/active/$ARGRUN
if [ ! -d $RUN_FOLDER ]; then
echo "Sorry could not find run folder for $ARGRUN ! - giving up"
exit 1
fi
fi
fi
}
function get_landmark() {
RUN=$1
landmark=""
if [ -f $RUN_FOLDER/RTAComplete.txt ]; then
landmark=$RUN_FOLDER/RTAComplete.txt
fi
}
function get_digest() {
RUN=$1
digest=`ls -lR $RUN_FOLDER/ | md5sum -b `
echo $digest
}
function poll_for() {
RUN=$1
# polls for the run landmark
poll_count=0
while [ 1 ]; do
get_landmark $RUN
get_digest $RUN
if [ ! -z "$landmark" ]; then
if [ $poll_count == 0 ]; then
echo "*** warning - landmark $landmark is already there ! *** "
echo "(final digest : "
get_digest $RUN
echo ")"
get_pipeline 1.0.4alpha $RUN
else
echo "found landmark ($landmark) - starting processing"
echo "(final digest : "
get_digest $RUN
echo ")"
get_pipeline 1.0.4alpha $RUN
fi
else
let poll_count=${poll_count}+1
echo "sleeping for $POLL_INTERVAL (poll count = $poll_count )"
sleep $POLL_INTERVAL
fi
done
}
get_opts "$@"
poll_for $ARGRUN