-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathautostart_gbs_qc
executable file
·128 lines (111 loc) · 3.54 KB
/
autostart_gbs_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
#!/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="
This is used to auto-start a run. It will poll for a landmark file indicating upload is complete then start the processing\n
\n
usage example (currently run in a screen session) :\n
\n
autostart_gbs_qc 200511_D00390_0545_BHFMY3BCX3 2>&1 | tee /dataset/2024_illumina_sequencing_e/scratch/postprocessing/autostart_logs/200511_D00390_0545_BHFMY3BCX3.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
}
function get_pipeline() {
gbs_version=$1
RUN=$2
export SEQ_PRISMS_BIN=/dataset/gseq_processing/active/bin/gbs_prism/seq_prisms
export GBS_PRISM_BIN=/dataset/gseq_processing/active/bin/gbs_prism
cd $GBS_PRISM_BIN
# (to move to another KGD version, git pull in the KGD folder, and then check out the version you want)
kgd_version=`$GBS_PRISM_BIN/get_kgd_version.sh`
echo "running gbs qc pipeline version $gbs_version (KGD version $kgd_version)"
is_alpha=`echo $gbs_version | grep alpha`
if [ ! $is_alpha ]; then
git checkout -q $gbs_version
if [ $? != 0 ]; then
echo "unable to checkout pipeline version $gbs_version"
exit 1
fi
echo "running exec ./_run_gbs_qc -r $RUN $gbs_version $kgd_version"
send_mail
exec ./_run_gbs_qc -r $RUN $gbs_version $kgd_version
else
echo "(no checkout for alpha versions, just running in current branch)"
echo "running exec ./_run_gbs_qc -r $RUN $gbs_version $kgd_version"
send_mail
exec ./_run_gbs_qc -r $RUN $gbs_version $kgd_version
fi
}
function send_mail() {
echo "sending mail to vanstijnt , mccullocha, bairdh, perrybe, andersonr, andrewsa, henryh, frenchm, hicklandm "
echo "" | mutt -s "FYI - looks like upload of $RUN is complete so auto-starting processing" vanstijnt , mccullocha, bairdh, perrybe, andersonr, andrewsa, henryh, frenchm, hicklandm
}
function get_landmark() {
RUN=$1
landmark=""
if [ -f /dataset/2024_illumina_sequencing_e/active/$RUN/RTAComplete.txt ]; then
landmark=/dataset/2024_illumina_sequencing_e/active/$RUN/RTAComplete.txt
fi
}
function get_digest() {
RUN=$1
digest=`ls -lR /dataset/2024_illumina_sequencing_e/active/$RUN/ | 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