Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions scripts/discovery/gold_docking_examples/ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Docking with the CSD Python API

Short, self-contained examples of the main GOLD docking modes, using the
CSD Python API. Each one uses a literature-backed system, runs end to end, and
reports the RMSD of its poses to the crystal structure.

Written using **CSD Python API 3.9.0**. Docking requires a CSD-Discovery or
CSD-Enterprise licence.

## Getting started

Every example reads prepared input files that are fetched from the RCSB PDB (as mmCIF) and
cleaned up by a shared script. Run it first:

```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[markdownlint] reported by reviewdog 🐶
error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]

python prepare_inputs.py # all systems
python prepare_inputs.py 1KE7 # or just one
```

That downloads each entry, removes waters, takes the native ligand out of the
binding site, adds hydrogens, and writes a `<code>_protein.mol2` plus a
`<code>_reference.mol2` into the relevant example directory. Each example needs
the same three things, and they come from those two files:

* a protein with waters removed, the native ligand taken out and hydrogens added
* the native ligand on its own, used to define the binding site
* a reference ligand in its crystallographic pose, used to measure RMSD

You can then run whichever example you are interested in, from its own directory:

```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[markdownlint] reported by reviewdog 🐶
error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]

cd normal_docking
python normal_docking.py
```

## The examples

Each directory has its own `ReadMe.md` covering that example in full; the
sections below are the short version.

