Skip to content

Commit 13cf707

Browse files
authoredOct 14, 2024
v1.1.0
New update fixes problems with installation and compatibility: - updated to python 3.10 - updated biopython to >1.8 - added CUDA version dependence for the installation script to choose correct jaxlib version - merged all package requirement into a single conda command - updated Readme - fixed relative paths for running the scripts to enable execution from anywhere
1 parent 3f8fdbb commit 13cf707

10 files changed

+57
-37
lines changed
 

‎README.md

+10-6
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,23 @@ First you need to clone this repository. Replace **[install_folder]** with the p
1010

1111
`git clone https://github.com/martinpacesa/BindCraft [install_folder]`
1212

13-
The navigate into your install folder using *cd* and run the installation code. In *pkg_manager* specify whether you are using 'mamba' or 'conda', if left blank it will use 'conda' by default.
13+
The navigate into your install folder using *cd* and run the installation code. BindCraft requires a CUDA-compatible Nvidia graphics card to run. In the *cuda* setting, please specify the CUDA version compatible with your graphics card, for example '11.8'. If unsure, leave blank but it's possible that the installation might select the wrong version, which will lead to errors. In *pkg_manager* specify whether you are using 'mamba' or 'conda', if left blank it will use 'conda' by default.
1414

15-
`bash install_bindcraft.sh --pkg_manager 'conda'`
15+
`bash install_bindcraft.sh --cuda '12.4' --pkg_manager 'conda'`
1616

1717
## Google Colab
1818
<a href="https://colab.research.google.com/github/martinpacesa/BindCraft/blob/main/notebooks/BindCraft.ipynb">
1919
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
2020
</a> <br />
2121
We prepared a convenient google colab notebook to test the bindcraft code functionalities. However, as the pipeline requires significant amount of GPU memory to run for larger target+binder complexes, we highly recommend to run it using a local installation and at least 32 Gb of GPU memory.
2222

23+
**Always try to trim the input target PDB to the smallest size possible! It will significantly speed up the binder generation and minimise the GPU memory requirements.**
24+
25+
**Be ready to run at least a few hundred trajectories to see some accepted binders, for difficult targets it might even be a few thousand.**
26+
2327

2428
## Running the script locally and explanation of settings
25-
To run the script locally, first you need to configure your target .json file in the *target_settings* folder. In the json file are the following settings:
29+
To run the script locally, first you need to configure your target .json file in the *settings_target* folder. In the json file are the following settings:
2630

2731
```
2832
design_path -> path where to save designs and statistics
@@ -35,16 +39,16 @@ number_of_final_designs -> how many designs that pass all filters to aim for,
3539
```
3640
Then run the binder design script:
3741

38-
`sbatch bindcraft.slurm --settings 'path/to/settings_target/.json' --filters 'path/to/settings_filters/.json' --advanced 'path/to/settings_advanced/.json'`
42+
`sbatch ./bindcraft.slurm --settings './settings_target/PDL1.json' --filters './settings_filters/default_filters.json' --advanced './settings_advanced/4stage_multimer.json'`
3943

4044
The *settings* flag should point to your target .json which you set above. The *filters* flag points to the json where the design filters are specified (default is ./filters/default_filters.json). The *advanced* flag points to your advanced settings (default is ./advanced_settings/4stage_multimer.json). If you leave out the filters and advanced settings flags it will automatically point to the defaults.
4145

4246
Alternatively, if your machine does not support SLURM, you can run the code directly by activating the environment in conda and running the python code:
4347

4448
```
4549
conda activate BindCraft
46-
cd /path/to/install/folder/
47-
python -u /work/lpdi/users/mpacesa/Pipelines/BindCraft/bindcraft.py --settings 'path/to/settings_target/.json' --filters 'path/to/settings_filters/.json' --advanced 'path/to/settings_advanced/.json'
50+
cd /path/to/bindcraft/folder/
51+
python -u ./bindcraft.py --settings './settings_target/PDL1.json' --filters './settings_filters/default_filters.json' --advanced './settings_advanced/4stage_multimer.json'
4852
```
4953

