Complex
This document describes how to create a Complex object, that can be used to run Docking, ABFE, and historically RBFE (the Complex.rbfe helper is removed).
Deprecated: Complex
The Complex class is deprecated. Prefer Docking, ABFE, PocketFinder, and SystemPrep for new projects. The legacy RBFE helper is removed. This how-to remains for legacy notebooks.
Creating a Complex¶
From a directory¶
# here, we're using the example data directory
from deeporigin.drug_discovery import Complex, BRD_DATA_DIR
sim = Complex.from_dir(BRD_DATA_DIR)
The directory should contain:
- exactly one PDB file for the protein
- one or more SDF files for the ligands. Each SDF file can contain one or more molecules.
From Protein and Ligand objects¶
A Complex object can be also be constructed using Protein and Ligand objects.
from deeporigin.drug_discovery import Complex, BRD_DATA_DIR, Protein, Ligand
protein = Protein.from_file(BRD_DATA_DIR / "brd.pdb")
ligand = Ligand.from_sdf(BRD_DATA_DIR / "brd-2.sdf")
sim = Complex(protein=protein, ligands=[ligand])
From LigandSet objects¶
A Complex object can also be constructed using Protein and LigandSet objects.
from deeporigin.drug_discovery import Complex, BRD_DATA_DIR, Protein, LigandSet
protein = Protein.from_file(BRD_DATA_DIR / "brd.pdb")
ligands = LigandSet.from_dir(BRD_DATA_DIR)
sim = Complex(protein=protein, ligands=ligands)
Modifying a Complex¶
You can modify a Complex object by adding or replacing ligands.
from deeporigin.drug_discovery import Complex, Protein, Ligand, BRD_DATA_DIR
protein = Protein.from_file(BRD_DATA_DIR / "brd.pdb")
ligand = Ligand.from_sdf(BRD_DATA_DIR / "brd-2.sdf")
ligand3 = Ligand.from_sdf(BRD_DATA_DIR / "brd-3.sdf")
# Create a complex with just the protein
sim = Complex(protein=protein)
# Add a single ligand
sim.ligands = ligand3
# Add another ligand
ligand4 = Ligand.from_sdf(BRD_DATA_DIR / "brd-4.sdf")
sim.ligands = sim.ligands + ligand4
# Replace all ligands
ligand5 = Ligand.from_sdf(BRD_DATA_DIR / "brd-5.sdf")
sim.ligands = ligand5 # Replace with a single ligand
Constructing Ligands
To see how to construct Ligands, see Ligands
Constructing the Protein
To see how to construct the Protein, see Proteins
Preparing a Complex¶
To prepare a protein-ligand complex for simulation or further analysis, use the Complex.prepare() method. This method runs system preparation on a given ligand in the context of the complex's protein, handling tasks such as protonation, water retention, and box padding.
Typically, you would call this method using a ligand in the complex:
result = sim.prepare(sim.ligands[0])
result.prepared_systems[0].show()
result is a FunctionResult that wraps the API response. The prepared proteins are available as a list on result.prepared_systems.
When preparing all ligands at once, the result aggregates costs and systems:
result = sim.prepare()
result.prepared_systems # list of Protein objects, one per ligand
result.cost # total cost across all preparations
You should see something like:
which shows you the prepared system.
Estimating cost¶
To get a cost estimate without running system preparation, use quote=True:
result = sim.prepare(sim.ligands[0], quote=True)
result.estimate # estimated cost in dollars
result.cost # None (function was not executed)
System preparation parameters
Look at the reference documentation to understand parameters for system preparation.
Specifying a Client¶
A Complex can be configured with a DeepOriginClient explicitly, using:
sim = Complex.from_dir(..., client=client)
You do not typically need to do this. If no client is specified, it is automatically configured using saved tokens and config.