-
Notifications
You must be signed in to change notification settings - Fork 1
/
update_sifts_via_rsync.sh
executable file
·265 lines (193 loc) · 5.83 KB
/
update_sifts_via_rsync.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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
#!/bin/bash
source ./scripts/env.sh
set -e
MTIME=
FULL=false
ARGV=`getopt --long -o "m:f" "$@"`
eval set -- "$ARGV"
while true ; do
case "$1" in
-m)
MTIME=$2
shift
;;
-f)
FULL=true
;;
*)
break
;;
esac
shift
done
DB_NAME=SIFTS
SRC_DIR=$SIFTS_SPLIT_XML
XML_DIR=$SIFTS_XML
weekday=`date -u +"%w"`
if [ ! -e $XSD2PGSCHEMA ] ; then
./scripts/update_extlibs.sh
fi
if ( [ $weekday -ge 1 ] && [ $weekday -le 4 ] ) || [ ! -d $SRC_DIR ] ; then
if [ -d $PDBML_NOATOM ] || [ -e scripts/default_div_dirs ] ; then
div_dirs=div_dirs
max_connection=$((MAXPROCS > 24 ? 24 : MAXPROCS))
find $PDBML_NOATOM -mindepth 1 -type d | cut -d '/' -f 2 > $div_dirs
if [ ! -s $div_dirs ] ; then
cp scripts/default_div_dirs $div_dirs
fi
rm -f $SRC_DIR/*/.*
cat $div_dirs | sort -R > $div_dirs~
for proc_id in `seq 1 $max_connection` ; do
./scripts/update_sifts_via_rsync_worker.sh -s $SIFTS_SPLIT_XML_URL -d $SRC_DIR -l $div_dirs -n $proc_id"of"$max_connection &
done
wait
rm -f $SRC_DIR/*/.* $div_dirs $div_dirs~
fi
( rsync -a --delete $SIFTS_SPLIT_XML_URL/ $SRC_DIR || rsync -a --delete $SIFTS_SPLIT_XML_URL/ $SRC_DIR || rsync -a --delete $SIFTS_SPLIT_XML_URL/ $SRC_DIR || true )
MD5_DIR=chk_sum_xml_sifts
chk_sum_log=sifts_xml_log
java -classpath $XSD2PGSCHEMA chksumstat --xml $SRC_DIR/[0-9a-z]{2} --xml-file-ext gz --sync $MD5_DIR --update --verbose > $chk_sum_log
if [ $FULL = "true" ] ; then
if [ -d $XML_DIR ] ; then
while read pdb_id ; do
[ -z "$pdb_id" ] || [[ "$pdb_id" =~ ^#.* ]] && continue
rm -f $XML_DIR/$pdb_id.xml
done < $chk_sum_log
fi
if [ -d $PDBML_SIFTS ] ; then
while read pdb_id ; do
[ -z "$pdb_id" ] || [[ "$pdb_id" =~ ^#.* ]] && continue
rm -f $PDBML_SIFTS/${pdb_id:1:2}/$pdb_id-noatom-sifts.xml.gz
done < $chk_sum_log
fi
if [ -d $PDBML_EXT ] ; then
while read pdb_id ; do
[ -z "$pdb_id" ] || [[ "$pdb_id" =~ ^#.* ]] && continue
rm -f $PDBML_EXT/$pdb_id-noatom-ext.xml.gz
done < $chk_sum_log
fi
#if [ -d $VALID_INFO_ALT ] ; then
# while read pdb_id ; do
# [ -z "$pdb_id" ] || [[ "$pdb_id" =~ ^#.* ]] && continue
# rm -f $VALID_INFO_ALT/$pdb_id-validation-alt.xml
# done < $chk_sum_log
#fi
#if [ -d $XML_VALID_ALT ] ; then
# while read pdb_id ; do
# [ -z "$pdb_id" ] || [[ "$pdb_id" =~ ^#.* ]] && continue
# rm -f $XML_VALID_ALT/$pdb_id-validation-alt.xml
# done < $chk_sum_log
#fi
if [ -d $XML_VALID ] ; then
while read pdb_id ; do
[ -z "$pdb_id" ] || [[ "$pdb_id" =~ ^#.* ]] && continue
rm -f $XML_VALID/$pdb_id-validation-full.xml
done < $chk_sum_log
fi
#if [ -d $RDF_VALID_ALT ] ; then
# while read pdb_id ; do
# [ -z "$pdb_id" ] || [[ "$pdb_id" =~ ^#.* ]] && continue
# rm -f $RDF_VALID_ALT/$pdb_id-validation-alt.rdf
# done < $chk_sum_log
#fi
if [ -d $RDF_VALID ] ; then
while read pdb_id ; do
[ -z "$pdb_id" ] || [[ "$pdb_id" =~ ^#.* ]] && continue
rm -f $RDF_VALID/$pdb_id-validation-full.rdf
done < $chk_sum_log
fi
if [ -d $RDF ] ; then
while read pdb_id ; do
[ -z "$pdb_id" ] || [[ "$pdb_id" =~ ^#.* ]] && continue
rm -f $RDF/$pdb_id.rdf
done < $chk_sum_log
fi
#if [ -d $MMCIF_VALID_ALT ] ; then
# while read pdb_id ; do
# [ -z "$pdb_id" ] || [[ "$pdb_id" =~ ^#.* ]] && continue
# rm -f $MMCIF_VALID_ALT/$pdb_id-validation-alt.cif
# done < $chk_sum_log
#fi
if [ -d $MMCIF_VALID ] ; then
while read pdb_id ; do
[ -z "$pdb_id" ] || [[ "$pdb_id" =~ ^#.* ]] && continue
rm -f $MMCIF_VALID/$pdb_id-validation-full.cif
done < $chk_sum_log
fi
#if [ -d $XML_VALID_ALT ] ; then
# while read pdb_id ; do
# [ -z "$pdb_id" ] || [[ "$pdb_id" =~ ^#.* ]] && continue
# rm -f $XML_VALID_ALT/${pdb_id:1:2}/$pdb_id-validation-alt.xml.gz
# done < $chk_sum_log
#fi
if [ -d $XML_VALID ] ; then
while read pdb_id ; do
[ -z "$pdb_id" ] || [[ "$pdb_id" =~ ^#.* ]] && continue
rm -f $XML_VALID/${pdb_id:1:2}/$pdb_id-validation-full.xml.gz
done < $chk_sum_log
fi
#if [ -d $RDF_VALID_ALT ] ; then
# while read pdb_id ; do
# [ -z "$pdb_id" ] || [[ "$pdb_id" =~ ^#.* ]] && continue
# rm -f $RDF_VALID_ALT/${pdb_id:1:2}/$pdb_id-validation-alt.rdf.gz
# done < $chk_sum_log
#fi
if [ -d $RDF_VALID ] ; then
while read pdb_id ; do
[ -z "$pdb_id" ] || [[ "$pdb_id" =~ ^#.* ]] && continue
rm -f $RDF_VALID/${pdb_id:1:2}/$pdb_id-validation-full.rdf.gz
done < $chk_sum_log
fi
if [ -d $RDF ] ; then
while read pdb_id ; do
[ -z "$pdb_id" ] || [[ "$pdb_id" =~ ^#.* ]] && continue
rm -f $RDF/$pdb_id.rdf.gz
done < $chk_sum_log
fi
#if [ -d $MMCIF_VALID_ALT ] ; then
# while read pdb_id ; do
# [ -z "$pdb_id" ] || [[ "$pdb_id" =~ ^#.* ]] && continue
# rm -f $MMCIF_VALID_ALT/${pdb_id:1:2}/$pdb_id-validation-alt.cif.gz
# done < $chk_sum_log
#fi
if [ -d $MMCIF_VALID ] ; then
while read pdb_id ; do
[ -z "$pdb_id" ] || [[ "$pdb_id" =~ ^#.* ]] && continue
rm -f $MMCIF_VALID/${pdb_id:1:2}/$pdb_id-validation-full.cif.gz
done < $chk_sum_log
fi
fi
rm -f $chk_sum_log
fi
xml_file_total=sifts_xml_file_total
if [ -z $MTIME ] ; then
MTIME=-4
fi
updated=`find $SRC_DIR -name "*.xml.gz" -mtime $MTIME | wc -l 2> /dev/null`
if [ $updated = 0 ] || [ ! -e $xml_file_total ] ; then
last=0
if [ -e $xml_file_total ] ; then
last=`cat $xml_file_total`
fi
total=`find $SRC_DIR -name '*.xml.gz' | wc -l 2> /dev/null`
if [ $total = $last ] ; then
echo $DB_NAME" ("$SRC_DIR") is up-to-date."
else
echo $total > $xml_file_total
fi
fi
date -u +"%b %d, %Y" > /tmp/sifts_xml-last
gz_file_list=`echo ${SRC_DIR,,}_gz_file_list | tr '-' _`
mkdir -p $XML_DIR
find $SRC_DIR -name '*.xml.gz' > $gz_file_list
while read gz_file
do
xml_file=`basename $gz_file .gz`
if [ ! -e $XML_DIR/$xml_file ] ; then
cp $gz_file $XML_DIR
fi
done < $gz_file_list
rm -f $gz_file_list
find $XML_DIR -type f -name "*.gz" -exec gunzip {} +
./scripts/delete_invalid_sifts.sh
echo Unzipped $DB_NAME" ("$XML_DIR") is up-to-date."