5054
**We recommend to generate at least a 100 final designs passing all filters, then order the top 5-20 for experimental characterisation.** If high affinity binders are required, it is better to screen more, as the ipTM metric used for ranking is not a good predictor for affinity, but has been shown to be a good binary predictor of binding.

‎bindcraft.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@
3434
design_models, prediction_models, multimer_validation = load_af2_models(advanced_settings["use_multimer_design"])
3535

3636
### set package settings
37-
advanced_settings["af_params_dir"] = os.path.realpath('')
38-
advanced_settings["dssp_path"] = os.path.join(os.path.realpath(''), 'functions/dssp')
39-
advanced_settings["dalphaball_path"] = os.path.join(os.path.realpath(''), 'functions/DAlphaBall.gcc')
37+
bindcraft_folder = os.path.dirname(os.path.realpath(__file__))
38+
advanced_settings["af_params_dir"] = bindcraft_folder
39+
advanced_settings["dssp_path"] = os.path.join(bindcraft_folder, 'functions/dssp')
40+
advanced_settings["dalphaball_path"] = os.path.join(bindcraft_folder, 'functions/DAlphaBall.gcc')
4041

4142
### generate directories, design path names can be found within the function
4243
design_paths = generate_directories(target_settings["design_path"])

‎bindcraft.slurm

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ conda activate BindCraft
1515
# alternatively you can source the environment directly
1616
#source /path/to/mambaforge/bin/activate /path/to/mambaforge/envs/BindCraft
1717

18+
# Get the directory where the bindcraft script is located
19+
SCRIPT_DIR=$(dirname "$0")
1820

1921
# Parsing command line options
2022
SETTINGS=""
@@ -37,4 +39,4 @@ echo "Running the BindCraft pipeline"
3739
echo "Running binder design for target ${SETTINGS}"
3840
echo "Design settings used: ${ADVANCED}"
3941
echo "Filtering designs based on ${FILTERS}"
40-
python -u ./bindcraft.py --settings "${SETTINGS}" --filters "${FILTERS}" --advanced "${ADVANCED}"
42+
python -u "${SCRIPT_DIR}/bindcraft.py" --settings "${SETTINGS}" --filters "${FILTERS}" --advanced "${ADVANCED}"

‎functions/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from .biopython_utils import *
1414
from .generic_utils import *
1515

16-
# set slurm environment modules and suppress warnings
16+
# suppress warnings
1717
#os.environ["SLURM_STEP_NODELIST"] = os.environ["SLURM_NODELIST"]
1818
warnings.simplefilter(action='ignore', category=FutureWarning)
1919
warnings.simplefilter(action='ignore', category=DeprecationWarning)

‎functions/biopython_utils.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from collections import defaultdict
99
from scipy.spatial import cKDTree
1010
from Bio import BiopythonWarning
11-
from Bio.PDB import PDBParser, DSSP, Selection, Polypeptide, PDBIO, Select, Chain, Superimposer
11+
from Bio.PDB import PDBParser, DSSP, Selection, Polypeptide, PDBIO, Select, Chain, Superimposer
1212
from Bio.SeqUtils.ProtParam import ProteinAnalysis
1313
from Bio.PDB.Selection import unfold_entities
1414
from Bio.PDB.Polypeptide import is_aa
@@ -126,6 +126,13 @@ def calculate_clash_score(pdb_file, threshold=2.4, only_ca=False):
126126

127127
return len(valid_pairs)
128128

