-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathexample_run.sh
More file actions
307 lines (236 loc) · 11.3 KB
/
example_run.sh
File metadata and controls
307 lines (236 loc) · 11.3 KB
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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
# ==============================================================================
# Variables & Directory Setup
# ==============================================================================
# >>> Adjust ALL of the following paths to your environment <<<
# ==============================================================================
# Path to CONDA Install
CONDA_PATH="/path/to/conda/bin/activate"
# Output directory (must be full path)
OUTPUT_DIR="/path/to/outputs"
# Input directory containing PDB files
INPUT_PDBS="./example_input/input_pdbs"
# Path to this repository
SCRIPT_DIR="/path/to/de_novo_binder_scoring"
# ==============================================================================
# Log directory setup
LOG_DIR="${OUTPUT_DIR}/log"
mkdir -p "${LOG_DIR}"
OVERALL_START_TIME=$(date +%s)
# Count number of input PDB files
count=$(ls -1 "${INPUT_PDBS}"/*.pdb | wc -l)
echo "Running ${count} structures..." > "${LOG_DIR}/log.txt"
# ==============================================================================
# 1. Pre-process input CSV and PDB Files
# ==============================================================================
# Activate the Python environment and run the meta_analysis script to convert PDB files to a CSV.
cd $SCRIPT_DIR
source "$CONDA_PATH"
conda activate binder_scoring_env
python ./scripts/process_inputs.py \
--input_pdbs "${INPUT_PDBS}" \
--output_dir "${OUTPUT_DIR}"
# ==============================================================================
# 2. Relax input structures and compute Rosetta metrics
# ==============================================================================
START_TIME=$(date +%s)
echo -e "\nRelaxing input PDBs and computing Rosetta metrics" >> "${LOG_DIR}/log.txt"
python ./scripts/compute_rosetta_metrics.py \
--run-csv "${OUTPUT_DIR}/run.csv" \
--out-csv "${OUTPUT_DIR}/input_rosetta_metrics.csv" \
--folder input:"${OUTPUT_DIR}/input_pdbs" \
conda deactivate
conda deactivate
END_TIME=$(date +%s)
echo "Structures relaxed in $((END_TIME - START_TIME)) seconds" >> "${LOG_DIR}/log.txt"
# ==============================================================================
# 3. Run Alphafold2 initial guess
# >>> REQUIRES an environment to run af2_initial_guess <<<
# ==============================================================================
START_TIME=$(date +%s)
echo -e "\nRunning AF2 initial guess" >> "${LOG_DIR}/log.txt"
mkdir -p "${OUTPUT_DIR}/AF2" && cd "${OUTPUT_DIR}/AF2"
# >>> load af2 initial guess environment <<<
# Run AF2 prediction
predict.py -pdbdir "${OUTPUT_DIR}/input_pdbs/relaxed_pdbs" \
-scorefilename "out.sc" \
-outsilent "af2.silent"
# >>> unload af2 initial guess environment <<<
END_TIME=$(date +%s)
echo "AF2 initial guess completed in $((END_TIME - START_TIME)) seconds" >> "${LOG_DIR}/log.txt"
# ==============================================================================
# 4A. Generate MSA files
# >>> REQUIRES an environment to run ColabFold <<<
# ==============================================================================
cd $SCRIPT_DIR
# >>> load ColabFold environment <<<
colabfold_batch "${OUTPUT_DIR}/unique_msa" "${OUTPUT_DIR}/unique_msa/msa" --msa-only
# >>> unload ColabFold environment <<<
#==============================================================================
# 4B. Generate model inputs
# ==============================================================================
source "$CONDA_PATH"
conda activate binder_scoring_env
python ./scripts/generate_model_inputs.py \
--run-csv "${OUTPUT_DIR}/run.csv" \
--out-dir "${OUTPUT_DIR}"
conda deactivate
conda deactivate
# ==============================================================================
# 5. Run ColabFold
# >>> REQUIRES an environment to run ColabFold <<<
# ==============================================================================
START_TIME=$(date +%s)
echo -e "\nRunning ColabFold" >> "${LOG_DIR}/log.txt"
# >>> load ColabFold environment <<<
colabfold_batch "${OUTPUT_DIR}/ColabFold/input_folder" "${OUTPUT_DIR}/ColabFold/ptm_output" --calc-extra-ptm --num-recycle 3 --num-models 3
find "${OUTPUT_DIR}/ColabFold/ptm_output" -type f -name "*.png" -exec rm -f {} \;
# >>> unload ColabFold environment <<<
END_TIME=$(date +%s)
echo "ColabFold completed in $((END_TIME - START_TIME)) seconds" >> "${LOG_DIR}/log.txt"
# ==============================================================================
# 6. Run Boltz
# >>> REQUIRES an environment to run Boltz <<<
# ==============================================================================
START_TIME=$(date +%s)
echo -e "\nRunning Boltz" >> "${LOG_DIR}/log.txt"
# >>> load Boltz environment <<<
boltz predict "${OUTPUT_DIR}/Boltz/input_folder" \
--recycling_steps 10 \
--diffusion_samples 3 \
--write_full_pae \
--out_dir "${OUTPUT_DIR}/Boltz"
# >>> unload Boltz environment <<<
END_TIME=$(date +%s)
echo "Boltz completed in $((END_TIME - START_TIME)) seconds" >> "${LOG_DIR}/log.txt"
# ==============================================================================
# 7. Run AF3
# >>> REQUIRES an environment to run AF3 <<<
# ==============================================================================
START_TIME=$(date +%s)
echo -e "\nRunning AF3" >> "${LOG_DIR}/log.txt"
# >>> load AF3 environment <<<
python run_alphafold.py \
--input_dir="${OUTPUT_DIR}/AF3/input_folder" \
--model_dir=/path/to/alphafold3_weights \
--db_dir=/path/to/alphafold3_database \
--run_data_pipeline=False \
--num_diffusion_samples=3 \
--output_dir="${OUTPUT_DIR}/AF3/outputs"
# >>> unload AF3 environment <<<
END_TIME=$(date +%s)
echo "AF3 completed in $((END_TIME - START_TIME)) seconds" >> "${LOG_DIR}/log.txt"
# ==============================================================================
# 8. Extracting confidence metrics and model_0 PDBs
# ==============================================================================
cd $SCRIPT_DIR
START_TIME=$(date +%s)
echo -e "\nExtracting confidence metrics" >> "${LOG_DIR}/log.txt"
source "$CONDA_PATH"
conda activate binder_scoring_env
python ./scripts/extract_confidence_metrics.py \
--run-csv "${OUTPUT_DIR}/run.csv" \
--out-dir "${OUTPUT_DIR}"
# ==============================================================================
# 9. compute ipSAE and other interface confidence metrics
# ==============================================================================
echo -e "\nComputing ipSAE and other interface confidence metrics" >> "${LOG_DIR}/log.txt"
python ./scripts/run_ipsae_batch.py \
--run-csv "${OUTPUT_DIR}/run.csv" \
--out-csv "${OUTPUT_DIR}/ipsae_and_ipae.csv" \
--af3-dir "${OUTPUT_DIR}/AF3" \
--boltz1-dir "${OUTPUT_DIR}/Boltz/boltz_results_input_folder" \
--colab-dir "${OUTPUT_DIR}/ColabFold/ptm_output" \
--ipsae-script-path ./scripts/ipsae_w_ipae.py \
# ==============================================================================
# 10. Computing DockQ
# ==============================================================================
echo -e "\nComputing dockQ" >> "${LOG_DIR}/log.txt"
python ./scripts/dockQ.py \
--run-csv "${OUTPUT_DIR}/run.csv" \
--input-pdbs "${OUTPUT_DIR}/input_pdbs/" \
--folder af3:"${OUTPUT_DIR}/AF3/pdbs/" \
--folder af2:"${OUTPUT_DIR}/AF2/pdbs/" \
--folder boltz:"${OUTPUT_DIR}/Boltz/pdbs" \
--folder colab:"${OUTPUT_DIR}/ColabFold/pdbs" \
--out-csv "${OUTPUT_DIR}/dockQ.csv" \
# ==============================================================================
# 11. Compute Rosetta metrics
# ==============================================================================
START_TIME=$(date +%s)
echo -e "\nRelaxing model PDBs and computing Rosetta metrics" >> "${LOG_DIR}/log.txt"
python ./scripts/compute_rosetta_metrics.py \
--run-csv "${OUTPUT_DIR}/run.csv" \
--out-csv "${OUTPUT_DIR}/rosetta_metrics.csv" \
--folder af3:"${OUTPUT_DIR}/AF3/pdbs" \
--folder boltz1:"${OUTPUT_DIR}/Boltz/pdbs" \
--folder colab:"${OUTPUT_DIR}/ColabFold/pdbs" \
--folder af2:"${OUTPUT_DIR}/AF2/pdbs" \
END_TIME=$(date +%s)
echo "Structures relaxed in $((END_TIME - START_TIME)) seconds" >> "${LOG_DIR}/log.txt"
# ==============================================================================
# 12. Compute RMSDs
# ==============================================================================
echo -e "\nComputing RMSDs" >> "${LOG_DIR}/log.txt"
python ./scripts/rmsd.py \
--folder input:"${OUTPUT_DIR}/input_pdbs/" \
--folder af3:"${OUTPUT_DIR}/AF3/pdbs/" \
--folder af2:"${OUTPUT_DIR}/AF2/pdbs/" \
--folder boltz1:"${OUTPUT_DIR}/Boltz/pdbs" \
--folder colab:"${OUTPUT_DIR}/ColabFold/pdbs" \
--out-csv "${OUTPUT_DIR}/rmsd.csv"
conda deactivate
conda deactivate
# ==============================================================================
# 13. Pymol Metrics: Interface Analysis & Hydrogen Bonds
# >>> REQUIRES an environment to run Pymol <<<
# ==============================================================================
cd ${OUTPUT_DIR}
START_TIME=$(date +%s)
PYMOL_DIR="${OUTPUT_DIR}/pymol_files"
mkdir -p "${PYMOL_DIR}"
# >>> load Pymol environment <<<
# Create a JSON file that lists the directories for Pymol analysis.
echo '{"input": "'${OUTPUT_DIR}/input_pdbs'", "af2": "'${OUTPUT_DIR}/AF2/pdbs'", "colab": "'${OUTPUT_DIR}/ColabFold/pdbs'", "boltz1": "'${OUTPUT_DIR}/Boltz/pdbs'", "af3": "'${OUTPUT_DIR}/AF3/pdbs'"}' > "${PYMOL_DIR}/pdb_dirs.json"
# Run Pymol in command-line mode to execute the analysis script.
python -m pymol -c -d "run ${SCRIPT_DIR}/scripts/pymol_metrics.py"
# >>> unload Pymol environment <<<
END_TIME=$(date +%s)
echo "Pymol metrics calculated in $((END_TIME - START_TIME)) seconds" >> "${LOG_DIR}/log.txt"
module purge
conda deactivate
conda deactivate
# ==============================================================================
# 14. Merge All CSV Metrics
# ==============================================================================
source "$CONDA_PATH"
conda activate binder_scoring_env
echo -e "\nMerging all metrics into merged_run.csv" >> "${LOG_DIR}/log.txt"
START_TIME=$(date +%s)
python ./scripts/merge_csvs.py \
--run-csv "${OUTPUT_DIR}/run.csv" \
--metric-csvs \
"${OUTPUT_DIR}/input_rosetta_metrics.csv" \
"${OUTPUT_DIR}/ipsae_and_ipae.csv" \
"${OUTPUT_DIR}/dockQ.csv" \
"${OUTPUT_DIR}/rosetta_metrics.csv" \
"${OUTPUT_DIR}/rmsd.csv" \
"${OUTPUT_DIR}/pymol_files/pymol_metrics_af3.csv" \
"${OUTPUT_DIR}/pymol_files/pymol_metrics_input.csv" \
"${OUTPUT_DIR}/pymol_files/pymol_metrics_boltz1.csv" \
"${OUTPUT_DIR}/pymol_files/pymol_metrics_colab.csv" \
"${OUTPUT_DIR}/pymol_files/pymol_metrics_af2.csv" \
"${OUTPUT_DIR}/AF2/AF2_metrics.csv" \
"${OUTPUT_DIR}/AF3/af3_metrics.csv" \
"${OUTPUT_DIR}/Boltz/boltz_metrics.csv" \
"${OUTPUT_DIR}/ColabFold/colab_metrics.csv" \
--out-dir "${OUTPUT_DIR}"
END_TIME=$(date +%s)
echo "CSV merging completed in $((END_TIME - START_TIME)) seconds" >> "${LOG_DIR}/log.txt"
# ==============================================================================
# 15. Overall Execution Time Logging
# ==============================================================================
END_TIME=$(date +%s)
RUN_TIME=$(( END_TIME - OVERALL_START_TIME ))
echo -e "\nOverall pipeline execution time: ${RUN_TIME} seconds" >> "${LOG_DIR}/log.txt"
TIME_PER_STRUC=$(echo "scale=2; $RUN_TIME / $count" | bc)
echo "${TIME_PER_STRUC} seconds per design" >> "${LOG_DIR}/log.txt"