| Directory | Mode | System |
|---|---|---|

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[markdownlint] reported by reviewdog 🐶
error MD060/table-column-style Table column style [Table pipe is missing space to the left for style "compact"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[markdownlint] reported by reviewdog 🐶
error MD060/table-column-style Table column style [Table pipe is missing space to the left for style "compact"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[markdownlint] reported by reviewdog 🐶
error MD060/table-column-style Table column style [Table pipe is missing space to the left for style "compact"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[markdownlint] reported by reviewdog 🐶
error MD060/table-column-style Table column style [Table pipe is missing space to the right for style "compact"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[markdownlint] reported by reviewdog 🐶
error MD060/table-column-style Table column style [Table pipe is missing space to the right for style "compact"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[markdownlint] reported by reviewdog 🐶
error MD060/table-column-style Table column style [Table pipe is missing space to the right for style "compact"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[markdownlint-fix] reported by reviewdog 🐶

Suggested change
|---|---|---|
| --- | --- | --- |

| `normal_docking` | Plain redocking | VEGFR2 (PDB 1Y6B) |
| `pharmacophore_constraint` | Pharmacophore constraint | CDK2 + LS3 (PDB 1KE7) |
| `scaffold_constraint` | Scaffold match constraint | CDK2, AT7519 series (PDB 2VTQ, 2VU3) |
| `covalent_docking` | Covalent, with warhead transformation | KRAS G12C + sotorasib (PDB 6OIM) |
| `metalloprotein_docking` | Coordinating a catalytic metal | Carbonic anhydrase II + acetazolamide (PDB 3HS4) |
| `virtual_screening` | Library screening and enrichment | MAPK1 / ERK2 (PDB 4ZZN) |

### Normal docking

Redocking a ligand into the structure it was solved in. 1Y6B belongs to the Astex Diverse
Set (Hartshorn *et al.*, *J. Med. Chem.* **2007**, *50*, 726), the standard
high-quality test set for docking validation. Success is conventionally an RMSD
of 2 Å or better.

### Pharmacophore constraint

A pharmacophore constraint is a scoring reward: poses
that put an atom of the requested type near a chosen point score better, and
poses that miss it are less competitive. Used here to require the hinge
hydrogen bond that ATP-competitive kinase inhibitors almost always make. In
1KE7, that's Leu83 NH donating to an LS3 oxygen.

### Scaffold constraint

For a congeneric series where one member has been solved and you want the
binding mode of a close analogue. The constraint substructure-matches a template
onto the ligand and adds a distance constraint per matched atom pair, so the
shared core is held on a spring while GOLD searches the rest.

2VTQ and 2VU3 are isomorphous, so no superposition is needed. For structures
that are not, superpose first with `Protein.ChainSuperposition`.

### Metalloprotein docking

Carbonic anhydrase II is a zinc enzyme: the metal is held by His94,
His96 and His119, and acetazolamide's sulfonamide takes the fourth coordination
position. GOLD determines the coordination geometry itself. It superimposes
tetrahedral, trigonal bipyramidal and octahedral templates on the coordinating
protein atoms and keeps the best fit, then turns the unoccupied positions into
fitting points.

### Virtual screening

Redocking asks whether a protocol reproduces a known pose. Screening asks a
different question: does the score rank actives above inactives? The example
docks a small library and reports a ROC curve, its AUC, and an enrichment
factor.

The library is sampled from **LIT-PCBA** (Tran-Nguyen, Jacquemard & Rognan,
*J. Chem. Inf. Model.* **2020**, *60*, 4263), whose inactives are molecules that
were assayed and found to be inactive, rather than property-matched decoys
assumed to be inactive. `prepare_screening_library.py` downloads the AVE-unbiased
release (about 57 MB), takes 20 actives and 200 inactives from the MAPK1
validation split, and generates 3D conformers.

A real screen would typically use the whole set. This sample however is sized to finish quickly on a laptop,
which means the ROC curve is noisy and the enrichment factor is quoted at 5%
rather than the usual 1%.

## Reading the results

Every script prints the fitness and the RMSD to the reference for each pose.
You can set `settings.reference_ligand_file`
and read the `Gold.Reference.RMSD` attribute back off each docked pose:

```python
for pose in docker.results.ligands:
print(pose.identifier, pose.fitness(), pose.attributes['Gold.Reference.RMSD'])
```

## Plotting alongside the CSD API

There is an additional optional package, MatPlotLib, used to plot the ROC curve in the virtual screening example.
It is imported in the virtual screening example but can be skipped if not installed.
The other examples do not require it.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Metalloprotein docking — carbonic anhydrase II

Coordinating a catalytic zinc.

System: human carbonic anhydrase II with acetazolamide (PDB 3HS4, 1.1 Å).
Acetazolamide (marketed as Diamox) with carbonic anhydrase is a zinc metalloenzyme: the Zn is held by His94, His96 and His119, and the
inhibitor's sulfonamide nitrogen takes the fourth coordination position.

GOLD works out metal coordination geometry itself. For a zinc it tries
tetrahedral, trigonal bipyramidal and octahedral templates, superimposes them
on the coordinating protein atoms, keeps whichever fits best, and turns the
unoccupied positions into fitting points the ligand can bind to. On this system
it picks **tetrahedral** (RMSD 0.166, against 0.316 and 0.453 for the
alternatives), which is correct. The chosen geometry is reported in
`output/gold_protein.log` and `output/gold_protein.mol2`
contains dummy atoms at the idealised coordination positions.

## Running it

```
Comment thread
dkondin-ccdc marked this conversation as resolved.
Resolved
python ../prepare_inputs.py 3HS4
python metalloprotein_docking.py
```

## Files

| File | Description |
|---|---|

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[markdownlint] reported by reviewdog 🐶
error MD060/table-column-style Table column style [Table pipe is missing space to the left for style "compact"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[markdownlint] reported by reviewdog 🐶
error MD060/table-column-style Table column style [Table pipe is missing space to the left for style "compact"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[markdownlint] reported by reviewdog 🐶
error MD060/table-column-style Table column style [Table pipe is missing space to the right for style "compact"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[markdownlint] reported by reviewdog 🐶
error MD060/table-column-style Table column style [Table pipe is missing space to the right for style "compact"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[markdownlint-fix] reported by reviewdog 🐶

Suggested change
|---|---|
| --- | --- |

| `metalloprotein_docking.py` | The example. |
| `3HS4_protein.mol2` | Prepared carbonic anhydrase II coordinates, catalytic Zn retained and unbonded. |
| `3HS4_reference.mol2` | Acetazolamide in its crystal pose, neutral; the RMSD reference. |
| `acetazolamide_anion.mol2` | The deprotonated ligand actually docked, written by the script. |
| `output/` | GOLD's working directory, including `gold_protein.log` and `gold_protein.mol2`. |

RMSD is measured against the crystallographic pose, which still has its original
protonation. GOLD compares heavy atoms, so the missing hydrogen does not affect
the comparison.
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
@<TRIPOS>MOLECULE
acetazolamide_anion
18 18 1 0 1
SMALL
USER_CHARGES
****
Generated from the CSD

@<TRIPOS>ATOM
1 C1 -5.0953 2.0810 15.8005 C.2 1 AZM701 0.0000
2 C2 -4.6923 3.9591 14.3425 C.2 1 AZM701 0.0000
3 C3 -5.8423 5.6621 13.1474 C.2 1 AZM701 0.0000
4 C4 -5.6973 6.7651 12.1204 C.3 1 AZM701 0.0000
5 N1 -5.4244 -0.5550 16.1885 N.2 1 AZM701 -1.0000
6 N2 -3.5973 3.3260 14.7095 N.2 1 AZM701 0.0000
7 N3 -3.8203 2.1850 15.5425 N.2 1 AZM701 0.0000
8 N4 -4.6853 5.0761 13.5084 N.am 1 AZM701 0.0000
9 O1 -5.3274 1.0560 18.0826 O.2 1 AZM701 0.0000
10 O2 -7.2464 1.0490 16.5675 O.2 1 AZM701 0.0000
11 O3 -6.9363 5.2921 13.5504 O.2 1 AZM701 0.0000
12 S1 -5.8544 0.8210 16.7935 S.o2 1 AZM701 0.0000
13 S2 -6.0734 3.3040 15.0335 S.3 1 AZM701 0.0000
14 H1 -6.2096 6.4771 11.2036 H 1 AZM701 0.0000
15 H2 -4.6414 6.9288 11.9101 H 1 AZM701 0.0000
16 H3 -6.1366 7.6828 12.5088 H 1 AZM701 0.0000
17 H5 -4.4130 -0.6357 16.2167 H 1 AZM701 0.0000
18 H6 -3.8036 5.4494 13.1717 H 1 AZM701 0.0000
@<TRIPOS>BOND
1 1 7 2
2 1 12 1
3 1 13 1
4 2 6 2
5 2 8 1
6 2 13 1
7 3 4 1
8 3 8 am
9 3 11 2
10 5 12 1
11 6 7 1
12 9 12 2
13 10 12 2
14 4 14 1
15 4 15 1
16 4 16 1
17 5 17 1
18 8 18 1
@<TRIPOS>SUBSTRUCTURE
1 AZM701 1 GROUP 0 A AZM 0
@<TRIPOS>SET
CCDC_LIGAND STATIC ATOMS
18 1 2 3 4 5 6 7 8 9 \
10 11 12 13 14 15 16 17 18
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
"""
This script can be used for any purpose without limitation subject to the
conditions at https://www.ccdc.cam.ac.uk/Community/Pages/Licences/v2.aspx
This permission notice and the following statement of attribution must be
included in all copies or substantial portions of this script.

"17/11/2026": created by Chris Ringrose for the Cambridge Crystallographic Data Centre
"""

import os

from ccdc import docking, io

HERE = os.path.dirname(os.path.abspath(__file__))

PROTEIN_FILE = os.path.join(HERE, '3HS4_protein.mol2')
REFERENCE_FILE = os.path.join(HERE, '3HS4_reference.mol2')
LIGAND_FILE = os.path.join(HERE, 'acetazolamide_anion.mol2')
OUTPUT_DIRECTORY = os.path.join(HERE, 'output')


def deprotonate_sulfonamide(molecule):
"""Turn a neutral sulfonamide NH2 into the anion that coordinates zinc."""
nitrogen = next(
atom for atom in molecule.atoms
if atom.atomic_symbol == 'N'
and any(n.atomic_symbol == 'S' for n in atom.neighbours)
and sum(1 for n in atom.neighbours if n.atomic_symbol == 'H') == 2
)
hydrogen = next(n for n in nitrogen.neighbours if n.atomic_symbol == 'H')
molecule.remove_atom(hydrogen)
nitrogen.formal_charge = -1
return molecule


def report_metal_geometry(log_file):
"""
Print the metal coordination geometry reported by GOLD in the protein log.
This confirms the metal ion was used in docking.
"""
wanted = ('Coordinating residues', 'Matched coordination geometry',
'Metal fitting points added')
with open(log_file) as handle:
lines = handle.readlines()
for index, line in enumerate(lines):
if any(key in line for key in wanted):
print(line.rstrip())
# These entries put their value on the following line.
if line.rstrip().endswith(':') and index + 1 < len(lines):
print(f' {lines[index + 1].strip()}')


ligand = deprotonate_sulfonamide(io.MoleculeReader(REFERENCE_FILE)[0])
ligand.identifier = 'acetazolamide_anion'
with io.MoleculeWriter(LIGAND_FILE) as writer:
writer.write(ligand)

settings = docking.Docker.Settings()
settings.add_protein_file(PROTEIN_FILE)

protein = settings.proteins[0]
print(f'Metals kept: {[a.atomic_symbol for a in protein.metals]}')

settings.binding_site = settings.BindingSiteFromLigand(protein, ligand, 6.0)
settings.add_ligand_file(LIGAND_FILE, ndocks=10)

# RMSD is measured against the crystallographic pose, which still has its
# original protonation. GOLD compares heavy atoms, so the missing hydrogen
# does not affect the comparison.
settings.reference_ligand_file = REFERENCE_FILE

settings.fitness_function = 'plp'
settings.autoscale = 100.
settings.output_directory = OUTPUT_DIRECTORY
settings.output_format = 'mol2'
settings.output_file = 'docked_poses.mol2'

docker = docking.Docker(settings=settings)
docker.dock(file_name=os.path.join(OUTPUT_DIRECTORY, 'metalloprotein_docking.conf'))

report_metal_geometry(os.path.join(OUTPUT_DIRECTORY, 'gold_protein.log'))

print(f'{"Pose":<28} {"Fitness":>10} {"RMSD":>10}')
for pose in docker.results.ligands:
rmsd = float(pose.attributes['Gold.Reference.RMSD'])
print(f'{pose.identifier:<28} {pose.fitness():>10.2f} {rmsd:>10.2f}')
24 changes: 24 additions & 0 deletions scripts/discovery/gold_docking_examples/normal_docking/ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Normal docking — VEGFR2

Redocking a ligand into its own crystal structure.

System: VEGFR2 in complex with a 2-anilino-5-aryl-oxazole inhibitor (PDB 1Y6B),
a member of the Astex Diverse Set, the standard high-quality test set for
validating docking performance (Hartshorn *et al.*, *J. Med. Chem.* **2007**,
*50*, 726).

## Running it

```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[markdownlint] reported by reviewdog 🐶
error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]

python ../prepare_inputs.py 1Y6B
python normal_docking.py
```

## Files

| File | Description |
|---|---|

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[markdownlint] reported by reviewdog 🐶
error MD060/table-column-style Table column style [Table pipe is missing space to the left for style "compact"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[markdownlint] reported by reviewdog 🐶
error MD060/table-column-style Table column style [Table pipe is missing space to the left for style "compact"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[markdownlint] reported by reviewdog 🐶
error MD060/table-column-style Table column style [Table pipe is missing space to the right for style "compact"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[markdownlint] reported by reviewdog 🐶
error MD060/table-column-style Table column style [Table pipe is missing space to the right for style "compact"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[markdownlint-fix] reported by reviewdog 🐶

Suggested change
|---|---|
| --- | --- |

| `normal_docking.py` | The example. |
| `1Y6B_protein.mol2` | Prepared VEGFR2 coordinates, written by `prepare_inputs.py`. |
| `1Y6B_reference.mol2` | The native ligand in its crystallographic pose; both the docking input and the RMSD reference. |
| `output/` | GOLD's working directory: docked poses, configuration and logs. |
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"""
This script can be used for any purpose without limitation subject to the
conditions at https://www.ccdc.cam.ac.uk/Community/Pages/Licences/v2.aspx
This permission notice and the following statement of attribution must be
included in all copies or substantial portions of this script.

"17/11/2026": created by Chris Ringrose for the Cambridge Crystallographic Data Centre
"""

import os

from ccdc import docking, io

HERE = os.path.dirname(os.path.abspath(__file__))

PROTEIN_FILE = os.path.join(HERE, '1Y6B_protein.mol2')
REFERENCE_FILE = os.path.join(HERE, '1Y6B_reference.mol2')
OUTPUT_DIRECTORY = os.path.join(HERE, 'output')

settings = docking.Docker.Settings()
settings.add_protein_file(PROTEIN_FILE)

# The binding site is defined from the crystallographic ligand: every protein
# atom within 6 A of it becomes part of the site GOLD searches.
protein = settings.proteins[0]
reference = io.MoleculeReader(REFERENCE_FILE)[0]
settings.binding_site = settings.BindingSiteFromLigand(protein, reference, 6.0)

# Here the ligand being docked is the crystal ligand itself; GOLD discards the
# input conformation and rebuilds it.
settings.add_ligand_file(REFERENCE_FILE, ndocks=10)

# Setting a reference ligand makes GOLD record the RMSD of every pose to it,
# as the Gold.Reference.RMSD attribute read back below.
settings.reference_ligand_file = REFERENCE_FILE

settings.fitness_function = 'plp'
settings.autoscale = 100. # search effort, as a percentage of the default
settings.output_directory = OUTPUT_DIRECTORY
settings.output_format = 'mol2'
settings.output_file = 'docked_poses.mol2'

docker = docking.Docker(settings=settings)
docker.dock(file_name=os.path.join(OUTPUT_DIRECTORY, 'normal_docking.conf'))

print(f'{"Pose":<28} {"Fitness":>10} {"RMSD":>10}')
for pose in docker.results.ligands:
rmsd = float(pose.attributes['Gold.Reference.RMSD'])
print(f'{pose.identifier:<28} {pose.fitness():>10.2f} {rmsd:>10.2f}')
Loading