### Install PyRosetta Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/README.md Install the PyRosetta wheel required for post-processing tasks. ```bash wget https://west.rosettacommons.org/pyrosetta/release/release/PyRosetta4.MinSizeRel.python39.linux.wheel/pyrosetta-2024.39+release.59628fb-cp39-cp39-linux_x86_64.whl pip install pyrosetta-2024.39+release.59628fb-cp39-cp39-linux_x86_64.whl ``` -------------------------------- ### Install DiffPepDock dependencies Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/examples/DiffPepDock_demo.ipynb Installs required Python packages and the pdbfixer tool. ```python #@title ### Install dependencies os.system("pip install wget wandb fair-esm biotite pyrootutils easydict biopython tqdm ml-collections mdtraj GPUtil dm-tree tmtools py3Dmol") os.system("wget https://west.rosettacommons.org/pyrosetta/release/release/PyRosetta4.MinSizeRel.python312.linux.wheel/pyrosetta-2024.39+release.59628fb-cp312-cp312-linux_x86_64.whl") os.system("pip install pyrosetta-2024.39+release.59628fb-cp312-cp312-linux_x86_64.whl") os.system("rm pyrosetta-2024.39+release.59628fb-cp312-cp312-linux_x86_64.whl") pdbfixer_folder = "pdbfixer" if not os.path.isdir(pdbfixer_folder): print("Installing pdbfixer...") os.system("git clone https://github.com/openmm/pdbfixer.git") os.chdir(pdbfixer_folder) os.system("python setup.py install") os.chdir("..") print("pdbfixer is installed.") else: print("pdbfixer is already cloned.") os.system("pip install hydra-core hydra-joblib-launcher") ``` -------------------------------- ### Create Conda Environment Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/README.md Set up the required dependencies using the provided environment file. ```bash conda env create -f environment.yml conda activate diffpepbuilder ``` -------------------------------- ### Download DiffPepDock model assets Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/examples/DiffPepDock_demo.ipynb Downloads the model checkpoint and sets up the directory structure if not already present. ```python #@title ### Download model assets import os diffpep_folder = "DiffPepBuilder" checkpoint_file = os.path.join(diffpep_folder, "experiments", "checkpoints", "diffpepdock_v1.pth") if not (os.path.isdir(diffpep_folder) and os.path.isfile(checkpoint_file)): print("Installing DiffPepDock...") if not os.path.isdir(diffpep_folder): os.system("git clone https://github.com/YuzheWangPKU/DiffPepBuilder.git") os.chdir(diffpep_folder) if not os.path.isfile(checkpoint_file): print("Downloading model weights...") os.system("wget https://zenodo.org/records/15398020/files/diffpepdock_v1.pth") os.makedirs("experiments/checkpoints/", exist_ok=True) os.system("mv diffpepdock_v1.pth experiments/checkpoints/") os.chdir("..") print("DiffPepDock is installed and ready.") else: print("DiffPepDock is already installed and ready.") ``` -------------------------------- ### Finetune Model for Docking Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/README.md Runs the finetuning process for docking tasks using the specified configuration file. ```bash export BASE_PATH="your/path/to/DiffPepBuilder" torchrun --nproc-per-node=8 experiments/train.py --config-name=finetune ``` -------------------------------- ### Download Model Weights Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/README.md Downloads the required model weights from Zenodo and moves them to the appropriate directory. ```bash wget https://zenodo.org/records/15398020/files/diffpepdock_v1.pth mv diffpepdock_v1.pth experiments/checkpoints/ ``` -------------------------------- ### Download Model Weights Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/README.md Downloads the required model weights from Zenodo and moves them to the appropriate directory. ```bash wget https://zenodo.org/records/12794439/files/diffpepbuilder_v1.pth mv diffpepbuilder_v1.pth experiments/checkpoints/ ``` -------------------------------- ### Download and Extract Training Data Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/README.md Downloads the raw dataset from Zenodo and extracts it into the local data directory. ```bash wget https://zenodo.org/records/13744959/files/PepPC-F_raw_data.tar.gz mkdir data/PepPC-F_raw_data tar -xvf PepPC-F_raw_data.tar.gz --strip-components=1 -C data/PepPC-F_raw_data ``` -------------------------------- ### Run Post-processing Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/README.md Performs side chain reconstruction and optimization on the generated peptide binders. ```bash export BASE_PATH="your/path/to/DiffPepBuilder" python experiments/run_postprocess.py --in_pdbs runs/inference --ori_pdbs examples/receptor_data --amber_relax --rosetta_relax ``` -------------------------------- ### Download DiffPepBuilder model assets Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/examples/DiffPepBuilder_demo.ipynb Downloads the repository, model weights, and required libraries if they are not already present in the local environment. ```python #@title ### Download model assets import os diffpep_folder = "DiffPepBuilder" ssbuilder_lib = os.path.join(diffpep_folder, "SSbuilder", "SSBLIB") checkpoint_file = os.path.join(diffpep_folder, "experiments", "checkpoints", "diffpepbuilder_v1.pth") if not (os.path.isdir(diffpep_folder) and os.path.isdir(ssbuilder_lib) and os.path.isfile(checkpoint_file)): print("Installing DiffPepBuilder...") if not os.path.isdir(diffpep_folder): os.system("git clone https://github.com/YuzheWangPKU/DiffPepBuilder.git") os.chdir(diffpep_folder) if not os.path.isdir(ssbuilder_lib): print("Installing SSBLIB...") os.system("tar -xvf SSbuilder/SSBLIB.tar.gz -C SSbuilder") if not os.path.isfile(checkpoint_file): print("Downloading model weights...") os.system("wget https://zenodo.org/records/12794439/files/diffpepbuilder_v1.pth") os.makedirs("experiments/checkpoints/", exist_ok=True) os.system("mv diffpepbuilder_v1.pth experiments/checkpoints/") os.chdir("..") print("DiffPepBuilder is installed and ready.") else: print("DiffPepBuilder is already installed and ready.") ``` -------------------------------- ### Download PepPC raw data Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/datasets/README.md Use wget to download the compressed raw data archive for the PepPC dataset from Zenodo. ```bash wget https://zenodo.org/records/13744959/files/PepPC_raw_data.tar.gz ``` -------------------------------- ### Download PepPC-F raw data Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/datasets/README.md Use wget to download the compressed raw data archive for the PepPC-F dataset from Zenodo. ```bash wget https://zenodo.org/records/13744959/files/PepPC-F_raw_data.tar.gz ``` -------------------------------- ### Clone Repository Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/README.md Download the source code from the GitHub repository. ```bash git clone https://github.com/YuzheWangPKU/DiffPepBuilder.git cd DiffPepBuilder ``` -------------------------------- ### Train DiffPepBuilder Model Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/README.md Initiates the training process using torchrun. Ensure the BASE_PATH environment variable is set correctly. ```bash export BASE_PATH="your/path/to/DiffPepBuilder" torchrun --nproc-per-node=8 experiments/train.py ``` -------------------------------- ### Execute Protein-Peptide Docking Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/README.md Runs the docking process using the preprocessed metadata. Ensure the BASE_PATH is set correctly and adjust nproc-per-node based on available GPU resources. ```bash export BASE_PATH="your/path/to/DiffPepBuilder" torchrun --nproc-per-node=8 experiments/run_docking.py data.val_csv_path=data/docking_data/metadata_test.csv ``` -------------------------------- ### Execute Protein-Peptide Docking Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/examples/DiffPepDock_demo.ipynb Configures the base path and runs the docking script using torchrun. Ensure the environment variable BASE_PATH is set correctly before execution. ```python #@title ### Run docking #@markdown - Postprocessing will be performed automatically after docking. os.environ['BASE_PATH'] = "/content/DiffPepBuilder" !torchrun --nproc-per-node=1 DiffPepBuilder/experiments/run_docking.py \ data.val_csv_path=test_case/metadata_test.csv \ experiment.use_ddp=False \ experiment.num_gpus=1 \ experiment.num_loader_workers=1 ``` -------------------------------- ### Download Docking Results Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/examples/DiffPepDock_demo.ipynb Compresses the docking results directory into a tarball and triggers a browser download. ```python #@title ### Download results #@markdown - The docking results will be saved in the `DiffPepBuilder/runs` folder. !tar --directory=/content/DiffPepBuilder/runs -czf /content/docking_results.tar.gz docking files.download("/content/docking_results.tar.gz") ``` -------------------------------- ### Customize Docking and Post-processing Settings Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/examples/DiffPepDock_demo.ipynb Updates the docking configuration YAML file with sampling parameters and relaxation settings. ```python #@title ### Customize docking settings import yaml #@markdown #### Sampling params denoising_steps = "200" #@param [100, 200, 500] noise_scale = "1" #@param [0.5, 1, 1.5, 2, 2.5] samples_per_sequence = 4 #@param {type:"integer"} #@markdown #### Postprocessing params amber_relax = True #@param {type:"boolean"} #@markdown - Amber relaxation runs slowly on Colab. You may skip this step for faster inference with minimal quality loss. rosetta_relax = True #@param {type:"boolean"} yaml_file_path = "DiffPepBuilder/config/docking.yaml" with open(yaml_file_path, 'r') as file: yaml_data = yaml.safe_load(file) yaml_data['data']['num_t'] = int(denoising_steps) yaml_data['experiment']['noise_scale'] = float(noise_scale) yaml_data['experiment']['eval_batch_size'] = int(samples_per_sequence) yaml_data['data']['num_repeat_per_eval_sample'] = int(samples_per_sequence) yaml_data['postprocess']['amber_relax'] = amber_relax yaml_data['postprocess']['rosetta_relax'] = rosetta_relax with open(yaml_file_path, 'w') as file: yaml.dump(yaml_data, file, default_flow_style=False) ``` -------------------------------- ### Run Inference Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/README.md Executes the inference script to generate peptide binders, requiring the base path to be set and GPU configuration. ```bash export BASE_PATH="your/path/to/DiffPepBuilder" torchrun --nproc-per-node=8 experiments/run_inference.py data.val_csv_path=data/receptor_data/metadata_test.csv ``` -------------------------------- ### Run Postprocessing Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/README.md Executes postprocessing on docking results to compute binding ddG values, optionally applying Amber and Rosetta relaxation. ```bash export BASE_PATH="your/path/to/DiffPepBuilder" python experiments/run_postprocess.py --in_pdbs runs/docking --ori_pdbs examples/docking_data --amber_relax --rosetta_relax ``` -------------------------------- ### Run de novo generation Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/examples/DiffPepBuilder_demo.ipynb Executes the inference script using torchrun to generate peptide binders based on the provided configuration. ```python #@title ### Run *de novo* generation os.environ['BASE_PATH'] = "/content/DiffPepBuilder" !torchrun --nproc-per-node=1 DiffPepBuilder/experiments/run_inference.py \ data.val_csv_path=test_case/metadata_test.csv \ experiment.use_ddp=False \ experiment.num_gpus=1 \ experiment.num_loader_workers=1 ``` -------------------------------- ### Preprocess Docking Data Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/README.md Prepares target and peptide sequences for docking by processing input files into the specified directory. ```bash python experiments/process_batch_dock.py --pdb_dir examples/docking_data --write_dir data/docking_data --receptor_info_path examples/docking_data/docking_cases.json --peptide_seq_path examples/docking_data/peptide_seq.fasta ``` -------------------------------- ### Preprocess Training Data Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/README.md Processes raw PDB files into a structured dataset format suitable for training. ```bash python experiments/process_dataset.py --pdb_dir data/PepPC-F_raw_data --write_dir data/complex_dataset ``` -------------------------------- ### Configure Docking Mode and Sequence Input Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/examples/DiffPepDock_demo.ipynb Uses ipywidgets to toggle between single and batch docking modes and save peptide sequences to a FASTA file. ```python #@title ### Specify peptide sequences import ipywidgets from IPython.display import display, clear_output mode_dropdown = ipywidgets.Dropdown( options=['single', 'batch'], value='single', description='Docking Mode:', style={'description_width': 'initial'} ) # Widgets for SINGLE mode peptide_seq = ipywidgets.Text( value='VLGEPRYAFNFN', description='Peptide Sequence:', style={'description_width': 'initial'} ) peptide_id = ipywidgets.Text( value='nat', description='Peptide ID:', style={'description_width': 'initial'} ) save_button = ipywidgets.Button( description='Save Sequence', button_style='success' ) # Widgets for BATCH mode upload_widget = ipywidgets.FileUpload( accept='.fasta', multiple=False, description='Upload FASTA' ) process_button = ipywidgets.Button( description='Process Upload', button_style='info' ) output = ipywidgets.Output() def on_mode_change(change): with output: clear_output(wait=True) if change['new'] == 'single': display(ipywidgets.VBox([peptide_seq, peptide_id, save_button])) else: display(ipywidgets.VBox([upload_widget, process_button])) def save_sequence(btn): seq = peptide_seq.value.strip() pid = peptide_id.value.strip() if not seq or not pid: with output: print("Please provide both Sequence and ID.") return path = os.path.join("test_case", "peptide_seq.fasta") with open(path, 'w') as f: f.write(f">{pid}\n{seq}\n") with output: print(f"Saved single-sequence file to {path}") def process_upload(btn): if not upload_widget.value: with output: clear_output(wait=True) print("No FASTA file uploaded.") return with output: clear_output(wait=True) for fname, fileinfo in upload_widget.value.items(): dest = os.path.join("test_case", "peptide_seq.fasta") with open(dest, 'wb') as f: f.write(fileinfo['content']) print(f"Saved batch file to {dest}") mode_dropdown.observe(on_mode_change, names='value') save_button.on_click(save_sequence) process_button.on_click(process_upload) display(mode_dropdown, output) on_mode_change({'new': mode_dropdown.value}) ``` -------------------------------- ### Download generated results Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/examples/DiffPepBuilder_demo.ipynb Compresses the inference directory into a tarball and triggers a browser download in a Jupyter environment. ```python #@title ### Download results !tar --directory=/content/DiffPepBuilder/runs -czf /content/designed_binders.tar.gz inference files.download("/content/designed_binders.tar.gz") ``` -------------------------------- ### Run Postprocessing Protocol Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/examples/DiffPepBuilder_demo.ipynb Executes the postprocessing script on generated PDB files. This process is computationally intensive and recommended for local machines with high CPU availability. ```python #@title ### (Optional) Run postprocessing #@markdown - This step executes slowly on Colab; we recommend running it on a local machine with more CPU cores available os.environ['BASE_PATH'] = "/content/DiffPepBuilder" !python DiffPepBuilder/experiments/run_postprocess.py --in_pdbs /content/DiffPepBuilder/runs/inference --ori_pdbs /content/DiffPepBuilder/examples/receptor_data --nproc 2 --amber_relax --rosetta_relax ``` -------------------------------- ### Customize generation settings Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/examples/DiffPepBuilder_demo.ipynb Updates the inference configuration file with sampling parameters, peptide length constraints, and disulfide bond settings. ```python #@title ### Customize generation settings import yaml #@markdown #### Sampling params denoising_steps = "200" #@param [100, 200, 500] noise_scale = "1" #@param [0.5, 1, 1.5, 2, 2.5] seq_temperature = "0.1" #@param [0.1, 0.5, 1, 2.5, 10] #@markdown #### Peptide length min_length = 12 #@param {type:"integer"} max_length = 16 #@param {type:"integer"} samples_per_length = 4 #@param {type:"integer"} #@markdown #### Disulfide bond settings build_ss_bond = True #@param {type:"boolean"} max_ss_bond = 2 #@param {type:"integer"} entropy_threshold = 0.01 #@param [0.001, 0.01, 0.05, 0.1, 0.5] yaml_file_path = "DiffPepBuilder/config/inference.yaml" with open(yaml_file_path, 'r') as file: yaml_data = yaml.safe_load(file) yaml_data['inference']['denoising']['num_t'] = int(denoising_steps) yaml_data['inference']['denoising']['noise_scale'] = float(noise_scale) yaml_data['inference']['sampling']['samples_per_length'] = samples_per_length yaml_data['inference']['sampling']['min_length'] = min_length yaml_data['inference']['sampling']['max_length'] = max_length yaml_data['inference']['sampling']['seq_temperature'] = float(seq_temperature) yaml_data['inference']['ss_bond']['build_ss_bond'] = build_ss_bond yaml_data['inference']['ss_bond']['max_ss_bond'] = max_ss_bond yaml_data['inference']['ss_bond']['entropy_threshold'] = float(entropy_threshold) with open(yaml_file_path, 'w') as file: yaml.dump(yaml_data, file, default_flow_style=False) ``` -------------------------------- ### Specify receptor information Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/examples/DiffPepDock_demo.ipynb Configures the receptor PDB file and binding parameters for the docking task. ```python #@title ### Specify receptor information from google.colab import files import json os.makedirs("test_case", exist_ok=True) receptor_type = "default (7Z6F)" #@param ["default (7Z6F)", "uploaded"] if receptor_type == "uploaded": uploaded_pdb = files.upload() file_name = next(iter(uploaded_pdb)) if not file_name.endswith(".pdb"): raise ValueError("Please upload in PDB format.") os.system(f"cp {file_name} test_case/") os.system(f"cp test_case/{file_name} DiffPepBuilder/examples/docking_data/") else: file_name = "7Z6F.pdb" os.system(f"cp DiffPepBuilder/examples/docking_data/7Z6F.pdb test_case/") #@markdown - **Note**: please remove non-protein components from the PDB file and ensure that the CA atoms are present. #@markdown - **Note**: please remove any underscores (`_`) from the receptor PDB file name, as the script interprets `_` as a delimiter. lig_chain = "A" #@param {type:"string"} #@markdown - Chain ID of the **reference** ligand. Please set to `None` if no reference ligand is included in the PDB file. #@markdown The model will prioritize reference ligand information over the binding motif if both are given. motif = None #@param {type:"string"} #@markdown - Comma-separated residue IDs of the binding motif on the receptor. An example is `"B40, B58-59, B71-72, B87"` key = os.path.splitext(file_name)[0] data = {} if lig_chain and lig_chain != "None": data['lig_chain'] = lig_chain if motif and motif != "None": data['motif'] = motif.replace(",", "-") json_file_write_path = "test_case/docking_cases.json" final_data = {key: data} with open(json_file_write_path, 'w') as file: json.dump(final_data, file, indent=4) ``` -------------------------------- ### Preprocess receptor data Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/examples/DiffPepBuilder_demo.ipynb Runs the receptor processing script using the configuration generated in the previous step. ```python #@title ### Preprocess receptors !python DiffPepBuilder/experiments/process_receptor.py \ --pdb_dir test_case \ --write_dir test_case \ --receptor_info_path test_case/de_novo_cases.json ``` -------------------------------- ### Specify receptor information Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/examples/DiffPepBuilder_demo.ipynb Configures the target receptor, ligand chains, and binding hotspots or motifs, saving the configuration to a JSON file. ```python #@title ### Specify receptor information from google.colab import files import json os.makedirs("test_case", exist_ok=True) receptor_type = "default (ALK1)" #@param ["default (ALK1)", "uploaded"] if receptor_type == "uploaded": uploaded_pdb = files.upload() file_name = next(iter(uploaded_pdb)) if not file_name.endswith(".pdb"): raise ValueError("Please upload in PDB format.") os.system(f"cp {file_name} test_case/") os.system(f"cp {file_name} DiffPepBuilder/examples/receptor_data/") else: file_name = "alk1.pdb" os.system(f"cp DiffPepBuilder/examples/receptor_data/alk1.pdb test_case/") #@markdown - **Note**: please remove non-protein components from the PDB file and ensure that the CA atoms are present. #@markdown - **Note**: please remove any underscores (`_`) from the receptor PDB file name, as the script interprets `_` as a delimiter. lig_chain = None #@param {type:"string"} #@markdown - Chain ID of the **reference** ligand. Please set to `None` if no reference ligand is included in the PDB file. #@markdown The model will prioritize reference ligand information over the hotspots and motif if both are given. hotspots = "B40, B58-59, B71-72, B87" #@param {type:"string"} motif = "B38-42, B47-50, B52-61, B64-67, B69-77, B82-87" #@param {type:"string"} #@markdown - **Note**: the model will prioritize hotspots over the motif when both are given. See the [paper](https://arxiv.org/abs/2405.00128) for more details. key = os.path.splitext(file_name)[0] data = {} if lig_chain and lig_chain != "None": data['lig_chain'] = lig_chain if hotspots and hotspots != "None": data['hotspots'] = hotspots.replace(",", "-") if motif and motif != "None": data['motif'] = motif.replace(",", "-") json_file_write_path = "test_case/de_novo_cases.json" final_data = {key: data} with open(json_file_write_path, 'w') as file: json.dump(final_data, file, indent=4) ``` -------------------------------- ### Extract SSBLIB Data Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/README.md Unzip the required SSBLIB data files before running design protocols. ```bash cd SSbuilder tar -xvf SSBLIB.tar.gz ``` -------------------------------- ### Preprocess Receptor and Peptide Data Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/examples/DiffPepDock_demo.ipynb Executes the batch processing script to prepare docking cases and generate ESM embeddings. ```python #@title ### Preprocess receptor and peptide sequence data !python DiffPepBuilder/experiments/process_batch_dock.py \ --pdb_dir test_case \ --write_dir test_case \ --receptor_info_path test_case/docking_cases.json \ --peptide_seq_path test_case/peptide_seq.fasta ``` -------------------------------- ### Preprocess Receptor Data Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/README.md Processes the receptor PDB files using the provided JSON configuration for residue identification. ```bash python experiments/process_receptor.py --pdb_dir examples/receptor_data --write_dir data/receptor_data --receptor_info_path examples/receptor_data/de_novo_cases.json ``` -------------------------------- ### Split Dataset Source: https://github.com/yuzhewangpku/diffpepbuilder/blob/main/README.md Divides the processed dataset into training and validation sets based on the specified number of validation samples. ```bash python experiments/split_dataset.py --input_path data/complex_dataset/metadata.csv --output_path data/complex_dataset --num_val 200 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.