Parse Before You Align: Segment Trees for Multi-Domain Remote Homology

Proteins that share an ancestor often keep the same 3D shape long after their amino-acid sequences have drifted apart. Below roughly 25% sequence identity, the so-called twilight zone, ordinary sequence alignment stops finding these relatives. The newest search methods compare residue-level embeddings from protein language models, and they do well on single compact domains. Two problems remain. The first is multi-domain proteins, which are built from several independently folding units that evolution reshuffles, duplicates, and hinges. The second is length: residue-level methods truncate inputs to a few hundred residues. A recent 13-method benchmark found that cutting multi-domain proteins into single domains by hand improves representation-based search by more than 30% (Benchmarking protein sequence and structure search methods for remote homology detection). Search tools therefore lose a large share of their sensitivity because nobody tells them where the domains are, or which domain should be matched to which.

We propose to learn that decomposition and use it during comparison. A lightweight model proposes a small number of candidate cut points along each sequence. A chart parser then builds a binary tree over the resulting segments, using the same span-by-split-point dynamic program that natural-language parsers use for sentences and whose cost grows as the cube of the input length. Two proteins are compared by aligning their trees. Inside a segment, residues must match in order. Between segments, sibling subtrees may swap places. Because the parse runs over roughly 8 to 16 segments rather than hundreds of residues, the cubic and even sixth-power costs of hierarchical alignment become affordable.

Core Claim

Existing twilight-zone tools fall into two groups. Linear aligners such as Smith-Waterman over Foldseek's structural alphabet (Fast and accurate protein structure search with Foldseek) and DeepBLAST's learned Needleman-Wunsch (Protein remote homology detection and structural alignment using deep learning) enforce a single global residue order. That order breaks under domain rearrangement or circular permutation. Order-free late-interaction scoring, as in ProtoCol's MaxSim, which matches each query residue to its best target residue anywhere (ProtoCol: Late Interaction Retrieval for Protein Homolog Search), avoids that problem but has the opposite one. Across long multi-domain proteins, scattered residue matches from one shared common domain can outweigh everything else, and the method has no way of saying that a matched region should be a contiguous, coherent unit.

Our claim is that remote homology between multi-domain proteins is best scored by an intermediate model. It is order-preserving within learned segments and allows segments to be swapped, placed hierarchically, or deleted between them. The learned segmentation can recover most of the gain that oracle domain decomposition gives, with no manual cutting and no 256-residue truncation.

The mechanism takes one idea from each direction. From protein biophysics it takes hierarchical assembly: local folding units combine into domains. Protein folding and chart parsing cast this as CKY chart parsing on a 2D lattice toy model. From parsing it takes two things: the inversion-allowing bilingual alignment of Wu's inversion transduction grammars, and the modern tricks that make charts fast, namely top-down split prediction (Fast-R2D2) and GPU-batched inside computation with gradients by automatic differentiation (Fast and Accurate Neural CRF Constituency Parsing).

How This Differs From the Closest Work

Hockenmaier, Joshi and Dill used a chart to search conformations of a single sequence. On 24,900 lattice 20-mers they recovered the native state 96.7% of the time while visiting 2.5% of the conformation space. They did not compare proteins, and they noted that a context-free chart cannot enforce excluded volume. Our use sidesteps that limitation: we never build coordinates. The chart only organizes how two sequences' embeddings are compared.

DeepBLAST motivates the proposal. It showed that learning the scoring inside a differentiable dynamic program lifts Malidup alignment F1 from 0.098 to 0.265, but its program is strictly linear. We keep its differentiable within-segment alignment and wrap it in a hierarchical outer program.

ProtoCol supplies our residue-level scorer and is the strongest competitor. We differ in two ways. We add structure above the residue level, and we remove truncation by scoring only within segment pairs.

The benchmarking paper both motivates and constrains the work. Its 30% oracle-decomposition gain is the headroom we aim to capture. Its finding that every method fails on intrinsically disordered proteins tells us not to claim anything there, because disordered regions have no domains to parse.