129+
three_to_one_map = {
130+
'ALA': 'A', 'CYS': 'C', 'ASP': 'D', 'GLU': 'E', 'PHE': 'F',
131+
'GLY': 'G', 'HIS': 'H', 'ILE': 'I', 'LYS': 'K', 'LEU': 'L',
132+
'MET': 'M', 'ASN': 'N', 'PRO': 'P', 'GLN': 'Q', 'ARG': 'R',
133+
'SER': 'S', 'THR': 'T', 'VAL': 'V', 'TRP': 'W', 'TYR': 'Y'
134+
}
135+
129136
# identify interacting residues at the binder interface
130137
def hotspot_residues(trajectory_pdb, binder_chain="B", atom_distance_cutoff=4.0):
131138
# Parse the PDB file
@@ -154,8 +161,10 @@ def hotspot_residues(trajectory_pdb, binder_chain="B", atom_distance_cutoff=4.0)
154161
for binder_idx, close_indices in enumerate(pairs):
155162
binder_residue = binder_atoms[binder_idx].get_parent()
156163
binder_resname = binder_residue.get_resname()
157-
if binder_resname in Polypeptide.standard_aa_names:
158-
aa_single_letter = Polypeptide.three_to_one(binder_resname)
164+
165+
# Convert three-letter code to single-letter code using the manual dictionary
166+
if binder_resname in three_to_one_map:
167+
aa_single_letter = three_to_one_map[binder_resname]
159168
for close_idx in close_indices:
160169
target_residue = target_atoms[close_idx].get_parent()
161170
interacting_residues[binder_residue.id[1]] = aa_single_letter

‎install_bindcraft.sh

+24-15
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
################## specify conda/mamba folder, and installation folder for git repositories, and whether to use mamba or $pkg_manager
44
# Default value for pkg_manager
55
pkg_manager='conda'
6+
cuda=''
67

78
# Define the short and long options
8-
OPTIONS=p:
9-
LONGOPTIONS=pkg_manager:
9+
OPTIONS=p:c:
10+
LONGOPTIONS=pkg_manager:,cuda:
1011

1112
# Parse the command-line options
1213
PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTIONS --name "$0" -- "$@")
@@ -19,6 +20,10 @@ while true; do
1920
pkg_manager="$2"
2021
shift 2
2122
;;
23+
-c|--cuda)
24+
cuda="$2"
25+
shift 2
26+
;;
2227
--)
2328
shift
2429
break
@@ -30,6 +35,10 @@ while true; do
3035
esac
3136
done
3237

38+
# Example usage of the parsed variables
39+
echo "Package manager: $pkg_manager"
40+
echo "CUDA version (if provided): $cuda"
41+
3342
############################################################################################################
3443
############################################################################################################
3544
################## initialisation
@@ -40,26 +49,26 @@ install_dir=$(pwd)
4049

4150
### BindCraft install
4251
printf "Installing BindCraft environment\n"
43-
$pkg_manager create --name BindCraft python=3.9 -y
44-
conda activate BindCraft
52+
$pkg_manager create --name BindCraft python=3.10 -y
53+
CONDA_BASE=$(conda info --base)
54+
source ${CONDA_BASE}/bin/activate ${CONDA_BASE}/envs/BindCraft
55+
printf "BindCraft environment activated at ${CONDA_BASE}/envs/BindCraft"
4556

46-
# install helpful packages
47-
$pkg_manager install pandas numpy biopython==1.79 scipy"<1.13.0" pdbfixer seaborn tqdm jupyter ffmpeg -y
57+
# install required packages
58+
if [ -n "$cuda" ]; then
59+
CONDA_OVERRIDE_CUDA="$cuda" $pkg_manager install pip pandas matplotlib numpy"<2.0.0" biopython scipy pdbfixer seaborn tqdm jupyter ffmpeg pyrosetta fsspec py3dmol chex dm-haiku dm-tree joblib ml-collections immutabledict optax jaxlib=*=*cuda* jax cuda-nvcc cudnn -c conda-forge -c anaconda -c nvidia --channel https://conda.graylab.jhu.edu -y
60+
else
61+
$pkg_manager install pip pandas matplotlib numpy"<2.0.0" biopython scipy pdbfixer seaborn tqdm jupyter ffmpeg pyrosetta fsspec py3dmol chex dm-haiku dm-tree joblib ml-collections immutabledict optax jaxlib=*=*cuda* jax cuda-nvcc cudnn -c conda-forge -c anaconda -c nvidia --channel https://conda.graylab.jhu.edu -y
62+
fi
4863

