-
Notifications
You must be signed in to change notification settings - Fork 0
/
ftdmp-calc-interface-gnn-scores
executable file
·282 lines (244 loc) · 6.94 KB
/
ftdmp-calc-interface-gnn-scores
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
279
280
281
#!/bin/bash
function print_help_and_exit
{
cat >&2 << 'EOF'
'ftdmp-calc-interface-gnn-scores' evaluates docking results produced by 'ftdmp-dock'
Options:
--input-prefix string input file path prefix
--input-suffix string input file path suffix, default is '.pdb'
--monomer1 string static monomer input file path
--monomer2 string mobile monomer input file path
--subselect-contacts string query to subselect inter-chain contacts, default is '[]'
--conda-path string conda installation path, default is ''
--conda-env string conda environment name, default is ''
--rebuild-sidechains flag to rebuild sidechains using FASPR
--local-column string flag to add per-residue scores to the global output table
--parallel number total number of parallel parts, default is 1
--cache-dir string cache directory path to store results of past calculations
--sbatch-parameters string sbatch parameters to run in parallel, default is ''
--colnames-prefix string prefix for output column names, default is 'FIGNN_'
--adjoin flag to output results joined with input
--help | -h flag to display help message and exit
Standard input:
space-separated table of docking results
Standard output:
space-separated table of scoring results
Example:
cat docking_results_table.txt | ftdmp-calc-interface-gnn-scores -m1 monomer1.pdb -m2 monomer2.pdb --parallel 16
EOF
exit 1
}
if [ -z "$1" ]
then
print_help_and_exit
fi
if [ -z "$FTDMPDIR" ]
then
export FTDMPDIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
export PATH="${FTDMPDIR}/core/voronota/expansion_js:${FTDMPDIR}:${PATH}"
fi
command -v voronota-js-voroif-gnn &> /dev/null || { echo >&2 "Error: 'voronota-js-voroif-gnn' executable not in binaries path"; exit 1; }
command -v voronota-js-fast-iface-data-graph &> /dev/null || { echo >&2 "Error: 'voronota-js-fast-iface-data-graph' executable not in binaries path"; exit 1; }
INPUT_PREFIX=""
INPUT_SUFFIX=".pdb"
MONOMERFILE1=""
MONOMERFILE2=""
CONDA_PATH=""
CONDA_ENV=""
PARALLEL_PARTS="1"
CACHE_DIR=""
SBATCH_PARAMETERS=""
SUBSELECT_CONTACTS="[]"
COLNAMES_PREFIX="FIGNN_"
USE_MONOMERS="false"
ADJOIN="false"
REBUILD_SIDECHAINS="false"
LOCAL_COLUMN="false"
HELP_MODE="false"
while [[ $# > 0 ]]
do
OPTION="$1"
OPTARG="$2"
shift
case $OPTION in
--input-prefix)
INPUT_PREFIX="$OPTARG"
shift
;;
--input-suffix)
INPUT_SUFFIX="$OPTARG"
shift
;;
--monomer1)
MONOMERFILE1="$OPTARG"
USE_MONOMERS="true"
shift
;;
--monomer2)
MONOMERFILE2="$OPTARG"
USE_MONOMERS="true"
shift
;;
--conda-path)
CONDA_PATH="$OPTARG"
shift
;;
--conda-env)
CONDA_ENV="$OPTARG"
shift
;;
--parallel)
PARALLEL_PARTS="$OPTARG"
shift
;;
--cache-dir)
CACHE_DIR="$OPTARG"
shift
;;
--sbatch-parameters)
SBATCH_PARAMETERS="$OPTARG"
shift
;;
--subselect-contacts)
SUBSELECT_CONTACTS="$OPTARG"
shift
;;
--colnames-prefix)
COLNAMES_PREFIX="$OPTARG"
shift
;;
--adjoin)
ADJOIN="true"
;;
--rebuild-sidechains)
REBUILD_SIDECHAINS="true"
;;
--local-column)
LOCAL_COLUMN="$OPTARG"
shift
;;
-h|--help)
HELP_MODE="true"
;;
*)
echo >&2 "Error: invalid command line option '$OPTION'"
exit 1
;;
esac
done
if [ "$HELP_MODE" == "true" ]
then
print_help_and_exit
fi
if [ -z "$MONOMERFILE1" ] && [ -z "$MONOMERFILE2" ]
then
USE_MONOMERS="false"
fi
if [ "$USE_MONOMERS" == "true" ]
then
if [ -z "$MONOMERFILE1" ]
then
echo >&2 "Error: no static input file specified"
exit 1
fi
if [ ! -s "$MONOMERFILE1" ]
then
echo >&2 "Error: no static input file '$MONOMERFILE1'"
exit 1
fi
if [ -z "$MONOMERFILE2" ]
then
echo >&2 "Error: no mobile input file specified"
exit 1
fi
if [ ! -s "$MONOMERFILE2" ]
then
echo >&2 "Error: no mobile input file '$MONOMERFILE2'"
exit 1
fi
fi
if [ -z "$PARALLEL_PARTS" ] || [ "$PARALLEL_PARTS" -ne "$PARALLEL_PARTS" ] || [ "$PARALLEL_PARTS" -lt "1" ]
then
echo >&2 "Error: invalid number of parallel parts '$PARALLEL_PARTS', must be a positive number"
exit 1
fi
if [ -z "$FTDMPDIR" ]
then
echo >&2 "Error: no defined environmental variable FTDMPDIR"
exit 1
fi
GNN_PACKAGES_PATH="${FTDMPDIR}/core/voronota/expansion_js/voroif/gnn_packages/v1"
if [ ! -d "${GNN_PACKAGES_PATH}" ]
then
echo >&2 "Error: no GNN packages directory '$GNN_PACKAGES_PATH'"
exit 1
fi
if [ ! -s "${GNN_PACKAGES_PATH}/gnn1.tar" ]
then
echo >&2 "Error: no first GNN package '${GNN_PACKAGES_PATH}/gnn1.tar'"
exit 1
fi
MORE_IFACE_GNN_PARAMETERS=()
MORE_IFACE_GNN_PARAMETERS+=("--gnn")
MORE_IFACE_GNN_PARAMETERS+=("$GNN_PACKAGES_PATH")
MORE_IFACE_GNN_PARAMETERS+=("--conda-path")
MORE_IFACE_GNN_PARAMETERS+=("$CONDA_PATH")
MORE_IFACE_GNN_PARAMETERS+=("--conda-env")
MORE_IFACE_GNN_PARAMETERS+=("$CONDA_ENV")
MORE_IFACE_GNN_PARAMETERS+=("--processors")
MORE_IFACE_GNN_PARAMETERS+=("$PARALLEL_PARTS")
MORE_IFACE_GNN_PARAMETERS+=("--subselect-contacts")
MORE_IFACE_GNN_PARAMETERS+=("$SUBSELECT_CONTACTS")
MORE_IFACE_GNN_PARAMETERS+=("--local-column")
MORE_IFACE_GNN_PARAMETERS+=("$LOCAL_COLUMN")
MORE_IFACE_GNN_PARAMETERS+=("--cache-dir")
MORE_IFACE_GNN_PARAMETERS+=("$CACHE_DIR")
MORE_IFACE_GNN_PARAMETERS+=("--sbatch-parameters")
MORE_IFACE_GNN_PARAMETERS+=("$SBATCH_PARAMETERS")
if [ "$REBUILD_SIDECHAINS" == "true" ]
then
MORE_IFACE_GNN_PARAMETERS+=("--faspr-path")
MORE_IFACE_GNN_PARAMETERS+=("${FTDMPDIR}/core/FASPR_data/dun2010bbdep.bin")
MORE_IFACE_GNN_PARAMETERS+=("--run-faspr")
MORE_IFACE_GNN_PARAMETERS+=("true")
fi
readonly TMPLDIR=$(mktemp -d)
trap "rm -r $TMPLDIR" EXIT
cat > "${TMPLDIR}/input"
if [ ! -s "${TMPLDIR}/input" ]
then
echo >&2 "Error: no input data in stdin"
exit 1
fi
{
if [ "$USE_MONOMERS" == "true" ]
then
mkdir -p "${TMPLDIR}/docklines"
cd "${TMPLDIR}/docklines"
cat ../input \
| awk -v m1="$MONOMERFILE1" -v m2="$MONOMERFILE2" '{if($1!="ID"){print "import-docking-result -static-file \"" m1 "\" -mobile-file \"" m2 "\" -generic-transform " $3 " " $4 " " $5 " " $6 " " $7 " " $8 " " $9 " " $10 " " $11 " " $12 " " $13 " " $14 " " $15 > $1 ; close($1)}}'
cd - &> /dev/null
find "${TMPLDIR}/docklines" -type f -not -empty \
| voronota-js-voroif-gnn --input _list --input-is-script 'true' "${MORE_IFACE_GNN_PARAMETERS[@]}"
else
cat "${TMPLDIR}/input" \
| awk -v prefix="$INPUT_PREFIX" -v suffix="$INPUT_SUFFIX" '{if($1!="ID"){print prefix $1 suffix}}' \
| voronota-js-voroif-gnn --input _list "${MORE_IFACE_GNN_PARAMETERS[@]}" \
| sed "s/^\(\S\+\)${INPUT_SUFFIX} /\1 /"
fi
} \
| sed '1 s/^\(\S\+\) /ID /' \
| sed "1 s/\s\+/ ${COLNAMES_PREFIX}/g" \
| sed 's/\s\+/ /g' \
> "${TMPLDIR}/output"
if [ ! -s "${TMPLDIR}/output" ]
then
echo >&2 "Error: no output produced"
exit 1
fi
if [ "$ADJOIN" == "true" ]
then
ftdmp-join-tables "${TMPLDIR}/input" "${TMPLDIR}/output"
else
cat "${TMPLDIR}/output"
fi