-
Notifications
You must be signed in to change notification settings - Fork 49
/
README.md
1824 lines (1320 loc) · 82.3 KB
/
README.md
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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# AlphaPulldown: Version 2.0.0 (Beta)
> AlphaPulldown fully **maintains backward compatibility** with input files and scripts from versions 1.x.
## Table of Contents
<!-- TOC start (generated with https://github.com/derlin/bitdowntoc) -->
- [AlphaPulldown: Version 2.0.0 (Beta)](#alphapulldown-version-200-beta)
* [Table of Contents](#table-of-contents)
- [About AlphaPulldown](#about-alphapulldown)
* [Overview](#overview)
- [Alphafold databases](#alphafold-databases)
- [Snakemake AlphaPulldown ](#snakemake-alphapulldown)
* [1. Installation](#1-installation)
* [2. Configuration](#2-configuration)
* [3. Execution](#3-execution)
- [Run AlphaPulldown Python Command Line Interface](#run-alphapulldown-python-command-line-interface)
* [0. Installation](#0-installation)
+ [0.1. Create Anaconda environment](#01-create-anaconda-environment)
+ [0.2. Installation using pip](#02-installation-using-pip)
+ [0.3. Installation for the Downstream analysis tools](#03-installation-for-the-downstream-analysis-tools)
+ [0.4. Installation for cross-link input data by AlphaLink2 (optional!)](#04-installation-for-cross-link-input-data-by-alphalink2-optional)
+ [0.5. Installation for developers](#05-installation-for-developers)
* [1. Compute multiple sequence alignment (MSA) and template features (CPU stage)](#1-compute-multiple-sequence-alignment-msa-and-template-features-cpu-stage)
+ [1.1. Basic run](#11-basic-run)
- [Input](#input)
- [Script Execution](#script-execution)
- [Output](#output)
- [Next step](#next-step)
+ [1.2. Example bash scripts for SLURM (EMBL cluster)](#12-example-bash-scripts-for-slurm-embl-cluster)
- [Input](#input-1)
- [Script Execution](#script-execution-1)
- [Next step](#next-step-1)
+ [1.3. Run using MMseqs2 and ColabFold Databases (Faster)](#13-run-using-mmseqs2-and-colabfold-databases-faster)
- [Run MMseqs2 Remotely](#run-mmseqs2-remotely)
- [Output](#output-1)
- [Run MMseqs2 Locally](#run-mmseqs2-locally)
- [Next step](#next-step-2)
+ [1.4. Run with custom templates (TrueMultimer)](#14-run-with-custom-templates-truemultimer)
- [Input](#input-2)
- [Script Execution](#script-execution-2)
- [Output](#output-2)
- [Next step](#next-step-3)
* [2. Predict structures (GPU stage)](#2-predict-structures-gpu-stage)
+ [2.1. Basic run](#21-basic-run)
- [Input](#input-3)
- [Script Execution: Structure Prediction](#script-execution-structure-prediction)
- [Output](#output-3)
- [Next step](#next-step-4)
+ [2.2. Example run with SLURM (EMBL cluster)](#22-example-run-with-slurm-embl-cluster)
- [Input](#input-4)
- [Script Execution](#script-execution-3)
- [Output and the next step](#output-and-the-next-step)
+ [2.3. Pulldown mode](#23-pulldown-mode)
- [Multiple inputs "pulldown" mode](#multiple-inputs-pulldown-mode)
+ [2.4. All versus All mode](#24-all-versus-all-mode)
- [Output and the next step](#output-and-the-next-step-1)
+ [2.5. Run with Custom Templates (TrueMultimer)](#25-run-with-custom-templates-truemultimer)
- [Input](#input-5)
- [Script Execution for TrueMultimer Structure Prediction](#script-execution-for-truemultimer-structure-prediction)
- [Output and the next step](#output-and-the-next-step-2)
+ [2.6. Run with crosslinking-data (AlphaLink2)](#26-run-with-crosslinking-data-alphalink2)
- [Input](#input-6)
- [Run with AlphaLink2 prediction via AlphaPulldown](#run-with-alphalink2-prediction-via-alphapulldown)
- [Output and the next step](#output-and-the-next-step-3)
* [3. Analysis and Visualization](#3-analysis-and-visualization)
+ [Create Jupyter Notebook](#create-jupyter-notebook)
- [Next step](#next-step-5)
+ [Create Results table](#create-results-table)
- [Next step](#next-step-6)
- [Downstream analysis](#downstream-analysis)
* [Jupyter notebook](#jupyter-notebook)
* [Results table ](#results-table)
* [Results management scripts](#results-management-scripts)
+ [Decrease the size of AlphaPulldown output](#decrease-the-size-of-alphapulldown-output)
+ [Convert Models from PDB Format to ModelCIF Format](#convert-models-from-pdb-format-to-modelcif-format)
- [1. Convert all models to separate ModelCIF files](#1-convert-all-models-to-separate-modelcif-files)
- [2. Only convert a specific single model for each complex](#2-only-convert-a-specific-single-model-for-each-complex)
- [3. Have a representative model and keep associated models](#3-have-a-representative-model-and-keep-associated-models)
- [Associated Zip Archives](#associated-zip-archives)
- [Miscellaneous Options](#miscellaneous-options)
- [Features Database](#features-database)
* [Installation](#installation)
+ [Steps:](#steps)
+ [Verify installation:](#verify-installation)
* [Configuration](#configuration)
* [Downloading Features](#downloading-features)
+ [List available organisms:](#list-available-organisms)
+ [Download specific protein features:](#download-specific-protein-features)
+ [Download all features for an organism:](#download-all-features-for-an-organism)
<!-- TOC end -->
# About AlphaPulldown
AlphaPulldown is a customized implementation of [AlphaFold-Multimer](https://github.com/google-deepmind/alphafold) designed for customizable high-throughput screening of protein-protein interactions. It extends AlphaFold’s capabilities by incorporating additional run options, such as customizable multimeric structural templates (TrueMultimer), [MMseqs2](https://github.com/soedinglab/MMseqs2) multiple sequence alignment (MSA) via [ColabFold](https://github.com/sokrypton/ColabFold) databases, protein fragment predictions, and the ability to incorporate mass spec data as an input using [AlphaLink2](https://github.com/Rappsilber-Laboratory/AlphaLink2/tree/main).
AlphaPulldown can be used in two ways: either by a two-step pipeline made of **python scripts**, or by a **Snakemake pipeline** as a whole. For details on using the Snakemake pipeline, please refer to the separate GitHub [**repository**](https://github.com/KosinskiLab/AlphaPulldownSnakemake).
## Overview
<picture>
<source media="(prefers-color-scheme: dark)" srcset="./manuals/AP_pipeline_dark.png">
<source media="(prefers-color-scheme: light)" srcset="./manuals/AP_pipeline.png">
<img alt="Shows an illustrated sun in light mode and a moon with stars in dark mode." src="./manuals/AP_pipeline.png">
</picture>
<p align='center'> <strong>Figure 1</strong> Overview of AlphaPulldown worflow </p>
The AlphaPulldown workflow involves the following 3 steps:
1. **Create and store MSA and template features**:
In this step, AlphaFold searches preinstalled databases using HMMER for each queried protein sequence and calculates multiple sequence alignments (MSAs) for all found homologs. It also searches for homolog structures to use as templates for feature generation. This step only requires CPU.
Customizable options include:
* To speed up the search process, [MMSeq2](https://doi.org/10.1038/s41592-022-01488-1) can be used instead of the default HHMER.
* Use custom MSA.
* Use a custom structural template, including a multimeric one (TrueMultimer mode).
2. **Structure prediction**:
In this step, the AlphaFold neural network runs and produces the final protein structure, requiring GPU. A key strength of AlphaPulldown is its ability to flexibly define how proteins are combined for the structure prediction of protein complexes. Here are the three main approaches you can use:
<picture>
<source media="(prefers-color-scheme: dark)" srcset="./manuals/AP_modes_dark.png">
<source media="(prefers-color-scheme: light)" srcset="./manuals/AP_modes.png">
<img alt="Shows an illustrated sun in light mode and a moon with stars in dark mode." src="./manuals/AP_modes.png">
</picture>
<p align='center'> <strong>Figure 2</strong> Three typical scenarios covered by AlphaPulldown</p>
* **Single file** (custom mode or homo-oligomer mode): Create a file where each row lists the protein sequences you want to predict together or each row tells the program to model homo-oligomers with your specified number of copies.
* **Multiple Files** (pulldown mode): Provide several files, each containing protein sequences. AlphaPulldown will automatically generate all possible combinations by pairing rows of protein names from each file.
* **All versus all**: AlphaPulldown will generate all possible non-redundant combinations of proteins in the list.
Additionally, AlphaPulldown also allows:
* Select only region(s) of proteins that you want to predict instead of the full-length sequences.
* Adjust MSA depth to control the influence of the initial MSA on the final model.
* Integrate high-throughput crosslinking data with AlphaFold modeling via [AlphaLink2](https://github.com/Rappsilber-Laboratory/AlphaLink2/tree/main).
3. **Downstream analysis of results**:
The results for all predicted models can be systematized using one of the following options:
* A table containing various scores and physical parameters of protein complex interactions.
* A Jupyter notebook with interactive 3D protein models and PAE plots.
<br>
# Alphafold databases
For the standard MSA and features calculation, AlphaPulldown requires genetic databases. Check if you have downloaded the necessary parameters and databases (e.g., BFD, MGnify, etc.) as instructed in [AlphaFold's documentation](https://github.com/KosinskiLab/alphafold). You should have a directory structured as follows:
<details>
<summary>
<b>Databases directory</b>
</summary>
```plaintext
alphafold_database/ # Total: ~ 2.2 TB (download: 438 GB)
bfd/ # ~ 1.7 TB (download: 271.6 GB)
# 6 files.
mgnify/ # ~ 64 GB (download: 32.9 GB)
mgy_clusters_2018_12.fa
params/ # ~ 3.5 GB (download: 3.5 GB)
# 5 CASP14 models,
# 5 pTM models,
# 5 AlphaFold-Multimer models,
# LICENSE,
# = 16 files.
pdb70/ # ~ 56 GB (download: 19.5 GB)
# 9 files.
pdb_mmcif/ # ~ 206 GB (download: 46 GB)
mmcif_files/
# About 227,000 .cif files.
obsolete.dat
pdb_seqres/ # ~ 0.2 GB (download: 0.2 GB)
pdb_seqres.txt
small_bfd/ # ~ 17 GB (download: 9.6 GB)
bfd-first_non_consensus_sequences.fasta
uniref30/ # ~ 86 GB (download: 24.9 GB)
# 14 files.
uniprot/ # ~ 98.3 GB (download: 49 GB)
uniprot.fasta
uniref90/ # ~ 58 GB (download: 29.7 GB)
uniref90.fasta
```
</details>
> [!NOTE]
> Uniclust30 is the version of the database generated before 2019, UniRef30 is the one generated after 2019. Please note that AlphaPulldown is using UniRef30_2023_02 by default. This version can be downloaded by [this script](https://github.com/KosinskiLab/alphafold/blob/main/scripts/download_uniref30.sh). Alternatively, please overwrite the default path to the uniref30 database using the --uniref30_database_path flag of create_individual_features.py.
> [!NOTE]
> Since the local installation of all genetic databases is space-consuming, you can alternatively use the [remotely-run MMseqs2 and ColabFold databases](https://github.com/sokrypton/ColabFold). Follow the corresponding [instructions](#13-run-using-mmseqs2-and-colabfold-databases-faster). However, for AlphaPulldown to function, you must download the parameters stored in the `params/` directory of the AlphaFold database.
<br>
<br>
# Snakemake AlphaPulldown
AlphaPulldown is available as a Snakemake pipeline, allowing you to sequentially execute **(1)** Generation of MSAs and template features, **(2)** Structure prediction, and **(3)** Results analysis without manual intervention between steps. For more details, please refer to the [**AlphaPulldownSnakemake**](https://github.com/KosinskiLab/AlphaPulldownSnakemake) repository.
> [!Warning]
> The Snakemake version of AlphaPulldown differs slightly from the conventional scripts-based AlphaPulldown in terms of input file specifications.
## 1. Installation
Before installation, make sure your python version is at least 3.10.
```bash
python3 --version
```
**Install Dependencies**
```bash
pip install snakemake==7.32.4 snakedeploy==0.10.0 pulp==2.7 click==8.1 cookiecutter==2.6
```
**Snakemake Cluster Setup**
In order to allow snakemake to interface with a compute cluster, we are going to use the [Snakemake-Profile for SLURM](https://github.com/Snakemake-Profiles/slurm). If you are not working on a SLURM cluster you can find profiles for different architectures [here](https://github.com/Snakemake-Profiles/slurm). The following will create a profile that can be used with snakemake and prompt you for some additional information.
```bash
git clone https://github.com/Snakemake-Profiles/slurm.git
profile_dir="${HOME}/.config/snakemake"
mkdir -p "$profile_dir"
template="gh:Snakemake-Profiles/slurm"
cookiecutter --output-dir "$profile_dir" "$template"
```
During the setup process, you will be prompted to answer several configuration questions. Below are the questions and the recommended responses:
- `profile_name [slurm]:` **slurm_noSidecar**
- `Select use_singularity:` **1 (False)**
- `Select use_conda:` **1 (False)**
- `jobs [500]:` *(Press Enter to accept default)*
- `restart_times [0]:` *(Press Enter to accept default)*
- `max_status_checks_per_second [10]:` *(Press Enter to accept default)*
- `max_jobs_per_second [10]:` *(Press Enter to accept default)*
- `latency_wait [5]:` **30**
- `Select print_shell_commands:` **1 (False)**
- `sbatch_defaults []:` **qos=low nodes=1**
- `Select cluster_sidecar:` **2 (no)**
- `cluster_name []:` *(Press Enter to leave blank)*
- `cluster_jobname [%r_%w]:` *(Press Enter to accept default)*
- `cluster_logpath [logs/slurm/%r/%j]:` *(Press Enter to accept default)*
- `cluster_config []:` *(Press Enter to leave blank)*
After responding to these prompts, your Slurm profile named *slurm_noSidecar* for Snakemake will be configured as specified.
**Singularity (Probably Installed Already)**: This pipeline makes use of containers for reproducibility. If you are working on the EMBL cluster singularity is already installed and you can skip this step. Otherwise, please install Singularity using the [official Singularity guide](https://sylabs.io/guides/latest/user-guide/quick_start.html#quick-installation-steps).
**Download The Pipeline**:
This will download the version specified by '--tag' of the snakemake pipeline and create the repository AlphaPulldownSnakemake or any other name you choose.
```bash
snakedeploy deploy-workflow \
https://github.com/KosinskiLab/AlphaPulldownSnakemake \
AlphaPulldownSnakemake \
--tag 1.4.0
cd AlphaPulldownSnakemake
```
>[!NOTE]
>If you want to use the latest version from GitHub replace `--tag X.X.X` to `--branch main`
**Install CCP4 package**:
To install the software needed for [the analysis step](https://github.com/KosinskiLab/AlphaPulldown?tab=readme-ov-file#3-analysis-and-visualization), please follow these instructions:
Download so-called Singularity image with our analysis software package
```bash
singularity pull docker://kosinskilab/fold_analysis:latest
singularity build --sandbox <writable_image_dir> fold_analysis_latest.sif
```
<writable_image_dir> can be any temporary directory and can be deleted later.
Download CCP4 from https://www.ccp4.ac.uk/download/#os=linux and copy to your server
```bash
tar xvzf ccp4-9.0.003-linux64.tar.gz
cd ccp4-9
cp bin/pisa bin/sc <writable_image_dir>/software/
cp /lib/* <writable_image_dir>/software/lib64/
```
Create a new Singularity with CCP4 included
```bash
cd <directory where you want to keep your local software>
singularity build fold_analysis_latest_withCCP4.sif <writable_image_dir>
```
It should create `fold_analysis_latest_withCCP4.sif` file.
You can delete the <writable_image_dir> now.
## 2. Configuration
Adjust `config/config.yaml` for your particular use case.
If you want to use CCP4 for analysis, open `config/config.yaml` in a text editor and change the path to the analysis container to:
```yaml
analysis_container : "/path/to/fold_analysis_latest_withCCP4.sif"
```
**input_files**
This variable holds the path to your sample sheet, where each line corresponds to a folding job. For this pipeline we use the following format specification:
```
protein:N:start-stop[_protein:N:start-stop]*
```
where protein is a path to a file with '.fasta' extension or uniprot ID, N is the number of monomers for this particular protein and start and stop are the residues that should be predicted. However, only protein is required, N, start and stop can be omitted. Hence the following folding jobs for the protein example containing residues 1-50 are equivalent:
```
example:2
example_example
example:2:1-50
example:1-50_example:1-50
example:1:1-50_example:1:1-50
```
This format similarly extends for the folding of heteromers:
```
example1_example2
```
Assuming you have two sample sheets config/sample_sheet1.csv and config/sample_sheet2.csv. The following would be equivalent to computing all versus all in sample_sheet1.csv:
```
input_files :
- config/sample_sheet1.csv
- config/sample_sheet1.csv
```
while the snippet below would be equivalent to computing the pulldown between sample_sheet1.csv and sample_sheet2.csv
```
input_files :
- config/sample_sheet1.csv
- config/sample_sheet2.csv
```
This format can be extended to as many files as you would like, but keep in mind the number of folds will increase dramatically.
```
input_files :
- config/sample_sheet1.csv
- config/sample_sheet2.csv
- ...
```
**alphafold_data_directory**
This is the path to your alphafold database.
**output_directory**
Snakemake will write the pipeline output to this directory. If it does not exist, it will be created.
**save_msa, use_precomputed_msa, predictions_per_model, number_of_recycles, report_cutoff**
Command line arguments that were previously pasesed to AlphaPulldown's run_multimer_jobs.py and create_notebook.py (report_cutoff).
**alphafold_inference_threads, alphafold_inference**
Slurm specific parameters that do not need to be modified by non-expert users.
**only_generate_features**
If set to True, stops after generating features and does not perform structure prediction and reporting.
## 3. Execution
After following the Installation and Configuration steps, you are now ready to run the snakemake pipeline. To do so, navigate into the cloned pipeline directory and run:
```bash
snakemake \
--use-singularity \
--singularity-args "-B /scratch:/scratch \
-B /g/kosinski:/g/kosinski \
--nv " \
--jobs 200 \
--restart-times 5 \
--profile slurm_noSidecar \
--rerun-incomplete \
--rerun-triggers mtime \
--latency-wait 30 \
-n
```
Here's a breakdown of what each argument does:
- `--use-singularity`: Enables the use of Singularity containers. This allows for reproducibility and isolation of the pipeline environment.
- `--singularity-args`: Specifies arguments passed directly to Singularity. In the provided example:
- `-B /scratch:/scratch` and `-B /g/kosinski:/g/kosinski`: These are bind mount points. They make directories from your host system accessible within the Singularity container. `--nv` ensures the container can make use of the hosts GPUs.
- `--profile name_of_your_profile`: Specifies the Snakemake profile to use (e.g., the SLURM profile you set up for cluster execution).
- `--rerun-triggers mtime`: Reruns a job if a specific file (trigger) has been modified more recently than the job's output. Here, `mtime` checks for file modification time.
- `--jobs 500`: Allows up to 500 jobs to be submitted to the cluster simultaneously.
- `--restart-times 10`: Specifies that jobs can be automatically restarted up to 10 times if they fail.
- `--rerun-incomplete`: Forces the rerun of any jobs that were left incomplete in previous Snakemake runs.
- `--latency-wait 30`: Waits for 30 seconds after a step finishes to check for the existence of expected output files. This can be useful in file-systems with high latencies.
- `-n`: Dry-run flag. This makes Snakemake display the commands it would run without actually executing them. It's useful for testing. To run the pipeline for real, simply remove this flag.
Executing the command above will perform submit the following jobs to the cluster:
![Snakemake rulegraph](manuals/dag.png)
<br>
<br>
# Run AlphaPulldown Python Command Line Interface
AlphaPulldown can be used as a set of scripts for every particular step.
1. [`create_individual_features.py`](#1-compute-multiple-sequence-alignment-msa-and-template-features-cpu-stage): Generates multiple sequence alignments (MSA), identifies structural templates, and stores the results in monomeric feature `.pkl` files.
2. [`run_multimer_jobs.py`](#2-predict-structures-gpu-stage): Executes the prediction of structures.
3. [`create_notebook.py`](#create-jupyter-notebook) and [`alpha-analysis.sif`](#create-results-table): Prepares an interactive Jupyter Notebook and a Results Table, respectively.
## 0. Installation
### 0.1. Create Anaconda environment
**Firstly**, install [Anaconda](https://www.anaconda.com/) and create an AlphaPulldown environment, gathering necessary dependencies. We recommend to use mamba to speed up solving of dependencies:
```bash
conda create -n AlphaPulldown -c omnia -c bioconda -c conda-forge python==3.11 openmm==8.0 pdbfixer==1.9 kalign2 hhsuite hmmer modelcif
```
**Optionally**, if you do not have it yet on your system, install [HMMER](http://hmmer.org/documentation.html) from Anaconda:
```bash
source activate AlphaPulldown
```
This usually works, but on some compute systems, users may prefer to use other versions or optimized builds of HMMER and HH-suite that are already installed.
### 0.2. Installation using pip
Activate the AlphaPulldown environment and install AlphaPulldown:
```bash
source activate AlphaPulldown
python3 -m pip install alphapulldown==2.0.0b6
```
```bash
pip install -U "jax[cuda12]"
```
> [!NOTE]
> **For older versions of AlphaFold**:
> If you haven't updated your databases according to the requirements of AlphaFold 2.3.0, you can still use AlphaPulldown with your older version of the AlphaFold database. Please follow the installation instructions on the [dedicated branch](https://github.com/KosinskiLab/AlphaPulldown/tree/AlphaFold-2.2.0).
### 0.3. Installation for the Downstream analysis tools
**Install CCP4 package**:
To install the software needed for [the anaysis step](https://github.com/KosinskiLab/AlphaPulldown?tab=readme-ov-file#3-analysis-and-visualization), please follow these instructions:
```bash
singularity pull docker://kosinskilab/fold_analysis:latest
singularity build --sandbox <writable_image_dir> fold_analysis_latest.sif
# Download the top one from https://www.ccp4.ac.uk/download/#os=linux
tar xvzf ccp4-9.0.003-linux64.tar.gz
cd ccp4-9
cp bin/pisa bin/sc <writable_image_dir>/software/
cp /lib/* <writable_image_dir>/software/lib64/
singularity build <new_image.sif> <writable_image_dir>
```
### 0.4. Installation for cross-link input data by [AlphaLink2](https://github.com/Rappsilber-Laboratory/AlphaLink2/tree/main) (optional!)
$\text{\color{red}Update the installation manual after resolving the dependency conflict.}$
1. Make sure you have installed PyTorch corresponding to the CUDA version you have. Here will take CUDA 11.7 and PyTorch 1.13.0 as an example:
```bash
pip install torch==1.13.0+cu117 --extra-index-url https://download.pytorch.org/whl/cu117
```
2. Compile [UniCore](https://github.com/dptech-corp/Uni-Core).
```bash
source activate AlphaPulldown
git clone https://github.com/dptech-corp/Uni-Core.git
cd Uni-Core
python setup.py install --disable-cuda-ext
# test whether unicore is successfully installed
python -c "import unicore"
```
You may see the following warning, but it's fine:
```plaintext
fused_multi_tensor is not installed corrected
fused_rounding is not installed corrected
fused_layer_norm is not installed corrected
fused_softmax is not installed corrected
```
4. Download the PyTorch checkpoints from [Zenodo](https://zenodo.org/records/8007238), unzip it, then you should obtain a file named: `AlphaLink-Multimer_SDA_v3.pt`
### 0.5. Installation for developers
Only for the developers who would like to modify AlphaPulldown's codes and test their modifications.
Please [add your SSH key to your GitHub account](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account)
<details>
<summary><b>Instructions</b></summary>
1. Clone the GitHub repo
```bash
git clone --recurse-submodules [email protected]:KosinskiLab/AlphaPulldown.git
cd AlphaPulldown
git submodule init
git submodule update
```
2. Create the Conda environment as described in [Create Anaconda environment](#1-create-anaconda-environment)
3. Install AlphaPulldown package and add its submodules to the Conda environment (does not work if you want to update the dependencies)
```bash
source activate AlphaPulldown
cd AlphaPulldown
pip install .
pip install -e . --no-deps
pip install -e ColabFold --no-deps
pip install -e alphafold --no-deps
```
You need to do it only once.
4. When you want to develop, activate the environment, modify files, and the changes should be automatically recognized.
5. Test your package during development using tests in `test/`, e.g.:
```bash
pip install pytest
pytest -s test/
pytest -s test/test_predictions_slurm.py
pytest -s test/test_features_with_templates.py::TestCreateIndividualFeaturesWithTemplates::test_1a_run_features_generation
```
6. Before pushing to the remote or submitting a pull request:
```bash
pip install .
pytest -s test/
```
to install the package and test. Pytest for predictions only works if SLURM is available. Check the created log files in your current directory.
</details>
<br>
## 1. Compute multiple sequence alignment (MSA) and template features (CPU stage)
>[!Note]
>If you work with proteins from model organisms you can directly download the features files from the [AlphaPulldown Features Database](#features-database) and skip this step.
### 1.1. Basic run
This is a general example of `create_individual_features.py` usage. For information on running specific tasks or parallel execution on a cluster, please refer to the corresponding sections of this chapter.
#### Input
At this step, you need to provide a [protein FASTA format](https://www.ncbi.nlm.nih.gov/WebSub/html/help/protein.html) file with all protein sequences that will be used for complex prediction.
Example of a FASTA file (`sequences.fasta`):
```plaintext
>proteinA
SEQUENCEOFPROTEINA
>proteinB
SEQUENCEOFPROTEINB
```
#### Script Execution
Activate the AlphaPulldown environment and run the script `create_individual_features.py` as follows:
```bash
source activate AlphaPulldown
create_individual_features.py \
--fasta_paths=<sequences.fasta> \
--data_dir=<path to alphafold databases> \
--output_dir=<dir to save the output objects> \
--max_template_date=<any date you want, format like: 2050-01-01> \
```
* Instead of `<sequences.fasta>` provide a path to your input FASTA file. You can also provide multiple comma-separated files.<br>
* Instead of `<path to alphafold databases>` provide a path to the genetic database (see [0. Alphafold-databases](#installation) of the installation part).<br>
* Instead of `<dir to save the output objects>` provide a path to the output directory, where your features files will be saved.<br>
* A date in the flag `--max_template_date` is needed to restrict the search of protein structures that are deposited before the indicated date. Unless the date is later than the date of your local genomic database's last update, the script will search for templates among all available structures.
Features calculation script `create_individual_features.py` has several optional FLAGS:
<details>
<summary>
Full list of arguments (FLAGS):
</summary>
* `--[no]save_msa_files`: By default is **False** to save storage stage but can be changed into **True**. If it is set to `True`, the program will create an individual folder for each protein. The output directory will look like:
```plaintext
output_dir
|- proteinA.pkl
|- proteinA
|- uniref90_hits.sto
|- pdb_hits.sto
|- etc.
|- proteinB.pkl
|- proteinB
|- uniref90_hits.sto
|- pdb_hits.sto
|- etc.
```
If `save_msa_files=False` then the `output_dir` will look like:
```plaintext
output_dir
|- proteinA.pkl
|- proteinB.pkl
```
* `--[no]use_precomputed_msas`: Default value is `False`. However, if you have already had MSA files for your proteins, please set the parameter to be True and arrange your MSA files in the format as below:
```plaintext
example_directory
|- proteinA
|- uniref90_hits.sto
|- pdb_hits.sto
|- ***.a3m
|- etc
|- proteinB
|- ***.sto
|- etc
```
Then, in the command line, set the `output_dir=/path/to/example_directory`.
* `--[no]skip_existing`: Default is `False` but if you have run the 1st step already for some proteins and now add new proteins to the list, you can change `skip_existing` to `True` in the command line to avoid rerunning the same procedure for the previously calculated proteins.
* `--seq_index`: Default is `None` and the program will run predictions one by one in the given files. However, you can set `seq_index` to a different number if you wish to run an array of jobs in parallel then the program will only run the corresponding job specified by the `seq_index`. e.g. the program only calculates features for the 1st protein in your FASTA file if `seq_index` is set to be 1. See also the Slurm sbatch script above for an example of how to use it for parallel execution. :exclamation: `seq_index` starts from 1.
* `--[no]use_mmseqs2`: Use mmseqs2 remotely or not. Default is False.
FLAGS related to TrueMultimer mode:
* `--path_to_mmt`: Path to directory with multimeric template mmCIF files.
* `--description_file`: Path to the text file with descriptions for generating features. **Please note**, the first column must be an exact copy of the protein description from your FASTA files. Please consider shortening them in FASTA files using your favorite text editor for convenience. These names will be used to generate pickle files with monomeric features!
The description.csv for the NS1-P85B complex should look like:
```plaintext
>sp|P03496|NS1_I34A1,3L4Q.cif,A
>sp|P23726|P85B_BOVIN,3L4Q.cif,C
```
In this example, we refer to the NS1 protein as chain A and to the P85B protein as chain C in multimeric template 3L4Q.cif.
**Please note**, that your template will be renamed to a PDB code taken from *_entry_id*. If you use a *.pdb file instead of *.cif, AlphaPulldown will first try to parse the PDB code from the file. Then it will check if the filename is 4-letter long. If it is not, it will generate a random 4-letter code and use it as the PDB code.
* `--threshold_clashes`: Threshold for VDW overlap to identify clashes. The VDW overlap between two atoms is defined as the sum of their VDW radii minus the distance between their centers. If the overlap exceeds this threshold, the two atoms are considered to be clashing. A positive threshold is how far the VDW surfaces are allowed to interpenetrate before considering the atoms to be clashing. (default: 1000, i.e. no threshold, for thresholding, use 0.6-0.9).
* `--hb_allowance`: Additional allowance for hydrogen bonding (default: 0.4) used for identifying clashing residues to be removed from a multimeric template. An allowance > 0 reflects the observation that atoms sharing a hydrogen bond can come closer to each other than would be expected from their VDW radii. The allowance is only subtracted for pairs comprised of a donor (or donor-borne hydrogen) and an acceptor. This is equivalent to using smaller radii to characterize hydrogen-bonding interactions.
* `--plddt_threshold`: Threshold for pLDDT score (default: 0) to be removed from a multimeric template (all residues with pLDDT>plddt_threshold are removed and modeled from scratch). Can be used only when multimeric templates are models generated by AlphaFold.
* `--new_uniclust_dir`: Please use this if you want to overwrite the default path to the uniclust database.
* `--[no]use_hhsearch`: Use hhsearch instead of hmmsearch when looking for structure template. Default is False.
* `--[no]multiple_mmts`: Use multiple multimeric templates per chain. Default is False.
</details>
#### Output
The result of `create_individual_features.py` run is pickle format features for each protein from the input FASTA file (e.g. `sequence_name_A.pkl` and `sequence_name_B.pkl`) stored in the `output_dir`.
> [!NOTE]
> The name of the pickles will be the same as the descriptions of the sequences in FASTA files (e.g. `>protein_A` in the FASTA file will yield `proteinA.pkl`). Note that special symbols such as `| : ; #`, after `>` will be replaced with `_`.
#### Next step
Proceed to the next step [2.1 Basic Run](#21-basic-run).
### 1.2. Example bash scripts for SLURM (EMBL cluster)
If you run AlphaPulldown on a computer cluster, you may want to execute feature creation in parallel. Here, we provide an example of code that is suitable for a cluster that utilizes SLURM Workload Manager.
<details>
<summary>For more details about the SLURM on the EMBL cluster, please refer to the [EMBL Cluster wiki](https://wiki.embl.de/cluster/Main_Page) using the EMBL network.</summary>
#### Input
For the following example, we will use [`example_2_sequences.fasta`](../example_data/example_2_sequences.fasta) as input.
#### Script Execution
Create the `create_individual_features_SLURM.sh` script and place the following code in it using vi, nano, or any other text editor. Replace input parameters with the appropriate arguments for the `create_individual_features.py` script as described in [Basic run](#11-basic-run) or any other type of run you intend to execute:
```bash
#!/bin/bash
#A typical run takes a couple of hours but may be much longer
#SBATCH --job-name=array
#SBATCH --time=10:00:00
#log files:
#SBATCH -e logs/create_individual_features_%A_%a_err.txt
#SBATCH -o logs/create_individual_features_%A_%a_out.txt
#qos sets priority
#SBATCH --qos=low
#Limit the run to a single node
#SBATCH -N 1
#Adjust this depending on the node
#SBATCH --ntasks=8
#SBATCH --mem=64000
module load HMMER/3.4-gompi-2023a
module load HH-suite/3.3.0-gompi-2023a
eval "$(conda shell.bash hook)"
module load CUDA/11.8.0
module load cuDNN/8.7.0.84-CUDA-11.8.0
conda activate AlphaPulldown
# CUSTOMIZE THE FOLLOWING SCRIPT PARAMETERS FOR YOUR SPECIFIC TASK:
####
create_individual_features.py \
--fasta_paths=example_1_sequences.fasta \
--data_dir=/scratch/AlphaFold_DBs/2.3.2
/ \
--output_dir=/scratch/mydir/test_AlphaPulldown/ \
--max_template_date=2050-01-01 \
--skip_existing=True \
--seq_index=$SLURM_ARRAY_TASK_ID
#####
```
Make the script executable by running:
```bash
chmod +x create_individual_features_SLURM.sh
```
Next, execute the following commands, replacing `<sequences.fasta>` with the path to your input FASTA file:
```bash
mkdir logs
#Count the number of jobs corresponding to the number of sequences:
count=`grep ">" <sequences.fasta> | wc -l`
#Run the job array, 100 jobs at a time:
sbatch --array=1-$count%100 create_individual_features_SLURM.sh
```
<details>
<summary>If you have several FASTA files, use the following commands:</summary>
Example for two files (For more files, create `count3`, `count4`, etc., variables and add them to the sum of counts):
```bash
mkdir logs
#Count the number of jobs corresponding to the number of sequences:
count1=`grep ">" <sequences1.fasta> | wc -l`
count2=`grep ">" <sequences2.fasta> | wc -l`
count=$(( $count1 + $count2 ))
#Run the job array, 100 jobs at a time:
sbatch --array=1-$count%100 create_individual_features_SLURM.sh
```
</details>
#### Next step
Proceed to the next step [2.2 Example run with SLURM (EMBL cluster)](#22-example-run-with-slurm-embl-cluster).
</details>
### 1.3. Run using MMseqs2 and ColabFold Databases (Faster)
MMseqs2 is another method for homolog search and MSA generation. It offers an alternative to the default HMMER and HHblits used by AlphaFold. The results of these different approaches might lead to slightly different protein structure predictions due to variations in the captured evolutionary information within the MSAs. AlphaPulldown supports the implementation of MMseqs2 search made by [ColabFold](https://github.com/sokrypton/ColabFold), which also provides a web server for MSA generation, so no local installation of databases is needed.
> **Cite:** If you use MMseqs2, please remember to cite:
Mirdita M, Schütze K, Moriwaki Y, Heo L, Ovchinnikov S, Steinegger M. ColabFold: Making protein folding accessible to all. Nature Methods (2022) doi: 10.1038/s41592-022-01488-1
<details>
#### Run MMseqs2 Remotely
> **CAUTION:** To avoid overloading the remote server, do not submit a large number of jobs simultaneously. If you want to calculate MSAs for many sequences, please use [MMseqs2 locally](#run-mmseqs2-locally).
To run `create_individual_features.py` using MMseqs2 remotely, add the `--use_mmseqs2=True` flag:
```bash
source activate AlphaPulldown
create_individual_features.py \
--fasta_paths=<sequences.fasta> \
--data_dir=<path to alphafold databases> \
--output_dir=<dir to save the output objects> \
--use_mmseqs2=True \
--max_template_date=<any date you want, format like: 2050-01-01> \
```
#### Output
After the script run is finished, your `output_dir` will look like this:
```plaintext
output_dir
|-proteinA.a3m
|-proteinA_env/
|-proteinA.pkl
|-proteinB.a3m
|-proteinB_env/
|-proteinB.pkl
...
```
Proceed to the next step [2.1 Basic Run](#21-basic-run).
#### Run MMseqs2 Locally
AlphaPulldown does **NOT** provide an interface or code to run MMseqs2 locally, nor will it install MMseqs2 or any other required programs. The user must install MMseqs2, ColabFold databases, ColabFold search, and other required dependencies and run MSA alignments first. An example guide can be found on the [ColabFold GitHub](https://github.com/sokrypton/ColabFold).
Suppose you have successfully run MMseqs2 locally using the `colab_search` program; it will generate an A3M file for each protein of your interest. Thus, your `output_dir` should look like this:
```plaintext
output_dir
|-0.a3m
|-1.a3m
|-2.a3m
|-3.a3m
...
```
These a3m files from `colabfold_search` are inconveniently named. Thus, we have provided a `rename_colab_search_a3m.py` script to help you rename all these files. Simply run:
```bash
# within the same conda env where you have installed AlphaPulldown
cd output_dir
rename_colab_search_a3m.py
```
Then your `output_dir` will become:
```plaintext
output_dir
|-proteinA.a3m
|-proteinB.a3m
|-proteinC.a3m
|-proteinD.a3m
...
```
Here, `proteinA`, `proteinB`, etc., correspond to the names in your input FASTA file (e.g., `>proteinA` will give you `proteinA.a3m`, `>proteinB` will give you `proteinB.a3m`, etc.).
> **NOTE:** You can also provide your own custom MSA file in `.a3m` format instead of using the files created by MMSeq2 or standard HHMER. Place appropriately named files in the output directory and use the code as follows.
After this, go back to your project directory with the original FASTA file and point to this directory in the command:
```bash
source activate AlphaPulldown
create_individual_features.py \
--fasta_paths=<sequences.fasta> \
--data_dir=<path to alphafold databases> \
--output_dir=<output_dir> \
--skip_existing=False \
--use_mmseqs2=True \
--seq_index=<any number you want or skip the flag to run all one after another>
```
AlphaPulldown will automatically search each protein's corresponding a3m files. In the end, your `output_dir` will look like:
```plaintext
output_dir
|-proteinA.a3m
|-proteinA.pkl
|-proteinB.a3m
|-proteinB.pkl
|-proteinC.a3m
|-proteinC.pkl
...
```
#### Next step
Proceed to the next step [2.1 Basic Run](#21-basic-run).
</details>
### 1.4. Run with custom templates (TrueMultimer)
Instead of using the default search through the PDB database for structural templates, you can provide a custom database. AlphaPulldown supports a feature called "True Multimer," which allows AlphaFold to use multi-chain structural templates during the prediction process. This can be beneficial for protein complexes where the arrangement of the chains may vary.
<details>
<summary>Details</summary>
#### Input
1. **Prepare a FASTA File:** Create a FASTA file containing all protein sequences that will be used for predictions as outlined in [1.1 Basic run](#11-basic-run).
3. **Create a Template Directory:** Designate a folder (e.g., `templates`) to store your custom template files in PDB or CIF format.
4. **Create a description file:** This `description.csv` file links protein sequences to templates:
```plaintext
>proteinA,TMPL.cif,A
>proteinB,TMPL.cif,B
```
* **Column 1** (>proteinA): Must exactly match protein descriptions from your FASTA file, including the `>` symbol.
* **Column 2** (TMPL.cif): The filename of your template structure in PDB or CIF format.
* **Column 3** (A): The chain ID within the template that the query sequence corresponds to.
The result pkl files will be stored as: `proteinA.TMPL.cif.A.pkl` and `proteinA.TMPL.cif.A.pkl`.
**For Multiple Templates:** If you want to provide multiple templates for a single protein, add additional rows with the same protein name but different templates and chain IDs and **use flag --multiple_template=True**:
```plaintext
>proteinA,TMPL.cif,A
>proteinA,TMP2.cif,B
>proteinB,TMPL.cif,B
```
>**CAUTION:** Even though you can use multiple templates for a single chain, this feature is not fully supported in AlphaPulldown yet and might bring unexpected results.
>**NOTE:** Your template will be renamed to a PDB code taken from *_entry_id*. If you use a *.pdb file instead of *.cif, AlphaPulldown will first try to parse the PDB code from the file. Then it will check if the filename is 4-letter long. If it is not, it will generate a random 4-letter code and use it as the PDB code.
#### Script Execution
>**Tip:** If you have already generated feature files (`.pkl`) for protein sequences without custom templates or with the
different templates, instead of generating them once again with the new template, you can go directly to the [prediction step](#24-run-with-custom-templates-truemultimer) and use `templates` and `description.csv` in combination with previously generated features. During the run, it will replace templates in the features `.pkl` file with the new one.
Run the following script:
```bash
create_individual_features.py \
--fasta_paths=<sequences.fasta> \
--path_to_mmt=<path to template directory> \
--description_file=<description.csv> \
--data_dir=<path to alphafold databases> \
--output_dir=<dir to save the output objects> \
--max_template_date=<any date you want, format like: 2050-01-01> \
--save_msa_files=True \
--use_precomputed_msas=True \
--skip_existing=True
```
Compared to [1.1. Basic run](#11-basic-run), this example differs in:
* `--path_to_mmt=<path to template directory>`: Path to your `templates` directory with custom template files in PDB or CIF format.
* `--description_file=<description.csv>`: Path to the description file.
>**Warning!** Feature files generated with custom templates have the same names as standard feature files. To avoid overwriting existing feature files or skipping their generation if `--skip_existing=True`, please create a separate directory to save custom features.
#### Output
Pickle format features for each protein in the `description.csv` file stored in the `output_dir`.
#### Next step
Go to the next step [2.4. Run with custom templates (TrueMultimer)](#24-run-with-custom-templates-truemultimer).
</details>
<br>
## 2. Predict structures (GPU stage)
### 2.1. Basic run
This is a general example of `run_multimer_jobs.py` usage. For information on running specific tasks or parallel execution on a cluster, please refer to the corresponding sections of this chapter.
#### Input
This step requires the pickle files (.pkl) generated during the [first step](#1-compute-multiple-sequence-alignment-msa-and-template-features-cpu-stage). Additionally, you'll need to provide a list of protein combinations `protein_list.txt` you intend to predict.
Here's how to structure your combinations file `protein_list.txt`. Protein names should correspond to the names of features files (`proteinA` for `proteinA.pkl`):
**Prediction of monomers**:
```plaintext
proteinA
proteinB
proteinC,1-100
```
* Each line is a separate prediction.
* Lines like `proteinA` will trigger a prediction of the entire sequence.
* To predict specific residue ranges (e.g., the first 100 residues of proteinC), use the format "proteinC,1-100".
**Prediction of complexes**:
```plaintext
proteinA;proteinB;proteinC
proteinB;proteinB
proteinB,4
proteinC,2;proteinA
proteinA,4,1-100;proteinB