%load_ext autoreload
%autoreload 2
from dotenv import load_dotenv
load_dotenv()
True
Docking Workflow¶
This notebook demonstrates how to perform molecular docking using Deep Origin's drug discovery platform. You'll learn how to:
- Load and prepare proteins - Load a protein structure and prepare it for docking
- Find binding pockets - Identify potential binding sites on the protein
- Dock ligands - Perform docking calculations for single or multiple ligands
- Monitor jobs - Track the progress of docking calculations
- Analyze results - Visualize and filter docking poses
Let's get started!
Setup¶
First, we'll import the necessary Deep Origin drug discovery modules.
from deeporigin.drug_discovery import (
Complex,
DATA_DIR,
Protein,
LigandSet,
)
Load Protein Structure¶
Here we load a protein structure from a PDB file. The Complex object represents a protein-ligand complex and will be used throughout the docking workflow.
protein = Protein.from_file(DATA_DIR / "brd" / "brd.pdb")
sim = Complex(protein=protein)
sim
Complex(protein=brd with 0 ligands)
Load Ligands¶
Load a set of ligands from a CSV file containing SMILES strings. The LigandSet object allows you to work with multiple ligands at once. You can visualize them in a grid to see what molecules you're working with.
ligands = LigandSet.from_csv(DATA_DIR / "ligands" / "smiles_to_dock.csv")
ligands
LigandSet with 16 ligands
16 unique SMILES
Properties: initial_smiles
Use .to_dataframe() to convert to a dataframe, .show_df() to view dataframewith structures, or .show() for 3D visualization
ligands.show_grid()
Protonate Ligands¶
It is reccomended that ligands are protonated before running docking
ligands.protonate()
Protonating ligands: 0%| | 0/16 [00:00<?, ?ligand/s]
Protonating ligands: 100%|██████████| 16/16 [00:00<00:00, 537.68ligand/s]
LigandSet with 16 ligands
16 unique SMILES
Properties: initial_smiles
Use .to_dataframe() to convert to a dataframe, .show_df() to view dataframewith structures, or .show() for 3D visualization
Assign Ligands to Complex¶
Associate the ligands with the protein complex. This prepares the system for docking calculations.
sim.ligands = ligands
sim
Complex(protein=brd with 16 ligands)
Visualize the Protein¶
Display the protein structure in 3D. This helps you understand the protein's structure before proceeding with docking.
sim.protein.show()
Prepare the Protein¶
Before docking, we need to prepare the protein structure. Water molecules are typically removed from crystal structures as they can interfere with docking calculations.
sim.protein.remove_water()
sim.protein.show()
Find Pockets¶
The find_pockets() method of Protein uses computational methods to detect cavities and potential binding sites on the protein surface.
pockets = sim.protein.find_pockets(pocket_count=1)
sim.protein.show(pockets=pockets)
Inspect Binding Pockets¶
View the detected binding pockets. Each pocket represents a potential binding site. You'll typically want to dock ligands into the most promising pocket (often the largest or most druggable one).
pockets
[Pocket: ╭─────────────────────────┬──────────────╮ │ Name │ pocket_1 │ ├─────────────────────────┼──────────────┤ │ Color │ red │ ├─────────────────────────┼──────────────┤ │ Volume │ 382.0 ų │ ├─────────────────────────┼──────────────┤ │ Total SASA │ 1383.8657 Ų │ ├─────────────────────────┼──────────────┤ │ Polar SASA │ 372.27518 Ų │ ├─────────────────────────┼──────────────┤ │ Polar/Apolar SASA ratio │ 0.36800975 │ ├─────────────────────────┼──────────────┤ │ Hydrophobicity │ 30.518518 │ ├─────────────────────────┼──────────────┤ │ Polarity │ 11.0 │ ├─────────────────────────┼──────────────┤ │ Drugability score │ 0.94493204 │ ╰─────────────────────────┴──────────────╯]
Bulk Docking Workflow¶
For drug discovery, you'll often want to dock many ligands at once. The bulk docking workflow allows you to:
- Submit multiple docking jobs - Dock all ligands in your ligand set
- Monitor progress - Track job status in real-time
- Retrieve results - Download all poses once calculations complete
- Analyze at scale - Compare binding across all ligands
The run() method with quote=True first provides a cost estimate before submitting jobs. You can specify:
- pocket: Which binding pocket to use
- batch_size: How many ligands to process per batch
jobs = sim.docking.run(
pocket=pockets[0],
quote=True,
batch_size=8,
)
jobs
Starting docking jobs: 0%| | 0/2 [00:00<?, ?it/s]
Starting docking jobs: 100%|██████████| 2/2 [00:00<00:00, 76.59it/s]
Docking brd.pdb to 16 ligands. (2 jobs)
Jobs Quoted
All 2 jobs have been quoted. For details look at the Billing tab. To approve and start the runs, call the confirm() method.
| executionID | resourceID | Status | Started At | Running Time |
|---|---|---|---|---|
| 4007fc1d-ffc9-4218-b438-eb417d3189e8 | avzxo4qrgp4v7x33ni8s | Quoted | None | None |
| f2d7c977-4a56-4eaf-ab72-ee2dd337628b | 1mohz3o44rqmroq1sc8y | Quoted | None | None |
Review Job Details¶
Before confirming, review the job details including:
- Number of ligands to dock
- Estimated cost
- Expected completion time
Use confirm() to submit the jobs for execution.
jobs.confirm()
jobs
Docking brd.pdb to 16 ligands. (2 jobs)
Average speed: 0.00 dockings/minute
| executionID | resourceID | Status | Started At | Running Time |
|---|---|---|---|---|
| 4007fc1d-ffc9-4218-b438-eb417d3189e8 | avzxo4qrgp4v7x33ni8s | Running | now | None |
| f2d7c977-4a56-4eaf-ab72-ee2dd337628b | 1mohz3o44rqmroq1sc8y | Running | now | None |
Monitor Job Progress¶
The watch() method monitors your docking jobs and updates you on their progress. It will:
- Check job status at regular intervals
- Display progress updates
- Notify you when jobs complete
You can cancel jobs if needed using jobs.cancel().
jobs.watch()
Docking brd.pdb to 16 ligands. (2 jobs)
Average speed: 0.00 dockings/minute
| executionID | resourceID | Status | Started At | Running Time |
|---|---|---|---|---|
| 4007fc1d-ffc9-4218-b438-eb417d3189e8 | avzxo4qrgp4v7x33ni8s | Succeeded | 20 seconds ago | 0 minutes |
| f2d7c977-4a56-4eaf-ab72-ee2dd337628b | 1mohz3o44rqmroq1sc8y | Succeeded | 20 seconds ago | 0 minutes |
Retrieve Docking Results¶
Once jobs complete, retrieve all poses using get_poses(). This downloads all calculated poses for all ligands in your set.
poses = sim.docking.get_poses()
poses
Downloading files: 0%| | 0/16 [00:00<?, ?file/s]
Downloading files: 25%|██▌ | 4/16 [00:00<00:00, 36.69file/s]
Downloading files: 100%|██████████| 16/16 [00:00<00:00, 91.93file/s]
LigandSet with 256 ligands
16 unique SMILES
Properties: Binding Energy, POSE SCORE, SCORE, SMILES, initial_smiles
Use .to_dataframe() to convert to a dataframe, .show_df() to view dataframewith structures, or .show() for 3D visualization
Convert to DataFrame for Analysis¶
Convert poses to a DataFrame for detailed analysis. This enables:
- Statistical analysis of binding energies
- Comparison across ligands
- Filtering and sorting
- Export to CSV or other formats
df = poses.to_dataframe()
df
| SMILES | POSE SCORE | Binding Energy | SCORE | |
|---|---|---|---|---|
| 0 | Fc1c(-c2cccc3ccccc23)ncc2c(N3C[C@H]4CC[C@@H](C... | 0.704003 | -8.416734 | -12.340761 |
| 1 | Fc1c(-c2cccc3ccccc23)ncc2c(N3C[C@H]4CC[C@@H](C... | 0.622063 | -8.215181 | -10.475386 |
| 2 | Fc1c(-c2cccc3ccccc23)ncc2c(N3C[C@H]4CC[C@@H](C... | 0.619683 | -8.784129 | -12.177119 |
| 3 | Fc1c(-c2cccc3ccccc23)ncc2c(N3C[C@H]4CC[C@@H](C... | 0.614134 | -9.716379 | -12.612789 |
| 4 | Fc1c(-c2cccc3ccccc23)ncc2c(N3C[C@H]4CC[C@@H](C... | 0.598104 | -8.464557 | -11.153189 |
| ... | ... | ... | ... | ... |
| 251 | C=CC(=O)N1CCN(c2nnc(-c3ccccc3OC)c3cc(-c4c(O)cc... | 0.558711 | -7.040850 | -10.172739 |
| 252 | C=CC(=O)N1CCN(c2nnc(-c3ccccc3OC)c3cc(-c4c(O)cc... | 0.542668 | -6.298942 | -7.821764 |
| 253 | C=CC(=O)N1CCN(c2nnc(-c3ccccc3OC)c3cc(-c4c(O)cc... | 0.542479 | -7.659334 | -6.126631 |
| 254 | C=CC(=O)N1CCN(c2nnc(-c3ccccc3OC)c3cc(-c4c(O)cc... | 0.518609 | -7.863280 | -11.947805 |
| 255 | C=CC(=O)N1CCN(c2nnc(-c3ccccc3OC)c3cc(-c4c(O)cc... | 0.508119 | -5.374318 | -5.179104 |
256 rows × 4 columns
Visualize Statistics of All Poses¶
Create a scatter plot showing all poses from all docked ligands. The plot displays binding energy vs Pose Score. Hover over each point to see details about the ligand and pose.
poses.plot()
Visualize Statistics of Best Poses¶
Display the top pose for each ligand in the protein structure. This gives you a visual overview of how different ligands bind to the protein, helping you identify promising candidates for further study.
top_poses = poses.filter_top_poses()
top_poses.plot()
Show best poses¶
Find the best pose for each ligand and visualize their conformations in the protein structure. This helps identify the most promising binding modes across your ligand set.
sim.protein.show(poses=top_poses)