%load_ext autoreload
%autoreload 2
%load_ext jupyter_black
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,
)
import deeporigin
deeporigin.__version__
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
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
ligands.show_grid()
Assign Ligands to Complex¶
Associate the ligands with the protein complex. This prepares the system for docking calculations.
sim.ligands = ligands
sim
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
Single Ligand Docking Example¶
Let's start with a simple example: docking a single ligand into a pocket. This demonstrates the basic docking workflow:
- Dock the ligand - Calculate possible binding poses
- View the poses - Visualize the docked conformations
- Analyze results - Examine binding energies and scores
- Filter top poses - Select the best binding pose
The dock() function returns a LigandSet object containing all calculated binding poses.
poses = sim.protein.dock(
pocket=pockets[0],
ligand=sim.ligands[0],
)
View Docking Poses¶
Visualize all the calculated poses for the ligand. Each pose represents a different binding conformation with its own binding energy and score.
sim.protein.show(poses=poses)
Analyze Docking Results¶
Convert the poses to a pandas DataFrame for detailed analysis. This allows you to:
- Compare binding energies across poses
- Examine pose scores
- Filter and sort poses based on various criteria
poses.to_dataframe()
poses
Filter Best Poses¶
Select the top pose (best binding conformation) for the ligand. The filter_top_poses() method selects poses based on binding energy and score criteria.
top_pose = poses.filter_top_poses()
sim.protein.show(poses=top_pose)
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
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
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()
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
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
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)