-
Notifications
You must be signed in to change notification settings - Fork 1
/
ftdmp-calc-interface-cadscore-for-reference
executable file
·240 lines (204 loc) · 5.82 KB
/
ftdmp-calc-interface-cadscore-for-reference
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
#!/bin/bash
function print_help_and_exit
{
cat >&2 << 'EOF'
'ftdmp-calc-interface-cadscore-for-reference' compares docking results produced by 'ftdmp-dock' to a reference
Options:
--reference string * reference file path
--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 '[]'
--remap-chains string flag to calculate and use optimal chains remapping, default is 'false'
--parallel number total number of parallel parts, default is 1
--sbatch-parameters string sbatch parameters to run in parallel, default is ''
--colnames-prefix string prefix for output column names, default is 'CR_'
--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-cadscore-for-reference -m1 monomer1.pdb -m2 monomer2.pdb --reference --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-fast-iface-cadscore &> /dev/null || { echo >&2 "Error: 'voronota-js-fast-iface-cadscore' executable not in binaries path"; exit 1; }
INPUT_PREFIX=""
INPUT_SUFFIX=".pdb"
MONOMERFILE1=""
MONOMERFILE2=""
PARALLEL_PARTS="1"
SBATCH_PARAMETERS=""
SUBSELECT_CONTACTS="[]"
COLNAMES_PREFIX="CR_"
USE_MONOMERS="false"
REMAP_CHAINS="false"
ADJOIN="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
;;
--reference)
REFERENCEFILE="$OPTARG"
shift
;;
--parallel)
PARALLEL_PARTS="$OPTARG"
shift
;;
--sbatch-parameters)
SBATCH_PARAMETERS="$OPTARG"
shift
;;
--subselect-contacts)
SUBSELECT_CONTACTS="$OPTARG"
shift
;;
--colnames-prefix)
COLNAMES_PREFIX="$OPTARG"
shift
;;
--remap-chains)
REMAP_CHAINS="$OPTARG"
shift
;;
--adjoin)
ADJOIN="true"
;;
-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 [ "$ADJOIN" == "true" ]
then
command -v ftdmp-join-tables &> /dev/null || { echo >&2 "Error: 'ftdmp-join-tables' executable not in binaries path"; exit 1; }
fi
if [ -z "$REFERENCEFILE" ]
then
echo >&2 "Error: no reference input file specified"
exit 1
fi
if [ ! -s "$REFERENCEFILE" ]
then
echo >&2 "Error: no reference input file '$REFERENCEFILE'"
exit 1
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
MORE_FAST_IFACE_CADSCORE_PARAMETERS=()
if [ "$REMAP_CHAINS" == "true" ]
then
MORE_FAST_IFACE_CADSCORE_PARAMETERS+=("--remap-chains")
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-fast-iface-cadscore --lt --target "$REFERENCEFILE" --model _list --model-input-is-script --processors "$PARALLEL_PARTS" --sbatch-parameters "$SBATCH_PARAMETERS" --subselect-contacts "$SUBSELECT_CONTACTS" "${MORE_FAST_IFACE_CADSCORE_PARAMETERS[@]}"
else
cat "${TMPLDIR}/input" \
| awk -v prefix="$INPUT_PREFIX" -v suffix="$INPUT_SUFFIX" '{if($1!="ID"){print prefix $1 suffix}}' \
| voronota-js-fast-iface-cadscore --lt --target "$REFERENCEFILE" --model _list --processors "$PARALLEL_PARTS" --sbatch-parameters "$SBATCH_PARAMETERS" --subselect-contacts "$SUBSELECT_CONTACTS" "${MORE_FAST_IFACE_CADSCORE_PARAMETERS[@]}" \
| sed "s/^\(\S\+\)${INPUT_SUFFIX}\s\+\(\S\+\)${INPUT_SUFFIX} /\1 \2 /"
fi
} \
| sed 's/^\(\S\+\)\s\+\(\S\+\)/\2 \1/' \
| sed '1 s/^\(\S\+\) /ID /' \
| sed "1 s/\s\+/ ${COLNAMES_PREFIX}/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