-
Notifications
You must be signed in to change notification settings - Fork 0
/
ftdmp-dock-two-monomers-with-hex
executable file
·265 lines (221 loc) · 6.03 KB
/
ftdmp-dock-two-monomers-with-hex
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
#!/bin/bash
function print_help_and_exit
{
cat >&2 << 'EOF'
'ftdmp-dock-two-monomers-with-hex' produces many dimeric structures by docking two monomeric structures
Options:
--monomer1 string * static monomer input file path
--monomer2 string * mobile monomer input file path
--job-name string job name to use as prefix for identifiers
--hex-macro-mode string flag to enable HEX macro mode, default is 'true'
--hex-max-solutions number max number of docking solutions for HEX, default is 10000
--hex-script string semicolon-sparated additional commands for HEX, default is ''
--hex-swap-and-repeat string flag to run HEX twice with monomers swapped, default is 'false'
--sbatch-parameters string sbatch parameters to run on cluster, default is ''
--help | -h flag to display help message and exit
Standard output:
space-separated table of docking results
Examples:
ftdmp-dock-two-monomers-with-hex --monomer1 monomer1.pdb --monomer2 monomer2.pdb --hex-max-solutions 30000
EOF
exit 1
}
readonly ZEROARG=$0
ALLARGS=("$@")
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 &> /dev/null || { echo >&2 "Error: 'voronota-js' executable not in binaries path"; exit 1; }
command -v ftdmp-prepare-monomer &> /dev/null || { echo >&2 "Error: 'ftdmp-prepare-monomer' executable not in binaries path"; exit 1; }
command -v hex &> /dev/null || { echo >&2 "Error: 'hex' executable not in binaries path"; exit 1; }
MONOMERFILE1=""
MONOMERFILE2=""
JOBNAME=""
HEX_MACRO_MODE="true"
HEX_MAX_SOLUTIONS="10000"
HEX_SCRIPT=""
HEX_SWAP_AND_REPEAT="false"
SBATCH_PARAMETERS=""
HELP_MODE="false"
while [[ $# > 0 ]]
do
OPTION="$1"
OPTARG="$2"
shift
case $OPTION in
--monomer1)
MONOMERFILE1="$OPTARG"
shift
;;
--monomer2)
MONOMERFILE2="$OPTARG"
shift
;;
--job-name)
JOBNAME="$OPTARG"
shift
;;
--hex-macro-mode)
HEX_MACRO_MODE="$OPTARG"
shift
;;
--hex-max-solutions)
HEX_MAX_SOLUTIONS="$OPTARG"
shift
;;
--hex-script)
HEX_SCRIPT="$OPTARG"
shift
;;
--hex-swap-and-repeat)
HEX_SWAP_AND_REPEAT="$OPTARG"
shift
;;
--sbatch-parameters)
SBATCH_PARAMETERS="$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" ]
then
echo >&2 "Error: no static monomer input file specified"
exit 1
fi
if [ ! -s "$MONOMERFILE1" ]
then
echo >&2 "Error: no static monomer input file '$MONOMERFILE1'"
exit 1
fi
if [ -z "$MONOMERFILE2" ]
then
echo >&2 "Error: no mobile monomer input file specified"
exit 1
fi
if [ ! -s "$MONOMERFILE2" ]
then
echo >&2 "Error: no mobile monomer input file '$MONOMERFILE2'"
exit 1
fi
if [ -z "$HEX_MAX_SOLUTIONS" ] || [ "$HEX_MAX_SOLUTIONS" -ne "$HEX_MAX_SOLUTIONS" ] || [ "$HEX_MAX_SOLUTIONS" -lt "101" ]
then
echo >&2 "Error: invalid number of docking solutions '$HEX_MAX_SOLUTIONS', must be a positive number larger than 100"
exit 1
fi
readonly TMPLDIR=$(mktemp -d)
trap "rm -r $TMPLDIR" EXIT
if [ -n "$SBATCH_PARAMETERS" ]
then
mkdir -p "$TMPLDIR/slurm_logs"
sbatch -o "$TMPLDIR/slurm_logs/slurmjob-%j.out" -e "$TMPLDIR/slurm_logs/slurmjob-%j.err" $SBATCH_PARAMETERS "$ZEROARG" "${ALLARGS[@]}" --sbatch-parameters "" \
| egrep '^Submitted batch job ' \
| awk '{print $4}' \
> "$TMPLDIR/slurm_job_ids"
sleep 1
REMAINING_SLURM_JOBS="$(squeue | grep -f "$TMPLDIR/slurm_job_ids" | wc -l)"
while [ "$REMAINING_SLURM_JOBS" -gt "0" ]
do
sleep 5
REMAINING_SLURM_JOBS="$(squeue | grep -f "$TMPLDIR/slurm_job_ids" | wc -l)"
done
find "$TMPLDIR/slurm_logs/" -type f -name '*.err' -not -empty | xargs -L 1 cat >&2
find "$TMPLDIR/slurm_logs/" -type f -name '*.out' -not -empty | xargs -L 1 cat
exit 0
fi
ftdmp-prepare-monomer --input "$MONOMERFILE1" --output-for-ftdock "$TMPLDIR/monomer1.pdb"
if [ ! -s "$TMPLDIR/monomer1.pdb" ]
then
echo >&2 "Error: failed to prepare monomer 1"
exit 1
fi
ftdmp-prepare-monomer --input "$MONOMERFILE2" --output-for-ftdock "$TMPLDIR/monomer2.pdb"
if [ ! -s "$TMPLDIR/monomer2.pdb" ]
then
echo >&2 "Error: failed to prepare monomer 2"
exit 1
fi
cd "$TMPLDIR"
{
if [ "$HEX_MACRO_MODE" == "true" ]
then
echo "activate_macro_model"
fi
echo "$HEX_SCRIPT"
echo "max_docking_solutions ${HEX_MAX_SOLUTIONS}"
echo "activate_docking"
} \
| tr ';' '\n' \
| sed 's/^\s\+//' \
| sed 's/\s\+$//' \
> ./common_settings.mac
{
echo "open_receptor ${TMPLDIR}/monomer1.pdb"
echo "open_ligand ${TMPLDIR}/monomer2.pdb"
cat ./common_settings.mac
echo "save_matrix ${TMPLDIR}/matrix_main.hex"
} \
> ./full_settings_main.mac
cat ./full_settings_main.mac | hex &> /dev/null
if [ ! -s "./matrix_main.hex" ]
then
echo >&2 "Error: failed to dock with HEX"
exit 1
fi
if [ "$HEX_SWAP_AND_REPEAT" == "true" ]
then
{
echo "open_receptor ${TMPLDIR}/monomer2.pdb"
echo "open_ligand ${TMPLDIR}/monomer1.pdb"
cat ./common_settings.mac
echo "save_matrix ${TMPLDIR}/matrix_alt.hex"
} \
> ./full_settings_alt.mac
cat ./full_settings_alt.mac | hex &> /dev/null
fi
{
cat "./matrix_main.hex"
if [ -s "./matrix_alt.hex" ]
then
cat "./matrix_alt.hex"
fi
} \
| egrep '^LigandMatrix:' -A 3 \
| egrep -v '^--$' \
| sed 's/\s\+/ /g' \
| sed 's/^\s//' \
| sed 's/\s$//' \
| sed 's/^LigandMatrix//' \
| tr '\n' ' ' \
| tr ':' '\n' \
| egrep . \
| awk '{print sprintf("%g %g %g %g %g %g %g %g %g %g %g %g", $4, $8, $12, $1, $2, $3, $5, $6, $7, $9, $10, $11);}' \
> ./reformatted_matrices.txt
if [ ! -s "./reformatted_matrices.txt" ]
then
echo >&2 "Error: failed to reformat matrices"
exit 1
fi
{
echo "ID scscore scale x y z a1 a2 a3 a4 a5 a6 a7 a8 a9"
cat ./reformatted_matrices.txt \
| awk -v jobname="$JOBNAME" '{print jobname "hex" NR " 0 0 " $0}'
} \
> ./results.txt
cat ./results.txt