RFD4-Proteina training data and the panel it was validated on
Protein design sample notebook on Scigantic.
Open the 640 structures RFD4-Proteina was validated on, and find out how many of its protein-ligand examples are actually drugs.
Figure: Ribbon render of a copper-binding protein from the RFD4-Proteina held-out validation panel, its beta-barrel fold in blue with the single copper ion shown as an amber sphere inside the barrel
The notebook
8 code cells, shown with the output each one printed.
RFD4-Proteina is more than the model
RFD4-Proteina is the RosettaCommons/NVIDIA biomolecular design model released in October 2026. The model gets the attention, but it stands on two things released with it, and you have both in front of you:
- atomworks, the data library every structure here was parsed and cleaned with. It is installed in this notebook.
- Annotated CIF, the file convention the release is written in: ordinary mmCIF with extra per-atom columns that record what the pipeline learned about each atom, such as whether it was observed or filled in.
The point of the pair is chaining. A tool that reads annotated CIF gets the previous tool's work as typed columns instead of redoing it, and can pass its own on. The second code cell below does exactly that on real files.
The files themselves are the panel used to validate the autoencoder: 640 structures, every one deposited on or after 2024-01-01, so none could have been in the training mixture. After reading them the way the model did, this notebook asks two questions you should ask of any benchmark before trusting a number computed on it. What is in it? And is it representative of what it was drawn from?
The second question needs a second dataset, so the PDB entry index is cross-mounted alongside: 252,816 deposited entries with dates, resolutions and methods.
Start here
Everything is mounted read-only. Nothing to download, nothing to install.
- /mnt/archive is the RFD4-Proteina release
- ~/additional-datasets/ holds the PDB entry index and BindingDB
Run the cells in order.
import gemmi, glob, os
# Resolve a cross-mounted file WITHOUT walking the mount tree. Additional archives
# land at a deterministic /mnt/archives/<bucket>[/<prefix>] and are symlinked into
# ~/additional-datasets/, so try exact paths first. A bare
# glob('/mnt/archives/**/x', recursive=True) would stat every file under every mount
# over FUSE -- the PDB mount alone has 1000 shard directories holding ~250k structure
# files -- and that cell does not finish.
def find_mount(*candidates):
for c in candidates:
c = os.path.expanduser(c)
if '*' in c:
hits = sorted(glob.glob(c)) # bounded: one level, never recursive
if hits:
return hits[0]
elif os.path.exists(c):
return c
raise FileNotFoundError(f'none of these exist: {candidates}')
import pyarrow as pa
# The panel ships Zstandard-compressed mmCIF (.cif.zst). This image does not carry
# `zstandard`, but pyarrow reads zstd, so decompress through it. gzip cannot.
def read_zst(path):
with pa.CompressedInputStream(pa.OSFile(path, 'rb'), 'zstd') as fh:
return fh.read().decode()
PANEL = '/mnt/archive/benchmarks/ae_pdb_temporal_holdout_2026_10_04'
# 640 structures, deliberately 128 of each modality. Note there is no protein-only
# panel: if you want a plain reconstruction baseline you have to build it.
for modality in ('protein_ligand', 'ptm', 'glycan', 'dna', 'rna'):
n = len(glob.glob(f'{PANEL}/{modality}/*.cif.zst'))
print(f' {modality:16s} {n:4d} structures')
files = sorted(glob.glob(f'{PANEL}/protein_ligand/*.cif.zst'))
print(f'\nworking with the {len(files)} protein-ligand ones')
cif = read_zst(files[0])
# read_structure_string, not read_structure_from_string, which does not exist in gemmi 0.7
st = gemmi.read_structure_string(cif, format=gemmi.CoorFormat.Mmcif)
st.setup_entities()
print(f'{os.path.basename(files[0])}: {st[0].count_atom_sites()} atoms, {len(st[0])} chains')
Output:
protein_ligand 128 structures ptm 128 structures glycan 128 structures dna 128 structures rna 128 structures working with the 128 protein-ligand ones protein_ligand_0000.cif.zst: 1111 atoms, 2 chains
Read it the way the model did
The cell above opened one file with gemmi, a general mmCIF reader. That works, but a general reader does not know what the release's extra columns mean and hands them back as text.
atomworks does know. Ask for the annotated columns by name and they arrive on the structure as typed arrays: is_imputed (the atom was not observed; its position was filled in by side-chain packing), nhyd (hydrogens attached to the atom) and atom_array_index (the atom's position in the array the pipeline worked on).
Then the chain: drop the imputed atoms with one mask, write the result back out, and open it with a different tool. The annotations are still there.
import logging
logging.disable(logging.WARNING) # atomworks warns at import about optional mirrors not needed here
from atomworks.io import parse
from atomworks.io.config import ParseConfig
from atomworks.io.utils.io_utils import CIFWriteConfig, to_cif_string
logging.disable(logging.NOTSET)
# The three per-atom columns this release adds to _atom_site, beyond what wwPDB defines.
ANNOTATED = ['is_imputed', 'nhyd', 'atom_array_index']
# add_missing_atoms=False keeps exactly the atoms in the file. The default would
# rebuild hydrogens and unresolved atoms, which is right for training, wrong for reading.
cfg = ParseConfig(extra_fields=ANNOTATED, add_missing_atoms=False, return_atom_array_plus=True)
print(f"{'file':28s} {'atoms':>6s} {'imputed':>8s} non-polymer")
for f in files[:8]:
atoms = parse(f, config=cfg)['asym_unit'][0] # a biotite AtomArray, plus the file's own component definitions
ligands = sorted(set(atoms.res_name[~atoms.is_polymer]))
print(f'{os.path.basename(f):28s} {len(atoms):6d} {int(atoms.is_imputed.sum()):8d} {", ".join(ligands)}')
# The annotations arrive typed: a real boolean mask and an integer count, not the
# strings 'True'/'False' a generic mmCIF reader hands back.
print(f'\nis_imputed is {atoms.is_imputed.dtype}, nhyd is {atoms.nhyd.dtype}')
# So chaining is one line. Keep only atoms that were experimentally observed...
observed = atoms[~atoms.is_imputed]
print(f'{os.path.basename(f)}: {len(atoms)} atoms, {len(observed)} observed, {len(atoms) - len(observed)} imputed')
# ...and write it back out. The annotation columns travel with the structure, so the
# next tool in the chain (gemmi here) still sees them.
out = to_cif_string(observed, config=CIFWriteConfig(extra_fields=ANNOTATED))
block = gemmi.cif.read_string(out).sole_block()
kept = [c for c in ANNOTATED if block.find_loop(f'_atom_site.{c}')]
print(f'round-tripped {len(block.find_loop("_atom_site.id"))} atoms; columns still present: {kept}')
Output:
file atoms imputed non-polymer protein_ligand_0000.cif.zst 1111 0 CU protein_ligand_0001.cif.zst 991 7 CA protein_ligand_0002.cif.zst 2779 0 A1IZA protein_ligand_0003.cif.zst 6800 0 MG protein_ligand_0004.cif.zst 4979 0 MG protein_ligand_0005.cif.zst 3700 0 NI protein_ligand_0006.cif.zst 3212 0 ZN protein_ligand_0007.cif.zst 5618 1 A1AVC is_imputed is bool, nhyd is int64 protein_ligand_0007.cif.zst: 5618 atoms, 5617 observed, 1 imputed round-tripped 5617 atoms; columns still present: ['is_imputed', 'nhyd', 'atom_array_index']
What is actually in this panel
Before any numbers, look at it. Each tile is one non-polymer component found across the sample, drawn from the file's own _chem_comp_atom and _chem_comp_bond tables.
The single-atom tiles are metal ions. In a set named protein_ligand, most of the tiles are a single metal atom.
from collections import Counter
from rdkit import Chem, RDLogger
from rdkit.Chem import Draw, AllChem
RDLogger.DisableLog('rdApp.*') # a few components fail valence; that is expected
METALS = {'CU','ZN','MG','CA','FE','MN','NA','K','NI','CO','CD','HG','PT','FE2','MO','AL'}
ORDER = {'SING': Chem.BondType.SINGLE, 'DOUB': Chem.BondType.DOUBLE,
'TRIP': Chem.BondType.TRIPLE, 'AROM': Chem.BondType.AROMATIC}
SCAN = files[:40] # 40 of 128 keeps this cell quick
def nonpoly_names(path):
"""Component names that are NOT part of the polymer, for one structure."""
s = gemmi.read_structure_string(read_zst(path), format=gemmi.CoorFormat.Mmcif)
s.setup_entities()
out = []
for ch in s[0]:
for res in ch:
info = gemmi.find_tabulated_residue(res.name) # None for the newest comps
if info is None or not info.is_amino_acid():
out.append(res.name)
return out
def comp_mols(path):
"""{comp_id: Mol} from the file's own component dictionary. Without the bond table
RDKit has no connectivity and every organic ligand collapses into a stack of atoms."""
blk = gemmi.cif.read_string(read_zst(path)).sole_block()
by = {}
for r in blk.find('_chem_comp_atom.', ['comp_id', 'atom_id', 'type_symbol']):
if r[2].strip('"\'').upper() == 'H':
continue
d = by.setdefault(r[0], {'idx': {}, 'rw': Chem.RWMol()})
aid = r[1].strip('"\'')
if aid in d['idx']:
continue
d['idx'][aid] = d['rw'].AddAtom(Chem.Atom(r[2].strip('"\'').capitalize()))
for r in blk.find('_chem_comp_bond.', ['comp_id', 'atom_id_1', 'atom_id_2', 'value_order']):
d = by.get(r[0])
if not d:
continue
a, b = r[1].strip('"\''), r[2].strip('"\'')
if a not in d['idx'] or b not in d['idx']:
continue
i, j = d['idx'][a], d['idx'][b]
if d['rw'].GetBondBetweenAtoms(i, j):
continue # some bonds are listed twice
d['rw'].AddBond(i, j, ORDER.get(r[3].strip('"\''), Chem.BondType.SINGLE))
out = {}
for cid, d in by.items():
m = d['rw'].GetMol()
try:
Chem.SanitizeMol(m)
AllChem.Compute2DCoords(m)
out[cid] = m
except Exception:
pass
return out
tally, depictions = Counter(), {}
for f in SCAN:
names = nonpoly_names(f)
tally.update(names)
mols = comp_mols(f)
for n in names:
if n in mols:
depictions.setdefault(n, mols[n])
wanted = [c for c, _ in tally.most_common(12) if c in depictions]
n_metal = sum(1 for c in wanted if c in METALS)
print(f'{n_metal} of the {len(wanted)} most common components are a single metal ion')
Draw.MolsToGridImage([depictions[c] for c in wanted],
legends=[f'{c} ({depictions[c].GetNumAtoms()} atoms)' for c in wanted],
molsPerRow=4, subImgSize=(210, 170))
Output:
6 of the 12 most common components are a single metal ion
Look at one
The first structure in the panel, with whatever non-polymer it carries drawn as spheres. The site sits buried against the fold, which is part of why these are a reconstruction test rather than a docking test.
import matplotlib.pyplot as plt
import numpy as np
# Headless 3D: this image has no nglview, and a widget would not survive into a
# saved notebook anyway. A CA trace plus the non-polymer atoms says the same thing.
METALS = {'NA','MG','K','CA','MN','FE','CO','NI','CU','ZN','CD','HG','PT','MO','AL'}
def is_aa(name):
info = gemmi.find_tabulated_residue(name)
return info is not None and info.is_amino_acid()
fig = plt.figure(figsize=(7.2, 6.0))
ax = fig.add_subplot(111, projection='3d')
chains = list(st[0])
colors = plt.cm.Blues(np.linspace(0.50, 0.85, max(1, len(chains))))
for ci, ch in enumerate(chains):
ca = np.array([[a.pos.x, a.pos.y, a.pos.z] for r in ch for a in r
if a.name == 'CA' and is_aa(r.name)])
if len(ca) > 1:
ax.plot(ca[:, 0], ca[:, 1], ca[:, 2], lw=1.7, color=colors[ci], label=f'chain {ch.name}')
het = [(a.element.name.upper(), a.pos) for ch in st[0] for r in ch for a in r
if not is_aa(r.name) and r.name != 'HOH' and a.element.name.upper() != 'H']
if het:
pts = np.array([[p.x, p.y, p.z] for _, p in het])
met = np.array([e in METALS for e, _ in het])
if met.any():
ax.scatter(pts[met, 0], pts[met, 1], pts[met, 2], s=200, c='#d9822b',
depthshade=False, edgecolors='white', linewidths=0.7, label='metal ion')
if (~met).any():
ax.scatter(pts[~met, 0], pts[~met, 1], pts[~met, 2], s=60, c='#c0392b',
depthshade=False, edgecolors='white', linewidths=0.4, label='ligand atom')
allp = np.array([[a.pos.x, a.pos.y, a.pos.z] for ch in st[0] for r in ch for a in r])
c, rad = allp.mean(0), np.abs(allp - allp.mean(0)).max()
ax.set_xlim(c[0]-rad, c[0]+rad); ax.set_ylim(c[1]-rad, c[1]+rad); ax.set_zlim(c[2]-rad, c[2]+rad)
ax.set_axis_off()
ax.set_box_aspect((1, 1, 1), zoom=1.38)
ax.set_title(f'{os.path.basename(files[0]).replace(".cif.zst", "")} '
f'{allp.shape[0]} atoms, non-polymer: '
f'{", ".join(sorted({r.name for ch in st[0] for r in ch if not is_aa(r.name) and r.name != "HOH"}))}',
fontsize=10)
ax.legend(loc='upper left', fontsize=8, framealpha=0.85)
ax.view_init(elev=18, azim=35)
plt.show()
Most of the protein-ligand panel is not a drug
The modality is named protein_ligand, which reads like 128 protein-drug complexes. Draw the non-polymer components and the problem is immediate: a majority are a single metal atom.
If you are benchmarking small-molecule design or docking, filter on non-polymer composition before quoting a number over "the protein-ligand set".
from rdkit import Chem
from rdkit.Chem import Draw
from collections import Counter
METALS = {'CU','ZN','MG','CA','FE','MN','NA','K','NI','CO','CD','HG','PT','FE2','MO','AL'}
SCAN = files[:40] # 40 of 128 keeps this quick; raise it for the full panel
def non_polymers(path):
s = gemmi.read_structure_string(read_zst(path), format=gemmi.CoorFormat.Mmcif)
s.setup_entities()
out = []
for ch in s[0]:
for res in ch:
info = gemmi.find_tabulated_residue(res.name) # None for the newest components
if info is None or not info.is_amino_acid():
out.append(res)
return out
comps, kinds = Counter(), Counter()
examples = {}
for f in SCAN:
nps = non_polymers(f)
names = {r.name for r in nps}
for r in nps:
comps[r.name] += 1
examples.setdefault(r.name, r)
if not names:
kinds['no non-polymer'] += 1
elif names <= METALS:
kinds['metal ion only'] += 1
else:
kinds['organic ligand'] += 1
for k, v in kinds.most_common():
print(f' {k:18s} {v:3d} ({100*v/len(SCAN):.0f}%)')
print()
print('most common non-polymer components:', comps.most_common(8))
Output:
metal ion only 22 (55%)
organic ligand 18 (45%)
most common non-polymer components: [('MG', 7), ('ZN', 4), ('CU', 3), ('CA', 3), ('NI', 2), ('K', 2), ('A1IZA', 1), ('A1AVC', 1)]
Is this benchmark's chemistry drug-like?
The panel files are stripped: they keep atoms, entities, sequences and component definitions, but no resolution, no deposition date, no title. So you cannot compare a panel structure to its PDB record directly.
What they do keep is ligand chemistry, and that is joinable. BindingDB is cross-mounted with 3.2 million measured binding records, so the panel's ligands can be put next to ligands that someone actually measured a Ki or Kd for.
import pyarrow.parquet as pq
import matplotlib.pyplot as plt
from rdkit import Chem, RDLogger
RDLogger.DisableLog('rdApp.*')
# panel side: heavy atoms of each ORGANIC non-polymer (metals excluded)
panel_hv = []
for f in SCAN:
for res in non_polymers(f):
if res.name in METALS:
continue
n = sum(1 for at in res if at.element.name.upper() != 'H')
if n > 1:
panel_hv.append(n)
# BindingDB side: one row group, one column. The table is 231 MB and the pod has ~4 GiB,
# so never read it whole -- column projection plus a single row group is the pattern.
bdb = find_mount(
'/mnt/archives/scigantic-bindingdb/202608/parquet/measurements.parquet',
'~/additional-datasets/*/202608/parquet/measurements.parquet',
)
pf = pq.ParquetFile(bdb)
smis = [s for s in pf.read_row_group(0, columns=['ligand_smiles'])
.column('ligand_smiles').to_pylist() if s][:8000]
bdb_hv = [m.GetNumHeavyAtoms() for m in (Chem.MolFromSmiles(s) for s in smis) if m]
print(f'panel organic ligands : n={len(panel_hv):4d} median {sorted(panel_hv)[len(panel_hv)//2]} heavy atoms')
print(f'BindingDB ligands : n={len(bdb_hv):4d} median {sorted(bdb_hv)[len(bdb_hv)//2]} heavy atoms')
Output:
panel organic ligands : n= 18 median 23 heavy atoms BindingDB ligands : n=8000 median 29 heavy atoms
import numpy as np
# 18 points do not make a histogram. Draw BindingDB as the distribution and the
# panel's ligands as individual marks, so the sample size is visible rather than
# hidden behind a density curve that implies more data than there is.
fig, ax = plt.subplots(figsize=(8, 3.6))
ax.hist(bdb_hv, bins=range(0, 80, 2), density=True, color='#93c5fd',
edgecolor='none', label=f'BindingDB measured binders (n={len(bdb_hv):,})')
bdb_med = float(np.median(bdb_hv))
pan_med = float(np.median(panel_hv))
ax.axvline(bdb_med, color='#2563eb', lw=1.4, label=f'BindingDB median {bdb_med:.0f}')
ax.axvline(pan_med, color='#ea580c', lw=1.4, ls='--', label=f'panel median {pan_med:.0f}')
y = ax.get_ylim()[1]
ax.plot(panel_hv, np.full(len(panel_hv), -y * 0.035), '|', color='#ea580c',
ms=13, mew=1.6, label=f'panel organic ligands (n={len(panel_hv)})')
ax.set_ylim(-y * 0.07, y)
ax.set_xlabel('ligand heavy atoms')
ax.set_ylabel('density')
ax.set_title('Panel ligands against ligands someone actually measured')
ax.legend(fontsize=8, loc='upper right')
ax.spines[['top', 'right']].set_visible(False)
plt.tight_layout()
plt.show()
print('Each orange tick is one panel ligand. The plot already excludes the')
print('metal-only examples, which are the majority of the panel.')
Output:
Each orange tick is one panel ligand. The plot already excludes the metal-only examples, which are the majority of the panel.
How much of the window did it sample?
The PDB entry index is cross-mounted too: 252,816 deposited entries with dates and methods. It has no sequences, so it cannot be joined to the anonymised panel structure by structure. What it does give is the size and shape of the pool the 640 were drawn from.
idx_path = find_mount(
'/mnt/archives/LiteFold/PDB/metadata/entries_idx.parquet',
'~/additional-datasets/*/metadata/entries_idx.parquet',
)
idx = pq.read_table(idx_path, columns=['pdb_id', 'accession_date_iso',
'experimental_method']).to_pandas()
window = idx[idx['accession_date_iso'] >= '2024-01-01']
print(f'{len(idx):,} PDB entries total')
print(f'{len(window):,} deposited on or after 2024-01-01, the panel\'s window')
print(f'the panel is 640 of those, a {640/len(window):.2%} sample')
print()
print(window['experimental_method'].value_counts().head(4).to_string())
Output:
252,816 PDB entries total 28,440 deposited on or after 2024-01-01, the panel's window the panel is 640 of those, a 2.25% sample experimental_method X-RAY DIFFRACTION 16464 ELECTRON MICROSCOPY 11464 SOLUTION NMR 409 ELECTRON CRYSTALLOGRAPHY 51
Ask Scigantic AI
BindingDB is mounted too, under ~/additional-datasets/, with measured Ki/Kd for real drug-like ligands in 202608/parquet/. It is 231 MB, so read columns rather than the whole table.
Try asking:
- *Scan the full 128-structure protein_ligand panel and split it into metal-only and organic, then compare the organic ligands' heavy-atom distribution against BindingDB's.*
- *Using the entry index, how many PDB entries deposited since 2024-01-01 contain a non-polymer ligand, and what fraction of that pool did the 640 sample?*
- *The panel files are anonymised. Can you recover which PDB entries they are by matching sequence and ligand composition against the entry index?*
- *Parse all 128 protein_ligand files with atomworks and tell me which structures have imputed atoms, how many, and in which residues.*
Run it yourself
This sample opens as a hosted JupyterLab notebook with its datasets already mounted, so nothing has to be downloaded first. The notebook arrives with its outputs already rendered, and an AI assistant in the notebook can explain each step or change the analysis. Open the sample or browse the full catalog.