Ahmed Doghri Logo Image
Ahmed Doghri

foldcontact

A sequence can look protein-like and still ignore the fold. foldcontact makes every infilled residue answer to the contact map, lifting constraint satisfaction from 34.5% to 100%.

foldcontact reproduced benchmark result

Protein-Looking Is Not Fold-Aware

Masked sequence models are good at producing plausible amino acids. Plausible is not the same as compatible with the residues that must meet in three-dimensional space.

foldcontact builds paired residue constraints, masks one side of every contact, and asks two infillers to rebuild it. One samples from the amino-acid alphabet. The other must satisfy the contact class.

The Contact Map Gets A Vote

The guided decoder treats hydrophobic, charged, and polar compatibility as a hard selection signal. Every prediction remains inspectable; there is no checkpoint hiding the decision.

This is a small reproduction of a structure-aware design idea, not a structure predictor. It exists to isolate the value of geometric constraints before scaling the architecture.

Update: that 100% turned out to be a tautology, not a result — mathematically guaranteed for every seed, zero variance. A genuine, harder metric shows a real but far more modest signal. Full writeup below.

The Number

Random infilling satisfies 34.5% of 1,440 held-out contacts. Contact-guided infilling satisfies 100%, a 65.5-point gain.

The controlled benchmark is educational and not a wet-lab claim. One deterministic test passes across the three-version GitHub Actions matrix.

The Perfect Score Was Definitional

The guided infiller picks its residue by directly maximizing the exact predicate, chemical group compatibility, that it's then scored on. Since every amino acid group has at least one self-compatible member, a compatible pick always exists — the metric can't help but hit 100%. Checked directly: across 40 seeds, guided_contact_satisfaction is exactly 1.0 every single time, with zero variance. It isn't measuring inference; it's re-evaluating the same rule the guided method already satisfies by construction.

A harder, non-circular question: did the guessed residue match the true, pre-masking identity, not just "is it group-compatible"? That metric can't be gamed the same way — narrowing to a compatible group still leaves up to four real candidates. Across 40 tuning seeds and a disjoint 25-seed holdout evaluated once, guided infilling recovers the true residue ~25% of the time versus ~8% for naive (close to the 1-in-12 chance rate) — a real, roughly 3x improvement, and a much more honest picture than "100% vs 34.5%." The original module is untouched and the published numbers above still reproduce exactly.

Research Basis

Inspired by the 2025 AtomWorks and RosettaFold-3 release. The portfolio number above comes from this repository's own controlled benchmark, not from the paper.

Tools Used

Python
Protein Design
Contact Maps
Sequence Infilling
Structural Biology
Metric Design
unittest