-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdatepdb.sh
executable file
·123 lines (104 loc) · 3.93 KB
/
updatepdb.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
#!/bin/bash
README="
update PDB, and save the PDB locally in the same data structure as the RCSB archive
pdb/data/structures/divided/pdb : the main PDB archive, experimental structures
pdb/data/structures/obsolete/pdb : the obsolete PDB archive, experimental structures
pdb/data/structures/models/current/pdb : for theoretical structures, main archive
pdb/data/structures/models/obsolete/pdb : for theoretical structures, obsolete archive
and the decompressed data are stored at
pdb/data/structures/divided/pdb_dcp : the main PDB archive, experimental structures
pdb/data/structures/obsolete/pdb_dcp : the obsolete PDB archive, experimental structures
pdb/data/structures/models/current/pdb_dcp : for theoretical structures, main archive
pdb/data/structures/models/obsolete/pdb_dcp : for theoretical structures, obsolete archive
Usage:
./updatepdb.sh
Created 2011-03-16, updated 2012-03-23, Nanjiang Shu
"
if [ "$DATADIR" == "" ]; then
echo "The environmental variable DATADIR does not exist, please set it. Exit!" >&2
exit 1
elif [ ! -d $DATADIR ] ; then
echo DATADIR $DATADIR unaccessable, exit >&2
exit 1
fi
function IsProgExist() #{{{
# usage: IsProgExist prog
# prog can be both with or without absolute path
{
type -P $1 &>/dev/null || { echo "The program \"$1\" is required but it's not installed. Aborting." >&2; exit 1; }
}
#}}}
function IsPathExist() #{{{
# supply the effective path of the program
{
if ! test -d $1; then
echo "Directory $1 does not exist. Aborting." >&2
exit
fi
}
#}}}
function AddAbsolutePath() #$path#{{{
{
local var=$1
if [ "${var:0:1}" != "/" ];then
var=$PWD/$var # add the absolut path
fi
echo $var
return 0
}
#}}}
function CopyNewEntry() #sourceDIR targetDIR#{{{
{
local sourceDIR=$1
local targetDIR=$2
local tmppdblist=$(mktemp /tmp/tmp.XXXXXXXXXX) || { echo "Failed to create temp file"; exit 1; }
local tmppdb_dcplist=$(mktemp /tmp/tmp.XXXXXXXXXX) || { echo "Failed to create temp file"; exit 1; }
# echo $tmppdb_dcplist
# echo $tmppdblist
IsPathExist $sourceDIR
mkdir -p $targetDIR
find $sourceDIR -name "*.gz" -printf "%p %TY-%Tm-%Td %TH:%TM:%TS\n" > $tmppdblist
find $targetDIR -name "*.ent" -printf "%p %TY-%Tm-%Td %TH:%TM:%TS\n" > $tmppdb_dcplist
$binpath/copy_new_entry.py $tmppdblist $tmppdb_dcplist $sourceDIR $targetDIR -v
rm -f $tmppdblist $tmppdb_dcplist
}
#}}}
IsProgExist dirname
IsProgExist find
IsProgExist gzip
binpath=`dirname $0`
binpath=`AddAbsolutePath $binpath`
echo "======================================================"
echo "Date=`date '+%F %H:%M:%S %A Week %V'`"
echo "======================================================"
echo "Begin time=`date '+%F %H:%M:%S'`"
### step 1. download pdb
$binpath/downloadpdbnew.sh
### step 2. extract gz files and upload to the pdb_dcp folder
echo "======================================================"
echo "main"
echo
sourceDIR=$DATADIR/pdb/data/structures/divided/pdb/
targetDIR=$DATADIR/pdb/data/structures/divided/pdb_dcp/
CopyNewEntry $sourceDIR $targetDIR
echo "======================================================"
echo "main obsolete"
echo
sourceDIR=$DATADIR/pdb/data/structures/obsolete/pdb/
targetDIR=$DATADIR/pdb/data/structures/obsolete/pdb_dcp/
CopyNewEntry $sourceDIR $targetDIR
echo "======================================================"
echo "models"
echo
sourceDIR=$DATADIR/pdb/data/structures/models/current/pdb/
targetDIR=$DATADIR/pdb/data/structures/models/current/pdb_dcp/
CopyNewEntry $sourceDIR $targetDIR
echo "======================================================"
echo "models obsolete"
echo
sourceDIR=$DATADIR/pdb/data/structures/models/obsolete/pdb/
targetDIR=$DATADIR/pdb/data/structures/models/obsolete/pdb_dcp/
CopyNewEntry $sourceDIR $targetDIR
echo "======================================================"
echo "End time=`date '+%F %H:%M:%S'`"
echo