wwPDB Chemical Component Dictionary (CCD): sample notebook

A worked notebook for wwPDB Chemical Component Dictionary (CCD), with 6 code cells and the output each one printed. On Scigantic it opens in a hosted JupyterLab with the dataset already mounted, so nothing is downloaded first.

Provider
wwPDB Consortium
License
CC0 1.0
Access
Free and public. No account with the data provider is needed.
DOI
10.1093/nar/gkj032

The notebook

wwPDB Chemical Component Dictionary (CCD) — explore ~45,000 ligands by id

The CCD is the reference chemistry for every small molecule, ligand, ion, and modified residue in the PDB — what AlphaFold 3 uses for ligand pose prediction, and what you reach for whenever a structure has a HETATM. It's ~45,000 components, and this notebook never downloads the whole thing. The scigantic_wwpdb library fetches by id, in three tiers so exploring stays fast:

1 · Search, then skim

search names it (RCSB text search), find batch-fetches metadata for the whole result set in a single request — so you look before you fetch. This is the fast way to browse.

import scigantic_wwpdb as ccd

ids = ccd.search('heme')          # component ids whose name matches
for s in ccd.find(ids):           # metadata for all of them, ONE request
    print(f'{s.id:6} {(s.formula or ""):18} {s.name}')

2 · One component, full structure

When you've found what you want, pull it: name, formula, every atom (with ideal 3-D coords), every bond, SMILES/InChI.

atp = ccd.component('ATP')
print(atp.name, '|', atp.formula, '|', len(atp.atoms), 'atoms')
print('SMILES  :', atp.smiles)
print('InChIKey:', atp.inchikey)
atp.atoms[:3]

3 · Draw it (RDKit)

A 2-D depiction built from the dictionary's atoms and bonds — so it works even for organometallics like heme, whose coordinate-bond SMILES a plain parser can't read.

from rdkit.Chem import Draw, rdDepictor

mols = []
for cid in ['ATP', 'HEM', 'NAD']:
    m = ccd.to_rdkit(cid)          # from atoms+bonds (handles the Fe in heme)
    rdDepictor.Compute2DCoords(m)
    mols.append(m)
Draw.MolsToGridImage(mols, legends=['ATP', 'HEM', 'NAD'], molsPerRow=3, subImgSize=(280, 240))

4 · 3-D coordinates & SDF

to_rdkit carries the ideal 3-D coordinates as a conformer; one step to an SDF for downstream tools.

mol = ccd.to_rdkit('ATP')
print('RDKit mol:', mol.GetNumAtoms(), 'atoms,', mol.GetNumConformers(), '3-D conformer')
sdf = ccd.to_sdf('ATP', 'ATP.sdf')
print('wrote ATP.sdf —', len(sdf.splitlines()), 'lines')

5 · Many at once

components fetches full structures for a list in parallel — reach for it after search/find narrow things down.

comps = ccd.components(['ATP', 'ADP', 'AMP', 'GTP'])
for c in comps:
    print(f'{c.id:5} {c.formula:16} {len(c.atoms):3} atoms')

6 · The whole dictionary, when you need it

For bulk sweeps, stream the full components.cif.gz (~117 MB) once — cached. For anything less than a few thousand, per-id component() / components() are faster and use no disk.

# doc = ccd.read_dictionary()   # downloads once (~117 MB), a gemmi Document of all ~45k blocks
print('Tip: search -> find -> component is the fast path; load_dictionary() is for bulk.')

import scigantic_wwpdb; help(scigantic_wwpdb) for the whole surface. Data: wwPDB CCD, CC0 1.0. Library: Scigantic/scigantic-wwpdb.

Run it

Open this notebook to run it, see the dataset page for the full description, or browse the full catalog.