Research Program

Encoder and split scorer. Each sequence is encoded once by a frozen ESM-2 model applied in overlapping windows, so length is unrestricted. On top of the per-residue embeddings sits a small bidirectional split scorer in the style of Fast-R2D2. It assigns every position a boundary probability. We keep the top $K-1$ positions, with non-maximum suppression, as candidate cuts. This yields $K$ atomic segments, with $K$ set adaptively to about length/40 and capped at 16.

Chart over segments. A CKY chart over these segments sums over all binary trees using span scores from the same encoder. Because the chart has $K$ atoms rather than $n$ residues, the parse costs $O(K^3)$ instead of $O(n^3)$. The split scorer is supervised weakly from CATH domain boundaries where available. It is also trained end to end through the retrieval loss, since the inside algorithm is differentiable and its gradient gives the posterior over trees.

Comparing two proteins. Every segment pair $(s, t)$, with $s$ from protein $A$ and $t$ from protein $B$, receives a leaf score $\ell(s,t)$. This score comes from a DeepBLAST-style differentiable local alignment over the residue embeddings of the two segments. Summed over all segment pairs, this step touches each residue pair once, so it costs $O(nm)$, where $n$ and $m$ are the two protein lengths.

A synchronous chart then combines leaf scores over span pairs. Here $S(i{:}j,\, p{:}q)$ is the best score for aligning segments $i$ through $j$ of $A$ with segments $p$ through $q$ of $B$. It either takes a leaf score, deletes a span at a learned cost, or splits both spans and combines the halves in straight or inverted order:

$$S(i{:}j,\,p{:}q)=\max\Big\{\ell,\ \max_{k,r}\big[S(i{:}k,p{:}r)+S(k{:}j,r{:}q)\big],\ \max_{k,r}\big[S(i{:}k,r{:}q)+S(k{:}j,p{:}r)\big]\Big\}.$$

This is Wu's inversion-transduction recursion, which runs in sixth-power time in its input length. Applied to segments instead of residues, the total cost is

$$O\big(nm + K_A^3 K_B^3\big),$$

where $K_A$ and $K_B$ are the segment counts of the two proteins. With $K \le 16$ the second term is at most about $1.7 \times 10^7$ cell updates, and it batches on GPU by span width exactly as in Zhang et al.

Training. The retrieval loss is contrastive over SCOPe and CATH superfamily labels with group-disjoint splits. A hinge loss on span pairs additionally rewards matching the TM-align correspondence where structures exist.

Search at scale. Full tree alignment is too slow for first-pass search over a large database. We therefore use ProtoCol-style MaxSim over segment-pooled vectors as a prefilter and rerank the top candidates with the tree alignment.

Baselines

Naive reference points. The do-nothing points are MMseqs2 sequence search and mean-pooled ESM-2 650M cosine similarity. ProtoCol reports roughly 24 ms per query for itself against over 1,000 ms for MMseqs2. It also reports beating the pooled 650M model by nearly 7 points of capped Recall@1 on SCOPe superfamily splits. These establish the floor and the known cost of pooling everything into one vector.

ProtoCol. This is the strongest learned competitor, because it already escapes the single-vector bottleneck, and it is the method our leaf scorer builds on. Its reported capped Recall@1 on group-disjoint SCOPe superfamilies is 0.946. We will retrain it on our exact splits using the same ESM-2 backbone and GPU budget. We will run it twice: at its native 256-residue truncation, and with truncation removed through the same windowed encoder we use. This keeps the length handling identical between it and us.

Foldseek. This is the strongest structure-based competitor. Its paper reports 86% and 88% of Dali and TM-align sensitivity on SCOPe. We run it on AlphaFold-predicted structures for every query and target. Because Foldseek sees 3D input that our sequence-only method does not, it is an upper reference rather than a like-for-like comparison.

