-
Notifications
You must be signed in to change notification settings - Fork 1
/
update_sifts_via_aria2c.sh
executable file
·279 lines (207 loc) · 6.75 KB
/
update_sifts_via_aria2c.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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
#!/bin/bash
source ./scripts/env.sh
set -e
if [ ! `which aria2c` ] ; then
echo "aria2c: command not found..."
echo "Please install aria2 (https://aria2.github.io/ZZ)."
exit 1
fi
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_XML_URL
XML_DIR=$SIFTS_XML
weekday=`date -u +"%w"`
if [ ! -e $XSD2PGSCHEMA ] ; then
./scripts/update_extlibs.sh
fi
if [ $weekday -ge 1 ] && [ $weekday -le 4 ] ; then
#wget -c -r -nv -np ftp://$SRC_DIR -nH 2> /dev/null
pdb_chain_uniprot_tsv=pdb_chain_uniprot.tsv
sifts_xml_all=sifts_xml_all
sifts_xml_unz=sifts_xml_unz
sifts_xml_new=sifts_xml_new
sifts_xml_del=sifts_xml_del
sifts_xml_list=sifts_xml_list
sifts_xml_url=${SRC_DIR//\//\\\/}
rm -f $pdb_chain_uniprot_tsv*
wget ftp://ftp.ebi.ac.uk/pub/databases/msd/sifts/flatfiles/tsv/$pdb_chain_uniprot_tsv.gz && gunzip $pdb_chain_uniprot_tsv.gz || exit 1
sed -e "1,2d" $pdb_chain_uniprot_tsv | cut -f 1 | uniq | sort > $sifts_xml_all
find $XML_DIR -name '*.xml' -size 0 -delete
find $XML_DIR -name "*.xml" | cut -d '/' -f 2 | cut -d '.' -f 1 | sort > $sifts_xml_unz
comm -23 $sifts_xml_all $sifts_xml_unz > $sifts_xml_new
comm -13 $sifts_xml_all $sifts_xml_unz > $sifts_xml_del
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 < $sifts_xml_del
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 < $sifts_xml_del
fi
max_connection=$((MAXPROCS > 24 ? 24 : MAXPROCS))
sed -e "s/^/ftp:\/\/$sifts_xml_url\//" $sifts_xml_new | sed -e "s/$/\.xml.gz/" > $sifts_xml_list
aria2c -i $sifts_xml_list -j $max_connection -d $SRC_DIR --allow-overwrite=true --auto-file-renaming=false || aria2c -i $sifts_xml_list -j $max_connection -d $SRC_DIR --allow-overwrite=true --auto-file-renaming=false || aria2c -i $sifts_xml_list -j $max_connection -d $SRC_DIR --allow-overwrite=true --auto-file-renaming=false || true
rm -f $pdb_chain_uniprot_tsv $sifts_xml_list $sifts_xml_all $sifts_xml_unz $sifts_xml_new $sifts_xml_del
MD5_DIR=chk_sum_xml_sifts
chk_sum_log=sifts_xml_log
java -classpath $XSD2PGSCHEMA chksumstat --xml $SRC_DIR --xml-file-ext gz --sync $MD5_DIR --update --verbose > $chk_sum_log
if [ $FULL = "true" ] ; then
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."