Skip to main content

interleave

Function interleave 

Source
pub fn interleave(residues: &str, structure: &str) -> Result<String>
Expand description

Weave an amino-acid sequence together with a 3Di structural string into SaProt’s product alphabet (ferritin-goh.13).

This is the join between ProstT5Translator, which emits 3Di, and SaProt, which consumes (residue, state) pairs — the pair that removes the Foldseek dependency from the structure-aware path.

§Non-standard residues become #

ProstT5’s alphabet is wider than SaProt’s: it has embeddings for X, B, O, U and Z, and SaProt has no pair for any of them. Passing one straight through would produce a token like Xa, which is not in the 441-entry vocabulary and encodes as <unk> — losing the structural state as well as the residue, silently.

Substituting UNKNOWN_STATE keeps the state: #a is in the vocabulary. It is lossy about the residue either way, but it loses strictly less, and it uses SaProt’s own convention for exactly this case.

§Errors

On a length mismatch — ProstT5’s translation is length-preserving, so a disagreement means something upstream went wrong and silently truncating to the shorter of the two would misalign every residue after the first gap — and on any character that is neither a residue nor a state, which indicates the two arguments were swapped or the structure string is not 3Di at all.

Whitespace is skipped in both arguments, matching the rest of the family.