-
Notifications
You must be signed in to change notification settings - Fork 1
/
ftdmp-dock-symmetric
executable file
·228 lines (187 loc) · 5.08 KB
/
ftdmp-dock-symmetric
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
#!/bin/bash
function print_help_and_exit
{
cat >&2 << 'EOF'
'ftdmp-dock-symmetric' produces many complex structures by performing symmetry docking with a single monomeric structure
Options:
--monomer string * mobile monomer input file path
--symmetry string * symmetry class for SAM
--output-dir string * output directory path
--job-name string job name to use as prefix for identifiers, default is 'sym'
--sam-parameters string additional SAM parameters, default is '-top=8000 -show=2000 -clusters=2000'
--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
Example:
ftdmp-dock-symmetric --monomer monomer.pdb --symmetry '-c2' --output-dir output
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 sam2.0.4.x64 &> /dev/null || { echo >&2 "Error: 'sam2.0.4.x64' executable not in binaries path"; exit 1; }
MONOMERFILE=""
SYMMETRYCLASS=""
OUTDIR=""
JOBNAME="sym"
SAM_PARAMETERS="-top=8000 -show=2000 -clusters=2000"
SBATCH_PARAMETERS=""
HELP_MODE="false"
while [[ $# > 0 ]]
do
OPTION="$1"
OPTARG="$2"
shift
case $OPTION in
--monomer)
MONOMERFILE="$OPTARG"
shift
;;
--symmetry)
SYMMETRYCLASS="$OPTARG"
shift
;;
--output-dir)
OUTDIR="$OPTARG"
shift
;;
--job-name)
JOBNAME="$OPTARG"
shift
;;
--sam-parameters)
SAM_PARAMETERS="$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 "$MONOMERFILE" ]
then
echo >&2 "Error: no monomer input file specified"
exit 1
fi
if [ ! -s "$MONOMERFILE" ]
then
echo >&2 "Error: no monomer input file '$MONOMERFILE'"
exit 1
fi
if [ -z "$SYMMETRYCLASS" ]
then
echo >&2 "Error: no symmetry specified"
exit 1
fi
if [ -z "$OUTDIR" ]
then
echo >&2 "Error: no output directory specified"
exit 1
fi
if [ -z "$JOBNAME" ]
then
JOBNAME="sym"
fi
SYMMETRYCLASS="$(echo $SYMMETRYCLASS | sed 's/^\(..\)\(.\+\)/\1 \2/')"
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 "$MONOMERFILE" --output-for-ftdock "${TMPLDIR}/${JOBNAME}.pdb"
if [ ! -s "${TMPLDIR}/${JOBNAME}.pdb" ]
then
echo >&2 "Error: failed to prepare monomer"
exit 1
fi
cd "$TMPLDIR"
sam2.0.4.x64 "./${JOBNAME}.pdb" $SYMMETRYCLASS $SAM_PARAMETERS > stdout.txt
cd - &> /dev/null
find "${TMPLDIR}/" -type f -name '*.pdb' -not -empty \
| egrep -v "${TMPLDIR}/${JOBNAME}\.pdb" \
> "$TMPLDIR/list_of_generated_complexes.txt"
if [ "$(cat $TMPLDIR/list_of_generated_complexes.txt | wc -l)" -lt "2" ]
then
cat "$TMPLDIR/stdout.txt" >&2
echo >&2 "Error: failed to generate complexes"
exit 1
fi
OUTDIR="${OUTDIR}"
mkdir -p "$OUTDIR"
cat "$TMPLDIR/list_of_generated_complexes.txt" \
| while read MFILE_IN
do
MFILE_NAME="$(basename ${MFILE_IN})"
MFILE_OUT="${OUTDIR}/${MFILE_NAME}"
{
cat << EOF
var params={}
params.input_pdb_file='$MFILE_IN';
params.output_pdb_file='$MFILE_OUT';
EOF
cat << 'EOF'
try
{
voronota_import("-file", params.input_pdb_file);
voronota_assert_partial_success("Failed to import file");
voronota_set_chain_names_by_guessing();
voronota_assert_full_success("Failed to set chain IDs");
voronota_export_atoms("-file", params.output_pdb_file, "-as-pdb", "-pdb-ter");
voronota_assert_full_success("Failed to export atoms");
}
catch(error)
{
log("Failed with '"+common_params.input_pdb_file+"': "+error);
}
EOF
} \
| voronota-js --no-setup-defaults
if [ -s "$MFILE_OUT" ]
then
echo "$MFILE_OUT"
fi
done \
> "$TMPLDIR/refined_list_of_generated_complexes.txt"
{
echo "ID"
cat "$TMPLDIR/refined_list_of_generated_complexes.txt" | xargs basename -s .pdb | sort
}