DeepBLAST. On alignment quality, the baseline is DeepBLAST, with Malidup F1 of 0.265 as reported.

Multi-domain numbers. We found no reported result on Lacuna for ProtoCol or DeepBLAST on the CATH-S20 multi-domain subset. We will establish those numbers ourselves.

Beating the baselines. On the multi-domain CATH-S20 subset, success means closing at least half the gap between whole-chain ProtoCol and ProtoCol run on oracle CATH domains. On single-domain SCOPe, success means staying within one point of ProtoCol; we do not expect a gain there. On Malidup, success means exceeding 0.265 F1.

Ablations. Four ablations isolate the key ingredient. The first replaces learned cuts with fixed-length windows. The second replaces the tree alignment with a flat maximum over segment pairs. The third forbids inversion, so segments must stay in order. The fourth substitutes oracle CATH boundaries for learned ones. All share the encoder, the training data, and the tuning budget, with the same number of hyperparameter trials for each.

Why not just…?

Why not just remove ProtoCol's truncation and let MaxSim handle long proteins? This is the most serious threat. MaxSim ignores residue order, so it already tolerates rearranged domains, and on a GPU the all-pairs cost at 1,000 residues is modest. Our bet is that on long multi-domain proteins, order-free matching yields false positives when two proteins share only one common domain, and that forcing contiguity inside segments fixes this. The untruncated ProtoCol baseline tests this directly. If it matches us on the CATH-S20 multi-domain subset, the hierarchy is unnecessary, and we would report that.

Why not just cut proteins into domains with a flat boundary predictor and take the best domain-pair score? This is plausibly most of the gain, since the 30% figure in the benchmarking paper comes from decomposition alone. The flat-maximum ablation is exactly this system. The tree must beat it on queries whose relatives share two or more domains, including in different orders. The tree should show no advantage on single-shared-domain pairs, which would confirm where its benefit comes from. If the flat version wins everywhere, the proposal reduces to a learned domain segmenter, which is still a useful result.

Why not just predict structures and run Foldseek, possibly in its TM-score mode? Foldseek is fast and sensitive. However, its alignment is linear, and it degrades under hinge motions and flexible domain arrangements. It also depends on predicted structures, and the benchmarking paper reports a 36.1% drop for TM-align when prediction confidence falls below pLDDT 70. We report Foldseek separately on confident and low-confidence targets to show where a sequence-only hierarchical method is and is not competitive.

Why not just run an exact residue-level chart on GPUs? Batching makes exact inside computation fast for sentences, as shown by Zhang et al.'s 1,092 sentences per second. Proteins of 500 residues already need about $10^8$ operations for a single-sequence chart. A residue-level inversion-transduction alignment of two such proteins, at sixth power, is out of reach. Pruning to segments is what makes the method exist at all.

Decisive Experiments

The first test is on the CATH-S20 multi-domain subset from the 13-method benchmark. We measure how much of the oracle-decomposition gain the learned segment trees recover, reporting recall at the top hit and at the first false positive, against untruncated ProtoCol and the flat-segment ablation.

The second is a controlled rearrangement test. We take SCOPe and CATH multi-domain pairs, circularly permute or swap domains in one member, and track how each method's score changes. Linear aligners should collapse, MaxSim and the tree should hold, and only the no-inversion ablation of the tree should degrade.

The third is a false-positive test. We build decoys that share exactly one promiscuous domain with the query but differ in the remaining domains. Here the tree should rank true multi-domain relatives above the decoys where MaxSim does not.

The last is a check on the learned segmentation itself. We measure boundary accuracy against CATH domain assignments on held-out superfamilies, and we compare runtime against untruncated ProtoCol at 256, 512, and 1,024 residues to confirm that the $O(nm + K^6)$ cost holds in practice.

The proposal is falsified if the untruncated order-free baseline or the flat segmenter matches the tree on the first and third tests.