-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_pdb_test.sh
executable file
·167 lines (100 loc) · 4.39 KB
/
run_pdb_test.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
#!/bin/bash
source ./scripts/env.sh
if [ ! -e $SAXON ] || [ ! -e $XSD2PGSCHEMA ] ; then
./scripts/update_extlibs.sh
fi
if [ ! -e $PDBML_XSD ] || [ ! -e $PDBML2RDF_XSL ] ; then
( cd resource; ./update_pdbx_xsd.sh; ./update_pdbx_owl.sh )
fi
#if [ ! -e $PDBX_PRIMITIVE_TYPE_MAPPING_XML ] ; then
java -jar $SAXON -s:$PDBML_XSD -xsl:$XSD2PRIMITIVE_TYPE_MAPPING_XSL -o:$PDBX_PRIMITIVE_TYPE_MAPPING_XML || ( echo $0 aborted. ; exit 1 )
echo Generated: $PDBX_PRIMITIVE_TYPE_MAPPING_XML
#fi
#if [ ! -e $MERGE_PDBML_SIFTS_XSL ] ; then
java -jar $SAXON -s:$PDBML_XSD -xsl:$XSD2MERGE_PDBML_SIFTS_XSL -o:$MERGE_PDBML_SIFTS_XSL || ( echo $0 aborted. ; exit 1 )
echo Generated: $MERGE_PDBML_SIFTS_XSL
#fi
#if [ ! -e $MERGE_PDBML_NEXTGEN_XSL ] ; then
java -jar $SAXON -s:$PDBML_XSD -xsl:$XSD2MERGE_PDBML_NEXTGEN_XSL -o:$MERGE_PDBML_NEXTGEN_XSL || ( echo $0 aborted. ; exit 1 )
echo Generated: $MERGE_PDBML_NEXTGEN_XSL
#fi
#if [ ! -e $PDBML2RDF_XSL ] ; then
java -jar $SAXON -s:$PDBML_XSD -xsl:$PDBX2PDBML2RDF_XSL -o:$PDBML2RDF_XSL || ( echo $0 aborted. ; exit 1 )
echo Generated: $PDBML2RDF_XSL
#fi
get_resource() {
pdb_id=$1
if [[ $pdb_id =~ [0-9][0-9a-z]{3} ]] ; then
pdbml_file=$WORK_DIR/$PDBML/$pdb_id-noatom.xml
sifts_xml_file=$WORK_DIR/$SIFTS_XML/$pdb_id.xml
pdbml_nextgen_file=$WORK_DIR/$NEXTGEN/$NEXTGEN_FILE_PREFIX$pdb_id$NEXTGEN_FILE_SUFFIX.xml
if [ ! -e $pdbml_file ] ; then
wget ftp://ftp.wwpdb.org/pub/pdb/data/structures/all/XML-noatom/$pdb_id-noatom.xml.gz -P $WORK_DIR/pdbml; gunzip $pdbml_file.gz
fi
if [ ! -e $sifts_xml_file ] ; then
wget ftp://$SIFTS_XML_URL/$pdb_id.xml.gz -P $WORK_DIR/$SIFTS_XML; gunzip $sifts_xml_file.gz
fi
if [ ! -e $pdbml_nextgen_file ] ; then
wget https://files-nextgen.wwpdb.org/pdb_nextgen/data/entries/divided/${pdb_id:1:2}/$NEXTGEN_FILE_PREFIX$pdb_id/$NEXTGEN_FILE_PREFIX$pdb_id$NEXTGEN_FILE_SUFFIX.xml.gz -P $WORK_DIR/nextgen; gunzip $pdbml_nextgen_file
fi
fi
}
xml_pretty() {
if [ $has_xmllint_command != "false" ] ; then
xmllint --format $1 > $1~ ; mv -f $1~ $1
fi
}
# PDB/RDF
WORK_DIR=test
for arg ; do
pdb_id=${arg,,}
get_resource $pdb_id
done
mkdir -p $WORK_DIR/$PDBML_SIFTS
mkdir -p $WORK_DIR/$RDF
for pdbml_file in $WORK_DIR/$PDBML/*.xml ; do
pdb_id=`basename $pdbml_file -noatom.xml`
get_resource $pdb_id
#exptl_method=`java -jar $SAXON -s:$pdbml_file -xsl:stylesheet/exptl_method.xsl`
exptl_method=`xsltproc stylesheet/exptl_method.xsl $pdbml_file`
#has_glycan=`java -jar $SAXON -s:$pdbml_file -xsl:$PDBML2WURCS_XSL`
has_glycan=`xsltproc $PDBML2WURCS_XSL $pdbml_file`
echo
echo Processing PDB ID: ${pdb_id^^}, "Exptl. method: "$exptl_method" ..."
sifts_xml_file=$WORK_DIR/$SIFTS_XML/$pdb_id.xml
pdbml_nextgen_file=$WORK_DIR/$NEXTGEN/$NEXTGEN_FILE_PREFIX$pdb_id$NEXTGEN_FILE_SUFFIX.xml
pdbml_sifts_file=$WORK_DIR/$PDBML_SIFTS/$pdb_id-noatom-sifts.xml
if [ $PREFER_SIFTS = "true" ] ; then
#xsltproc stylesheet/check_sifts.xsl $sifts_xml_file
#echo
if [ -e $sifts_xml_file ] && [ -s $sifts_xml_file ] ; then
xsltproc -o $pdbml_sifts_file --stringparam sifts_file ../$sifts_xml_file $MERGE_PDBML_SIFTS_XSL $pdbml_file
#java -jar $SAXON -s:$pdbml_file -xsl:$MERGE_PDBML_SIFTS_XSL -o:$pdbml_sifts_file sifts_file=../$sifts_xml_file
echo " generated: "$pdbml_sifts_file
else
cp -f $pdbml_file $pdbml_sifts_file
fi
else
if [ -e $pdbml_nextgen_file ] && [ -s $sifts_xml_file ] ; then
xsltproc -o $pdbml_sifts_file --stringparam nextgen_file ../$pdbml_nextgen_file $MERGE_PDBML_NEXTGEN_XSL $pdbml_file
#java -jar $SAXON -s:$pdbml_file -xsl:$MERGE_PDBML_NEXGEN_XSL -o:$pdbml_sifts_file nextgen_file=../$pdbml_nextgen_file
echo " generated: "$pdbml_sifts_file
else
cp -f $pdbml_file $pdbml_sifts_file
fi
fi
rdf_file=$WORK_DIR/$RDF/$pdb_id.rdf
#if [ -z "$has_glycan" ] ; then
xsltproc -o $rdf_file --stringparam wurcs2glytoucan $WURCS_CATALOG_XML --stringparam primitive_type_mapping $_PDBX_PRIMITIVE_TYPE_MAPPING_XML $PDBML2RDF_XSL $pdbml_sifts_file
#else
# java -jar $SAXON -s:$pdbml_sifts_file -xsl:$PDBML2RDF_XSL -o:$rdf_file wurcs2glytoucan=$WURCS_CATALOG_XML primitive_type_mapping=$_PDBX_PRIMITIVE_TYPE_MAPPING_XML || ( echo $0 aborted. ; exit 1 )
#fi
echo " generated: "$rdf_file
if [ $has_rapper_command != "false" ] ; then
rapper -q -c $rdf_file 2> /dev/null || ( echo $0 aborted. ; exit 1 )
echo " validated: "$rdf_file
fi
xml_pretty $rdf_file
done
echo
echo Done.