From 1198d3029b1a73960c9a7aaaa63f481b27d5dcce Mon Sep 17 00:00:00 2001 From: chrisringrose Date: Wed, 18 Nov 2026 14:58:32 +0000 Subject: [PATCH 1/2] NO_JIRA Added a series of Gold Docking examples for: * Normal docking * Metalloprotein docking * Scaffold constraint docking * Pharmacophore constraint docking * Virtual Screening --- .../discovery/gold_docking_examples/ReadMe.md | 117 +++++++++++++++ .../metalloprotein_docking/ReadMe.md | 37 +++++ .../acetazolamide_anion.mol2 | 52 +++++++ .../metalloprotein_docking.py | 86 +++++++++++ .../normal_docking/ReadMe.md | 24 +++ .../normal_docking/normal_docking.py | 49 ++++++ .../pharmacophore_constraint/LS3_ideal.sdf | 96 ++++++++++++ .../pharmacophore_constraint/ReadMe.md | 49 ++++++ .../pharmacophore_constraint.py | 62 ++++++++ .../reference_LS3.mol2 | 102 +++++++++++++ .../gold_docking_examples/prepare_inputs.py | 141 ++++++++++++++++++ .../scaffold_constraint/ReadMe.md | 50 +++++++ .../scaffold_constraint.py | 67 +++++++++ .../virtual_screening/ReadMe.md | 58 +++++++ .../prepare_screening_library.py | 84 +++++++++++ .../virtual_screening/virtual_screening.py | 124 +++++++++++++++ 16 files changed, 1198 insertions(+) create mode 100644 scripts/discovery/gold_docking_examples/ReadMe.md create mode 100644 scripts/discovery/gold_docking_examples/metalloprotein_docking/ReadMe.md create mode 100644 scripts/discovery/gold_docking_examples/metalloprotein_docking/acetazolamide_anion.mol2 create mode 100644 scripts/discovery/gold_docking_examples/metalloprotein_docking/metalloprotein_docking.py create mode 100644 scripts/discovery/gold_docking_examples/normal_docking/ReadMe.md create mode 100644 scripts/discovery/gold_docking_examples/normal_docking/normal_docking.py create mode 100644 scripts/discovery/gold_docking_examples/pharmacophore_constraint/LS3_ideal.sdf create mode 100644 scripts/discovery/gold_docking_examples/pharmacophore_constraint/ReadMe.md create mode 100644 scripts/discovery/gold_docking_examples/pharmacophore_constraint/pharmacophore_constraint.py create mode 100644 scripts/discovery/gold_docking_examples/pharmacophore_constraint/reference_LS3.mol2 create mode 100644 scripts/discovery/gold_docking_examples/prepare_inputs.py create mode 100644 scripts/discovery/gold_docking_examples/scaffold_constraint/ReadMe.md create mode 100644 scripts/discovery/gold_docking_examples/scaffold_constraint/scaffold_constraint.py create mode 100644 scripts/discovery/gold_docking_examples/virtual_screening/ReadMe.md create mode 100644 scripts/discovery/gold_docking_examples/virtual_screening/prepare_screening_library.py create mode 100644 scripts/discovery/gold_docking_examples/virtual_screening/virtual_screening.py diff --git a/scripts/discovery/gold_docking_examples/ReadMe.md b/scripts/discovery/gold_docking_examples/ReadMe.md new file mode 100644 index 0000000..b68cfdb --- /dev/null +++ b/scripts/discovery/gold_docking_examples/ReadMe.md @@ -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 and +cleaned up by a shared script. Run it first: + +``` +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 `_protein.mol2` plus a +`_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: + +``` +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 | +|---|---|---| +| `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. diff --git a/scripts/discovery/gold_docking_examples/metalloprotein_docking/ReadMe.md b/scripts/discovery/gold_docking_examples/metalloprotein_docking/ReadMe.md new file mode 100644 index 0000000..5dcb215 --- /dev/null +++ b/scripts/discovery/gold_docking_examples/metalloprotein_docking/ReadMe.md @@ -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 + +``` +python ../prepare_inputs.py 3HS4 +python metalloprotein_docking.py +``` + +## Files + +| File | Description | +|---|---| +| `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. diff --git a/scripts/discovery/gold_docking_examples/metalloprotein_docking/acetazolamide_anion.mol2 b/scripts/discovery/gold_docking_examples/metalloprotein_docking/acetazolamide_anion.mol2 new file mode 100644 index 0000000..bff5d20 --- /dev/null +++ b/scripts/discovery/gold_docking_examples/metalloprotein_docking/acetazolamide_anion.mol2 @@ -0,0 +1,52 @@ +@MOLECULE +acetazolamide_anion + 18 18 1 0 1 +SMALL +USER_CHARGES +**** +Generated from the CSD + +@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 +@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 +@SUBSTRUCTURE + 1 AZM701 1 GROUP 0 A AZM 0 +@SET +CCDC_LIGAND STATIC ATOMS +18 1 2 3 4 5 6 7 8 9 \ +10 11 12 13 14 15 16 17 18 diff --git a/scripts/discovery/gold_docking_examples/metalloprotein_docking/metalloprotein_docking.py b/scripts/discovery/gold_docking_examples/metalloprotein_docking/metalloprotein_docking.py new file mode 100644 index 0000000..40a2078 --- /dev/null +++ b/scripts/discovery/gold_docking_examples/metalloprotein_docking/metalloprotein_docking.py @@ -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}') diff --git a/scripts/discovery/gold_docking_examples/normal_docking/ReadMe.md b/scripts/discovery/gold_docking_examples/normal_docking/ReadMe.md new file mode 100644 index 0000000..293a947 --- /dev/null +++ b/scripts/discovery/gold_docking_examples/normal_docking/ReadMe.md @@ -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 + +``` +python ../prepare_inputs.py 1Y6B +python normal_docking.py +``` + +## Files + +| File | Description | +|---|---| +| `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. | diff --git a/scripts/discovery/gold_docking_examples/normal_docking/normal_docking.py b/scripts/discovery/gold_docking_examples/normal_docking/normal_docking.py new file mode 100644 index 0000000..4e02d62 --- /dev/null +++ b/scripts/discovery/gold_docking_examples/normal_docking/normal_docking.py @@ -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}') diff --git a/scripts/discovery/gold_docking_examples/pharmacophore_constraint/LS3_ideal.sdf b/scripts/discovery/gold_docking_examples/pharmacophore_constraint/LS3_ideal.sdf new file mode 100644 index 0000000..5e2889d --- /dev/null +++ b/scripts/discovery/gold_docking_examples/pharmacophore_constraint/LS3_ideal.sdf @@ -0,0 +1,96 @@ +LS3 + -ISIS- 3D + + 43 47 0 0 0 0 0 0 0 0 0 + 3.7250 0.0370 0.6470 O 0 0 0 0 0 + 2.9800 0.0200 1.6110 C 0 0 0 0 0 + 3.3580 -0.0120 2.9000 N 0 0 0 0 0 + 2.2600 -0.0240 3.7510 C 0 0 0 0 0 + 2.1680 -0.0550 5.1410 C 0 0 0 0 0 + 0.9370 -0.0610 5.7550 C 0 0 0 0 0 + -0.2350 -0.0360 4.9940 C 0 0 0 0 0 + -1.5540 -0.0430 5.6630 C 0 0 0 0 0 + -2.6450 0.6650 5.2990 O 0 0 0 0 0 + -3.6270 0.3740 6.1630 C 0 0 0 0 0 + -3.1820 -0.4810 7.0400 N 0 0 0 0 0 + -1.9020 -0.7670 6.7570 C 0 0 0 0 0 + -0.1570 -0.0050 3.6030 C 0 0 0 0 0 + 1.0860 0.0000 2.9860 C 0 0 0 0 0 + 1.5140 0.0360 1.5670 C 0 0 0 0 0 + 0.7160 0.0740 0.4600 C 0 0 0 0 0 + 1.2760 0.1040 -0.7800 N 0 0 0 0 0 + 0.4590 0.1440 -1.9130 C 0 0 0 0 0 + 1.0200 0.1790 -3.1760 C 0 0 0 0 0 + 0.2220 0.2140 -4.3230 C 0 0 0 0 0 + 0.7760 0.2490 -5.7480 C 0 0 0 0 0 + -0.7060 -0.1940 -6.7410 S 0 0 0 0 0 + -0.7360 -1.6000 -6.9440 O 0 0 0 0 0 + -0.8100 0.6820 -7.8550 O 0 0 0 0 0 + -1.9630 0.2680 -5.4810 C 0 0 0 0 0 + -1.1450 0.2230 -4.1890 C 0 0 0 0 0 + -1.7080 0.1930 -2.9090 C 0 0 0 0 0 + -0.9230 0.1530 -1.7820 C 0 0 0 0 0 + 4.2810 -0.0250 3.1990 H 0 0 0 0 0 + 3.0670 -0.0750 5.7380 H 0 0 0 0 0 + 0.8760 -0.0850 6.8330 H 0 0 0 0 0 + -4.6260 0.7830 6.1380 H 0 0 0 0 0 + -1.2630 -1.4440 7.3050 H 0 0 0 0 0 + -1.0580 0.0140 3.0090 H 0 0 0 0 0 + -0.3570 0.0820 0.5690 H 0 0 0 0 0 + 2.2410 0.0980 -0.8770 H 0 0 0 0 0 + 2.0950 0.1770 -3.2790 H 0 0 0 0 0 + 1.5660 -0.4890 -5.8770 H 0 0 0 0 0 + 1.1310 1.2470 -6.0030 H 0 0 0 0 0 + -2.7740 -0.4590 -5.4540 H 0 0 0 0 0 + -2.3480 1.2710 -5.6640 H 0 0 0 0 0 + -2.7830 0.2000 -2.8040 H 0 0 0 0 0 + -1.3770 0.1290 -0.8020 H 0 0 0 0 0 + 1 2 2 0 0 0 + 2 3 1 0 0 0 + 2 15 1 0 0 0 + 3 4 1 0 0 0 + 3 29 1 0 0 0 + 4 5 2 0 0 0 + 4 14 1 0 0 0 + 5 6 1 0 0 0 + 5 30 1 0 0 0 + 6 7 2 0 0 0 + 6 31 1 0 0 0 + 7 8 1 0 0 0 + 7 13 1 0 0 0 + 8 9 1 0 0 0 + 8 12 2 0 0 0 + 9 10 1 0 0 0 + 10 11 2 0 0 0 + 10 32 1 0 0 0 + 11 12 1 0 0 0 + 12 33 1 0 0 0 + 13 14 2 0 0 0 + 13 34 1 0 0 0 + 14 15 1 0 0 0 + 15 16 2 0 0 0 + 16 17 1 0 0 0 + 16 35 1 0 0 0 + 17 18 1 0 0 0 + 17 36 1 0 0 0 + 18 19 2 0 0 0 + 18 28 1 0 0 0 + 19 20 1 0 0 0 + 19 37 1 0 0 0 + 20 21 1 0 0 0 + 20 26 2 0 0 0 + 21 22 1 0 0 0 + 21 38 1 0 0 0 + 21 39 1 0 0 0 + 22 23 2 0 0 0 + 22 24 2 0 0 0 + 22 25 1 0 0 0 + 25 26 1 0 0 0 + 25 40 1 0 0 0 + 25 41 1 0 0 0 + 26 27 1 0 0 0 + 27 28 2 0 0 0 + 27 42 1 0 0 0 + 28 43 1 0 0 0 +M END +$$$$ \ No newline at end of file diff --git a/scripts/discovery/gold_docking_examples/pharmacophore_constraint/ReadMe.md b/scripts/discovery/gold_docking_examples/pharmacophore_constraint/ReadMe.md new file mode 100644 index 0000000..45b9c87 --- /dev/null +++ b/scripts/discovery/gold_docking_examples/pharmacophore_constraint/ReadMe.md @@ -0,0 +1,49 @@ +# Pharmacophore constraint docking — CDK2 + +Docking the inhibitor LS3 into CDK2 (PDB 1KE7) with a pharmacophore constraint +on the hinge hydrogen bond. + +A pharmacophore constraint is a scoring *reward* rather than a hard restraint: +poses placing an atom of the requested type near the given point score higher. +Use it when you know, from a series of actives or from the biology, that a +particular interaction must be made. Here, that's the hinge hydrogen bond that almost +all ATP-competitive kinase inhibitors form. + +Note that it does not forbid poses that miss the point; it makes them less +competitive. With `function_shape='block'` an atom outside the radius simply +contributes nothing, while `'gaussian'` lets the reward decay with distance. + +## Running it + +``` +python ../prepare_inputs.py 1KE7 +python pharmacophore_constraint.py +``` + +## Files + +| File | Description | +|---|---| +| `pharmacophore_constraint.py` | The example. | +| `1KE7_protein.mol2` | Prepared CDK2 coordinates, written by `prepare_inputs.py`. | +| `1KE7_reference.mol2` | LS3 in its crystallographic pose; the docking input and the RMSD reference. | +| `1ke7.pdb` | Original protein structure as downloaded from the PDB. | +| `LS3_ideal.sdf` | LS3 coordinates from the PDB chemical component dictionary, in an idealised geometry rather than the bound one. | +| `reference_LS3.mol2` | Earlier copy of the LS3 bound coordinates, kept from the original version of this example. | + +## The pharmacophore point + +The constraint places an acceptor point at **(-10.910, 52.354, 11.763)**, the +position of the LS3 oxygen that accepts a hydrogen bond from the Leu83 backbone +NH (N···O 2.68 Å), with a 1.5 Å radius and a gaussian function shape. + +Place the point where the *ligand atom* should sit, not on the protein partner, +and keep the radius wide enough for a good pose to reach it. A point set a few +ångströms off a real acceptor position with a tight radius will quietly push +docking away from the correct answer rather than towards it. + +`use_as_fitting_point=True` also biases where GOLD tries to place the +ligand, rather than only rewarding the pose after the fact. + +Valid types: `'acceptor'`, `'donor_acceptor'`, `'donor'`, `'aromatic_center'` +(or `'aromatic_centre'`), `'ring_center'` (or `'ring_centre'`). diff --git a/scripts/discovery/gold_docking_examples/pharmacophore_constraint/pharmacophore_constraint.py b/scripts/discovery/gold_docking_examples/pharmacophore_constraint/pharmacophore_constraint.py new file mode 100644 index 0000000..96f2e47 --- /dev/null +++ b/scripts/discovery/gold_docking_examples/pharmacophore_constraint/pharmacophore_constraint.py @@ -0,0 +1,62 @@ +""" +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, '1KE7_protein.mol2') +REFERENCE_FILE = os.path.join(HERE, '1KE7_reference.mol2') +OUTPUT_DIRECTORY = os.path.join(HERE, 'output') + +settings = docking.Docker.Settings() +settings.add_protein_file(PROTEIN_FILE) + +protein = settings.proteins[0] +reference = io.MoleculeReader(REFERENCE_FILE)[0] +settings.binding_site = settings.BindingSiteFromLigand(protein, reference, 6.0) + +settings.add_ligand_file(REFERENCE_FILE, ndocks=10) +settings.reference_ligand_file = REFERENCE_FILE + +# The point is placed on the hinge hydrogen bond: in 1KE7 the Leu83 backbone +# NH donates to the LS3 oxygen O5 at the coordinates below (N...O 2.68 A). +# +# Place the point where you want the ligand ATOM to sit, not on the protein +# partner, and make the radius large enough that a good pose can reach it. A +# point set a few angstroms off a real acceptor position with a tight radius +# will quietly push docking away from the correct answer rather than towards it. +# +# Valid types: 'acceptor', 'donor_acceptor', 'donor', 'aromatic_center' +# (or 'aromatic_centre'), 'ring_center' (or 'ring_centre'). +hinge_acceptor = settings.PharmacophoreConstraint( + origin=(-10.910, 52.354, 11.763), + type='acceptor', + radius=1.5, + function_shape='gaussian', # reward decays with distance, rather than cutting off + use_as_fitting_point=True, # also bias where GOLD tries to place the ligand + weight=10.0, +) +settings.add_constraint(hinge_acceptor) + +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, 'pharmacophore_constraint.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}') diff --git a/scripts/discovery/gold_docking_examples/pharmacophore_constraint/reference_LS3.mol2 b/scripts/discovery/gold_docking_examples/pharmacophore_constraint/reference_LS3.mol2 new file mode 100644 index 0000000..74bbdc1 --- /dev/null +++ b/scripts/discovery/gold_docking_examples/pharmacophore_constraint/reference_LS3.mol2 @@ -0,0 +1,102 @@ +@MOLECULE +A:1KE7 + 43 47 1 0 0 +SMALL +NO_CHARGES +**** +Generated from the CSD + +@ATOM + 1 O5 -10.9101 52.3537 11.7633 O.2 1 LS3299 0.0000 + 2 C6 -10.1871 51.8697 12.6203 C.2 1 LS3299 0.0000 + 3 N7 -9.6421 52.5277 13.6994 N.am 1 LS3299 0.0000 + 4 C8 -8.8131 51.6867 14.3934 C.ar 1 LS3299 0.0000 + 5 C9 -7.9971 51.9087 15.6134 C.ar 1 LS3299 0.0000 + 6 C10 -7.1341 50.7937 16.1094 C.ar 1 LS3299 0.0000 + 7 C11 -7.0151 49.4947 15.3554 C.ar 1 LS3299 0.0000 + 8 C12 -6.1391 48.4277 15.8204 C.2 1 LS3299 0.0000 + 9 O13 -5.8341 48.2237 17.1424 O.3 1 LS3299 0.0000 + 10 C14 -5.1821 47.0177 17.1814 C.2 1 LS3299 0.0000 + 11 N15 -4.8761 46.5757 15.9414 N.2 1 LS3299 0.0000 + 12 C16 -5.4641 47.4147 15.0614 C.2 1 LS3299 0.0000 + 13 C17 -7.8731 49.3317 14.1394 C.ar 1 LS3299 0.0000 + 14 C18 -8.7921 50.4067 13.7064 C.ar 1 LS3299 0.0000 + 15 C19 -9.7531 50.4387 12.6233 C.2 1 LS3299 0.0000 + 16 C20 -10.1731 49.4127 11.8463 C.2 1 LS3299 0.0000 + 17 N21 -10.9421 49.3827 10.5823 N.pl3 1 LS3299 0.0000 + 18 C22 -11.1171 48.2837 9.7733 C.ar 1 LS3299 0.0000 + 19 C23 -10.0101 47.3447 9.3942 C.ar 1 LS3299 0.0000 + 20 C24 -10.2971 46.1977 8.5332 C.ar 1 LS3299 0.0000 + 21 C25 -9.3361 45.1636 8.0912 C.3 1 LS3299 0.0000 + 22 S26 -9.9211 44.4506 6.5622 S.o2 1 LS3299 0.0000 + 23 O27 -9.6841 43.0326 6.5112 O.2 1 LS3299 0.0000 + 24 O28 -9.4571 45.3086 5.5091 O.2 1 LS3299 0.0000 + 25 C29 -11.6312 44.8716 6.9852 C.3 1 LS3299 0.0000 + 26 C30 -11.6382 45.9956 7.9682 C.ar 1 LS3299 0.0000 + 27 C31 -12.7622 46.8827 8.3512 C.ar 1 LS3299 0.0000 + 28 C32 -12.4882 48.0367 9.2412 C.ar 1 LS3299 0.0000 + 29 H2283 -12.1211 44.0033 7.4231 H 1 LS3299 0.0000 + 30 H2284 -12.1641 45.1735 6.0848 H 1 LS3299 0.0000 + 31 H2285 -9.2585 44.3873 8.8510 H 1 LS3299 0.0000 + 32 H2286 -8.3583 45.6162 7.9335 H 1 LS3299 0.0000 + 33 H2293 -13.2987 48.7126 9.5098 H 1 LS3299 0.0000 + 34 H2312 -8.9982 47.5162 9.7583 H 1 LS3299 0.0000 + 35 H2321 -13.7700 46.6906 7.9860 H 1 LS3299 0.0000 + 36 H2532 -9.8938 48.4287 12.2201 H 1 LS3299 0.0000 + 37 H2533 -6.5786 50.9232 17.0371 H 1 LS3299 0.0000 + 38 H2534 -11.3791 50.2496 10.2859 H 1 LS3299 0.0000 + 39 H2535 -9.8275 53.4950 13.9450 H 1 LS3299 0.0000 + 40 H2536 -4.9407 46.4822 18.0985 H 1 LS3299 0.0000 + 41 H2537 -5.4317 47.3366 13.9757 H 1 LS3299 0.0000 + 42 H2539 -8.0266 52.8637 16.1359 H 1 LS3299 0.0000 + 43 H2540 -7.8198 48.4079 13.5651 H 1 LS3299 0.0000 +@BOND + 1 1 2 2 + 2 2 3 am + 3 3 4 1 + 4 4 5 ar + 5 5 6 ar + 6 6 7 ar + 7 7 8 1 + 8 8 9 1 + 9 9 10 1 + 10 10 11 2 + 11 8 12 2 + 12 11 12 1 + 13 7 13 ar + 14 4 14 ar + 15 13 14 ar + 16 2 15 1 + 17 14 15 1 + 18 15 16 2 + 19 16 17 1 + 20 17 18 1 + 21 18 19 ar + 22 19 20 ar + 23 20 21 1 + 24 21 22 1 + 25 22 23 2 + 26 22 24 2 + 27 22 25 1 + 28 20 26 ar + 29 25 26 1 + 30 26 27 ar + 31 18 28 ar + 32 27 28 ar + 33 25 29 1 + 34 25 30 1 + 35 21 31 1 + 36 21 32 1 + 37 28 33 1 + 38 19 34 1 + 39 27 35 1 + 40 16 36 1 + 41 6 37 1 + 42 17 38 1 + 43 3 39 1 + 44 10 40 1 + 45 12 41 1 + 46 5 42 1 + 47 13 43 1 +@SUBSTRUCTURE + 1 LS3299 1 GROUP 0 A LS3 0 diff --git a/scripts/discovery/gold_docking_examples/prepare_inputs.py b/scripts/discovery/gold_docking_examples/prepare_inputs.py new file mode 100644 index 0000000..e37509e --- /dev/null +++ b/scripts/discovery/gold_docking_examples/prepare_inputs.py @@ -0,0 +1,141 @@ +""" +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 math +import os +import sys +import urllib.request + +from ccdc import io +from ccdc.protein import Protein + +PDB_DOWNLOAD_URL = 'https://files.rcsb.org/download/{code}.pdb' + +# PDB entry -> (output directory, het code of the ligand of interest) +# +# PDB entry -> (output directory, het code, keep_metals) +# +# 1Y6B VEGFR2 + oxazole inhibitor Astex Diverse Set member, plain redocking +# 1KE7 CDK2 + LS3 pharmacophore constraint +# 2VTQ CDK2 + difluoro analogue scaffold template for the constraint +# 2VU3 CDK2 + AT7519 the elaborated ligand to be docked +# 6OIM KRAS G12C + sotorasib covalent docking reference +# 3HS4 carbonic anhydrase II metalloprotein docking, catalytic Zn kept + +SYSTEMS = { + '1Y6B': ('normal_docking', 'AAX', False), + '1KE7': ('pharmacophore_constraint', 'LS3', False), + '2VTQ': ('scaffold_constraint', 'LZA', False), + '2VU3': ('scaffold_constraint', 'LZE', False), + '6OIM': ('covalent_docking', 'MOV', False), + '3HS4': ('metalloprotein_docking', 'AZM', True), +} + + +def fetch_pdb(code, directory): + """Download a PDB entry, unless it is already present.""" + pdb_file = os.path.join(directory, f'{code}.pdb') + if not os.path.exists(pdb_file): + print(f'Fetching {code} from the RCSB PDB...') + urllib.request.urlretrieve(PDB_DOWNLOAD_URL.format(code=code), pdb_file) + return pdb_file + + +def pick_ligand(protein, het_code, keep_metals): + """Choose which copy of the ligand to treat as the native one. + + A PDB entry often holds several copies of the same het group, only one of + which is in the site of interest. For a metalloprotein the right copy is the + one coordinating the metal; 3HS4, for instance, has three acetazolamides and + only one of them is in the active site. + """ + candidates = [l for l in protein.ligands if het_code in l.identifier] + if not candidates: + raise RuntimeError(f'No ligand matching {het_code} found') + if not (keep_metals and protein.metals): + return candidates[0] + + def distance_to_nearest_metal(ligand): + return min( + math.dist(atom.coordinates, metal.coordinates) + for atom in ligand.atoms + for metal in protein.metals + ) + + return min(candidates, key=distance_to_nearest_metal) + + +def prepare(code, directory, het_code, keep_metals=False, force=False): + """Split a PDB entry into a docking-ready protein and its native ligand.""" + os.makedirs(directory, exist_ok=True) + + protein_file = os.path.join(directory, f'{code}_protein.mol2') + reference_file = os.path.join(directory, f'{code}_reference.mol2') + + # Never clobber a file someone has prepared by hand: curated protonation or + # a hand-fixed binding site is exactly the sort of work that is painful to + # lose and easy to overwrite by rerunning a script. + existing = [f for f in (protein_file, reference_file) if os.path.exists(f)] + if existing and not force: + print(f' {code}: skipping, these already exist (use --force to replace):') + for path in existing: + print(f' {path}') + return protein_file, reference_file + + pdb_file = fetch_pdb(code, directory) + + protein = Protein.from_file(pdb_file) + protein.remove_all_waters() + protein.remove_unknown_atoms() + + # Bond orders for the HET groups are not in the PDB file, so let the API + # perceive them before we pull the ligand out. + protein.detect_ligand_bonds() + + if keep_metals: + # detect_ligand_bonds() bonds the metal to whatever it coordinates, so + # in 3HS4 the zinc and the inhibitor it binds become a single "ligand" + # and the zinc drops out of protein.metals. Deleting the metal bonds + # separates them again. GOLD requires this anyway: a metal in the input + # file must carry no bonds to its coordinating atoms, or it cannot work + # out the coordination geometry. + protein.remove_metal_bonds() + + native = pick_ligand(protein, het_code, keep_metals) + native.add_hydrogens(mode='missing') + + with io.MoleculeWriter(reference_file) as writer: + writer.write(native) + + # GOLD docks into an empty site, so every ligand comes out of the protein. + for ligand in protein.ligands: + protein.remove_ligand(ligand.identifier) + protein.add_hydrogens() + + with io.MoleculeWriter(protein_file) as writer: + writer.write(protein) + + print(f' {code} -> {protein_file}, {reference_file}') + return protein_file, reference_file + + +def main(): + arguments = sys.argv[1:] + force = '--force' in arguments + wanted = [c.upper() for c in arguments if c != '--force'] or list(SYSTEMS) + for code in wanted: + if code not in SYSTEMS: + print(f'Unknown entry {code}; known entries are {", ".join(SYSTEMS)}') + continue + directory, het_code, keep_metals = SYSTEMS[code] + prepare(code, directory, het_code, keep_metals=keep_metals, force=force) + + +if __name__ == '__main__': + main() diff --git a/scripts/discovery/gold_docking_examples/scaffold_constraint/ReadMe.md b/scripts/discovery/gold_docking_examples/scaffold_constraint/ReadMe.md new file mode 100644 index 0000000..1272882 --- /dev/null +++ b/scripts/discovery/gold_docking_examples/scaffold_constraint/ReadMe.md @@ -0,0 +1,50 @@ +# Scaffold constraint docking — CDK2, AT7519 series + +Holding a known core in place while GOLD searches the rest. + +System: the Astex CDK2 series that produced the clinical candidate AT7519 +(Wyatt *et al.*, *J. Med. Chem.* **2008**, *51*, 4986). + +| Entry | Ligand | Role | +|---|---|---| +| PDB 2VTQ | the 2,6-difluoro analogue (het code `LZA`) | the template | +| PDB 2VU3 | AT7519 itself, the 2,6-dichloro compound (het code `LZE`) | docked here | + +In this example, one member of a congeneric +series has been solved crystallographically, and you want the binding mode of a +close analogue. Docking the analogue freely can slide the shared core out of +the known pose; a scaffold constraint pins the core and lets GOLD search only +the part you are uncertain about. + +The constraint substructure-matches the template onto the ligand and adds a +distance constraint per matched atom pair, so it is a spring rather than a weld. +Raise `weight` to hold the core more tightly. + +## Running it + +``` +python ../prepare_inputs.py 2VTQ 2VU3 +python scaffold_constraint.py +``` + +## Two practical points this example has to deal with + +* **The template must be the shared core, not the whole template ligand.** The + maximum common substructure is computed in the script to get the shared core. +* **Bond orders perceived for the two pyrazoles differ between the two PDB + entries**, so the MCS is run with `check_bond_type` switched off. Leaving it + on truncates the core at the amide and loses the pyrazole entirely. + +2VTQ and 2VU3 are isomorphous, so their coordinates are already in a common +frame (the two ligand centroids sit 0.12 Å apart). For structures that are not, +superpose the proteins first with `ccdc.protein.Protein.ChainSuperposition`. + +## Files + +| File | Description | +|---|---| +| `scaffold_constraint.py` | The example. | +| `2VU3_protein.mol2` | Prepared CDK2 coordinates for the docking target. | +| `2VTQ_reference.mol2` | The difluoro analogue in its crystal pose; the scaffold template. | +| `2VU3_reference.mol2` | AT7519 in its crystal pose; the docking input and RMSD reference. | +| `output/` | GOLD's working directory: docked poses, configuration and logs. | diff --git a/scripts/discovery/gold_docking_examples/scaffold_constraint/scaffold_constraint.py b/scripts/discovery/gold_docking_examples/scaffold_constraint/scaffold_constraint.py new file mode 100644 index 0000000..ef5d44f --- /dev/null +++ b/scripts/discovery/gold_docking_examples/scaffold_constraint/scaffold_constraint.py @@ -0,0 +1,67 @@ +""" +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 +from ccdc.descriptors import MolecularDescriptors + +HERE = os.path.dirname(os.path.abspath(__file__)) + +PROTEIN_FILE = os.path.join(HERE, '2VU3_protein.mol2') +TEMPLATE_FILE = os.path.join(HERE, '2VTQ_reference.mol2') # analogue, crystal pose +LIGAND_FILE = os.path.join(HERE, '2VU3_reference.mol2') # AT7519 +OUTPUT_DIRECTORY = os.path.join(HERE, 'output') + + +def shared_core(template, ligand): + """The maximum common substructure, in the template's crystal coordinates.""" + mcs = MolecularDescriptors.MaximumCommonSubstructure() + mcs.settings.check_bond_type = False # the two pyrazoles are perceived differently + mcs.settings.ignore_hydrogens = True + matched_pairs, _ = mcs.search(template, ligand) + + core = template.copy() + keep = {template_atom.index for template_atom, _ in matched_pairs} + core.remove_atoms([a for a in core.atoms if a.index not in keep]) + core.identifier = 'shared_core' + return core + + +template = io.MoleculeReader(TEMPLATE_FILE)[0] +ligand = io.MoleculeReader(LIGAND_FILE)[0] + +core = shared_core(template, ligand) +heavy_atoms = sum(1 for a in core.atoms if a.atomic_symbol != 'H') +print(f'Scaffold: {heavy_atoms} heavy atoms') + +settings = docking.Docker.Settings() +settings.add_protein_file(PROTEIN_FILE) + +protein = settings.proteins[0] +settings.binding_site = settings.BindingSiteFromLigand(protein, ligand, 6.0) + +settings.add_ligand_file(LIGAND_FILE, ndocks=10) +settings.reference_ligand_file = LIGAND_FILE + +settings.add_constraint(settings.ScaffoldMatchConstraint(core, weight=5.0)) + +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, 'scaffold_constraint.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}') diff --git a/scripts/discovery/gold_docking_examples/virtual_screening/ReadMe.md b/scripts/discovery/gold_docking_examples/virtual_screening/ReadMe.md new file mode 100644 index 0000000..56b23ee --- /dev/null +++ b/scripts/discovery/gold_docking_examples/virtual_screening/ReadMe.md @@ -0,0 +1,58 @@ +# Virtual screening — MAPK1 / ERK2 + +Docking a library and measuring enrichment. + +System: MAPK1 (ERK2), PDB template 4ZZN, with a library sampled from LIT-PCBA. + +Redocking tells you whether a protocol reproduces a known pose. Screening asks +a different question: does the score rank actives above inactives? The answer is +summarised by a ROC curve and its area (AUC), where 0.5 is random. + +Because actives are rare in practice, the early part of the curve matters more +than the whole of it. The enrichment factor asks how many more actives you find +at the top of the ranked list than chance would give. It is taken at **5%** here +only because the sampled library is small: at 1% the cut would be a couple of +molecules and the number would be mostly noise. On a full screen, report EF at +1%. + +## Running it + +``` +python prepare_screening_library.py +python virtual_screening.py +``` + +No `prepare_inputs.py` step — this example gets its protein and native ligand +from the LIT-PCBA download instead. + +## The library + +LIT-PCBA (Tran-Nguyen, Jacquemard & Rognan, *J. Chem. Inf. Model.* **2020**, +*60*, 4263) is a virtual screening benchmark drawn from confirmatory PubChem +dose-response assays. Unlike older sets built from property-matched decoys, its +inactives are molecules that were actually tested and found inactive, which +avoids rewarding a method for simply telling actives and decoys apart on gross +properties. + +`prepare_screening_library.py` downloads the AVE-unbiased release (about 57 MB), +takes the MAPK1 target, samples 20 actives and 200 inactives from its validation +split with a fixed random seed, and generates 3D conformers. It also extracts +the GOLD-ready protein and ligand files that LIT-PCBA ships for the 4ZZN +template. The identifier of each molecule carries its known activity +(`active_…` / `inactive_…`), so the poses GOLD writes out can be scored without +matching them back to the library file. + +A real screen uses every molecule. The sample here is sized to finish on a +laptop, which means the resulting ROC curve is noisy. + +## Files + +| File | Description | +|---|---| +| `prepare_screening_library.py` | Downloads LIT-PCBA and builds the library. | +| `virtual_screening.py` | The example: docks the library, reports AUC and enrichment, plots the ROC curve. | +| `AVE_unbiased.tgz` | The LIT-PCBA download. | +| `4zzn_protein.mol2`, `4zzn_ligand.mol2` | Extracted from LIT-PCBA; the target and the ligand defining its site. | +| `screening_library.sdf` | The sampled library with 3D conformers. | +| `roc_curve.png` | Written by `virtual_screening.py`. | +| `output/` | GOLD's working directory: docked poses, configuration and logs. | diff --git a/scripts/discovery/gold_docking_examples/virtual_screening/prepare_screening_library.py b/scripts/discovery/gold_docking_examples/virtual_screening/prepare_screening_library.py new file mode 100644 index 0000000..bfb029d --- /dev/null +++ b/scripts/discovery/gold_docking_examples/virtual_screening/prepare_screening_library.py @@ -0,0 +1,84 @@ +""" +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 +import random +import tarfile +import urllib.request + +from ccdc import conformer, io +from ccdc.molecule import Molecule + +HERE = os.path.dirname(os.path.abspath(__file__)) + +ARCHIVE_URL = 'https://drugdesign.unistra.fr/LIT-PCBA/Files/AVE_unbiased.tgz' +ARCHIVE_FILE = os.path.join(HERE, 'AVE_unbiased.tgz') + +TARGET = 'MAPK1' # ERK2: an ATP-competitive site +TEMPLATE = '4zzn' # one of the PDB templates LIT-PCBA provides + +N_ACTIVES = 20 +N_INACTIVES = 200 +RANDOM_SEED = 1 # fixed so the example is reproducible + +LIBRARY_FILE = os.path.join(HERE, 'screening_library.sdf') + + +def read_smiles(archive, member): + """Read a LIT-PCBA .smi file: one 'SMILES ID' pair per line.""" + with archive.extractfile(member) as handle: + for line in handle: + parts = line.decode().split() + if len(parts) >= 2: + yield parts[0], parts[1] + + +def main(): + if not os.path.exists(ARCHIVE_FILE): + print('Downloading LIT-PCBA (about 57 MB)...') + urllib.request.urlretrieve(ARCHIVE_URL, ARCHIVE_FILE) + + archive = tarfile.open(ARCHIVE_FILE) + + # The protein and its native ligand come ready for docking. + for suffix in ('protein', 'ligand'): + member = f'{TARGET}/{TEMPLATE}_{suffix}.mol2' + with archive.extractfile(member) as source: + with open(os.path.join(HERE, os.path.basename(member)), 'wb') as target: + target.write(source.read()) + print(f'Extracted {os.path.basename(member)}') + + # Sample from the validation split. + rng = random.Random(RANDOM_SEED) + actives = rng.sample(list(read_smiles(archive, f'{TARGET}/active_V.smi')), N_ACTIVES) + inactives = rng.sample(list(read_smiles(archive, f'{TARGET}/inactive_V.smi')), N_INACTIVES) + + # The identifier carries the known activity, so the poses GOLD writes out + # can be scored without having to match them back to this file. + generator = conformer.ConformerGenerator() + written = 0 + with io.MoleculeWriter(LIBRARY_FILE) as writer: + for label, entries in (('active', actives), ('inactive', inactives)): + for smiles, identifier in entries: + try: + molecule = Molecule.from_string(smiles, format='smiles') + molecule = generator.generate(molecule)[0].molecule + except RuntimeError as error: + # A few benchmark SMILES fail to embed; skip rather than stop. + print(f'Skipping {identifier}: {error}') + continue + molecule.identifier = f'{label}_{identifier}' + writer.write(molecule) + written += 1 + + print(f'Wrote {written} molecules to {LIBRARY_FILE}') + + +if __name__ == '__main__': + main() diff --git a/scripts/discovery/gold_docking_examples/virtual_screening/virtual_screening.py b/scripts/discovery/gold_docking_examples/virtual_screening/virtual_screening.py new file mode 100644 index 0000000..2b4f5e2 --- /dev/null +++ b/scripts/discovery/gold_docking_examples/virtual_screening/virtual_screening.py @@ -0,0 +1,124 @@ +""" +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 + +try: + from matplotlib import pyplot as plt +except ImportError as _error: + plt = None + print(f'Plotting disabled (matplotlib unavailable: {_error})') + +from ccdc import docking, io + +HERE = os.path.dirname(os.path.abspath(__file__)) + +PROTEIN_FILE = os.path.join(HERE, '4zzn_protein.mol2') +NATIVE_LIGAND_FILE = os.path.join(HERE, '4zzn_ligand.mol2') +LIBRARY_FILE = os.path.join(HERE, 'screening_library.sdf') +OUTPUT_DIRECTORY = os.path.join(HERE, 'output') + + +def dock_library(): + """Dock every molecule in the library once and return the docked poses.""" + settings = docking.Docker.Settings() + settings.add_protein_file(PROTEIN_FILE) + + protein = settings.proteins[0] + native = io.MoleculeReader(NATIVE_LIGAND_FILE)[0] + native.identifier = 'native_ligand' + + settings.binding_site = settings.BindingSiteFromLigand(protein, native, 6.0) + + # One pose per molecule: in screening you need a score for each compound, + # not a thorough exploration of any one of them. + settings.add_ligand_file(LIBRARY_FILE, ndocks=1) + + settings.fitness_function = 'plp' + # Screening trades search effort for throughput. + settings.autoscale = 30. + settings.output_directory = OUTPUT_DIRECTORY + settings.output_format = 'mol2' + settings.output_file = 'docked_library.mol2' + + docker = docking.Docker(settings=settings) + docker.dock(file_name=os.path.join(OUTPUT_DIRECTORY, 'virtual_screening.conf')) + return docker.results + + +def roc_curve(scored): + """Return ROC points and the AUC from (score, is_active) pairs.""" + ranked = sorted(scored, key=lambda pair: pair[0], reverse=True) + n_actives = sum(1 for _, active in ranked if active) + n_inactives = len(ranked) - n_actives + + # Walk down the ranked list, stepping up for an active and right otherwise. + # The area accumulated under those steps is the AUC. + true_positives = false_positives = 0 + points = [(0.0, 0.0)] + auc = 0.0 + for _, active in ranked: + if active: + true_positives += 1 + else: + false_positives += 1 + auc += true_positives / n_actives # area of the strip just swept + points.append((false_positives / n_inactives, true_positives / n_actives)) + + return points, auc / n_inactives + + +def enrichment_factor(scored, fraction=0.01): + """How many times more actives appear in the top fraction than by chance.""" + ranked = sorted(scored, key=lambda pair: pair[0], reverse=True) + cut = max(1, int(round(len(ranked) * fraction))) + hit_rate = sum(1 for _, active in ranked[:cut] if active) / cut + overall_rate = sum(1 for _, active in ranked if active) / len(ranked) + return hit_rate / overall_rate + + +def main(): + results = dock_library() + + # The identifier prefix records the known activity (see the prep script). + scored = [ + (pose.fitness(), pose.identifier.startswith('active')) + for pose in results.ligands + ] + + points, auc = roc_curve(scored) + n_actives = sum(1 for _, active in scored if active) + print(f'Docked {len(scored)} molecules, {n_actives} of them actives') + print(f'AUC {auc:.3f}') + print(f'Enrichment factor 5% {enrichment_factor(scored, 0.05):.1f}') + + plot_roc(points, auc) + + +def plot_roc(points, auc): + """Save the ROC curve, if matplotlib is available.""" + if plt is None: + print('Skipping the ROC plot: matplotlib did not import.') + return + + plt.figure(figsize=(5, 5)) + plt.plot([x for x, _ in points], [y for _, y in points], + label=f'GOLD PLP (AUC = {auc:.3f})') + plt.plot([0, 1], [0, 1], '--', color='grey', label='random') + plt.xlabel('False positive rate') + plt.ylabel('True positive rate') + plt.title('MAPK1 virtual screen (LIT-PCBA sample)') + plt.legend(loc='lower right') + plt.tight_layout() + plt.savefig(os.path.join(HERE, 'roc_curve.png'), dpi=150) + print('Wrote roc_curve.png') + + +if __name__ == '__main__': + main() From 228177c40e5a31d2248d7f17e0816e8ab5874895 Mon Sep 17 00:00:00 2001 From: chrisringrose Date: Fri, 20 Nov 2026 10:06:42 +0000 Subject: [PATCH 2/2] NO_JIRA Updated to use mmcif instead of pdb. --- .../discovery/gold_docking_examples/ReadMe.md | 2 +- .../pharmacophore_constraint/ReadMe.md | 2 +- .../gold_docking_examples/prepare_inputs.py | 20 +++++++++---------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/scripts/discovery/gold_docking_examples/ReadMe.md b/scripts/discovery/gold_docking_examples/ReadMe.md index b68cfdb..8a90374 100644 --- a/scripts/discovery/gold_docking_examples/ReadMe.md +++ b/scripts/discovery/gold_docking_examples/ReadMe.md @@ -9,7 +9,7 @@ CSD-Enterprise licence. ## Getting started -Every example reads prepared input files that are fetched from the RCSB PDB and +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: ``` diff --git a/scripts/discovery/gold_docking_examples/pharmacophore_constraint/ReadMe.md b/scripts/discovery/gold_docking_examples/pharmacophore_constraint/ReadMe.md index 45b9c87..0369a06 100644 --- a/scripts/discovery/gold_docking_examples/pharmacophore_constraint/ReadMe.md +++ b/scripts/discovery/gold_docking_examples/pharmacophore_constraint/ReadMe.md @@ -27,7 +27,7 @@ python pharmacophore_constraint.py | `pharmacophore_constraint.py` | The example. | | `1KE7_protein.mol2` | Prepared CDK2 coordinates, written by `prepare_inputs.py`. | | `1KE7_reference.mol2` | LS3 in its crystallographic pose; the docking input and the RMSD reference. | -| `1ke7.pdb` | Original protein structure as downloaded from the PDB. | +| `1KE7.cif` | Original protein structure, downloaded from the RCSB PDB in mmCIF format by `prepare_inputs.py`. | | `LS3_ideal.sdf` | LS3 coordinates from the PDB chemical component dictionary, in an idealised geometry rather than the bound one. | | `reference_LS3.mol2` | Earlier copy of the LS3 bound coordinates, kept from the original version of this example. | diff --git a/scripts/discovery/gold_docking_examples/prepare_inputs.py b/scripts/discovery/gold_docking_examples/prepare_inputs.py index e37509e..113d37b 100644 --- a/scripts/discovery/gold_docking_examples/prepare_inputs.py +++ b/scripts/discovery/gold_docking_examples/prepare_inputs.py @@ -15,7 +15,7 @@ from ccdc import io from ccdc.protein import Protein -PDB_DOWNLOAD_URL = 'https://files.rcsb.org/download/{code}.pdb' +PDB_DOWNLOAD_URL = 'https://files.rcsb.org/download/{code}.cif' # PDB entry -> (output directory, het code of the ligand of interest) # @@ -38,13 +38,13 @@ } -def fetch_pdb(code, directory): - """Download a PDB entry, unless it is already present.""" - pdb_file = os.path.join(directory, f'{code}.pdb') - if not os.path.exists(pdb_file): +def fetch_mmcif(code, directory): + """Download a PDB entry as mmCIF, unless it is already present.""" + cif_file = os.path.join(directory, f'{code}.cif') + if not os.path.exists(cif_file): print(f'Fetching {code} from the RCSB PDB...') - urllib.request.urlretrieve(PDB_DOWNLOAD_URL.format(code=code), pdb_file) - return pdb_file + urllib.request.urlretrieve(PDB_DOWNLOAD_URL.format(code=code), cif_file) + return cif_file def pick_ligand(protein, het_code, keep_metals): @@ -88,13 +88,13 @@ def prepare(code, directory, het_code, keep_metals=False, force=False): print(f' {path}') return protein_file, reference_file - pdb_file = fetch_pdb(code, directory) + cif_file = fetch_mmcif(code, directory) - protein = Protein.from_file(pdb_file) + protein = Protein.from_file(cif_file) protein.remove_all_waters() protein.remove_unknown_atoms() - # Bond orders for the HET groups are not in the PDB file, so let the API + # Bond orders for the HET groups are not in the mmCIF file, so let the API # perceive them before we pull the ligand out. protein.detect_ligand_bonds()