4964
# install ColabDesign
50-
pip install git+https://github.com/sokrypton/ColabDesign.git
51-
pip install --upgrade "jax[cuda]" -f https://storage.googleapis.com/jax-releases/jax_releases.htm
52-
pip install matplotlib==3.7.1
53-
54-
# install PyRosetta
55-
$pkg_manager install pyrosetta --channel https://conda.graylab.jhu.edu -y
65+
pip3 install git+https://github.com/sokrypton/ColabDesign.git --no-deps
5666

5767
# Download AlphaFold2 weights
5868
mkdir -p ${install_dir}/params/
5969
cd ${install_dir}/params/
6070
wget -P ${install_dir}/params/ https://storage.googleapis.com/alphafold/alphafold_params_2022-12-06.tar
6171
tar -xvf ${install_dir}/params/alphafold_params_2022-12-06.tar
62-
rm ${install_dir}/params/alphafold_params_2022-12-06.tar
6372

6473
# chmod executables
6574
chmod +x ${install_dir}/functions/dssp
@@ -79,6 +88,6 @@ printf "$pkg_manager cleaned up\n"
7988
################## finish script
8089
t=$SECONDS
8190
printf "Finished setting up BindCraft environment\n"
82-
printf "Activate environment using command: \"conda activate BindCraft\""
91+
printf "Activate environment using command: \"$pkg_manager activate BindCraft\""
8392
printf "\n"
84-
printf "Installation took $(($t / 3600)) hours, $((($t / 60) % 60)) minutes and $(($t % 60)) seconds."
93+
printf "Installation took $(($t / 3600)) hours, $((($t / 60) % 60)) minutes and $(($t % 60)) seconds."

‎notebooks/BindCraft.ipynb

-5
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
"Resolving deltas: 100% (26/26), done.\n",
6060
"Installing ColabDesign\n",
6161
"Installing PyRosetta\n",
62-
"Downgrading BioPython\n",
6362
"BindCraft installation is finished, ready to run!\n",
6463
"CPU times: user 1.86 s, sys: 244 ms, total: 2.11 s\n",
6564
"Wall time: 2min 10s\n"
@@ -97,10 +96,6 @@
9796
" import pyrosettacolabsetup\n",
9897
" pyrosettacolabsetup.install_pyrosetta(serialization=True, cache_wheel_on_google_drive=False)\n",
9998
"\n",
100-
" print(\"Downgrading BioPython\")\n",
101-
" os.system(\"pip uninstall -y biopython\")\n",
102-
" os.system(\"pip install biopython==1.79\")\n",
103-
"\n",
10499
" # download params\n",
105100
" if not os.path.isfile(\"bindcraft/params/done.txt\"):\n",
106101
" print(\"downloading AlphaFold params\")\n",

‎settings_advanced/4stage_multimer_betasheet.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@
5757
"save_trajectory_pickle": false,
5858
"max_trajectories": false,
5959
"enable_rejection_check": true,
60-
"acceptance_rate": 0.05,
60+
"acceptance_rate": 0.01,
6161
"start_monitoring": 50
6262
}

‎settings_advanced/4stage_multimer_peptides.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@
5757
"save_trajectory_pickle": false,
5858
"max_trajectories": false,
5959
"enable_rejection_check": true,
60-
"acceptance_rate": 0.05,
60+
"acceptance_rate": 0.01,
6161
"start_monitoring": 50
6262
}

‎settings_target/PDL1.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
"target_hotspot_residues": "56",
77
"lengths": [65, 150],
88
"number_of_final_designs": 100
9-
}
9+
}

0 commit comments

Comments
 (0)