Structure alignment, GSA and structure search
The 3D structures of the MolNFT records (the BinaryCIF a MolNFT v2 record keeps on chain, the PDB file of a MolNFT v1 record on IPFS) are read once, written in a compact form, encoded in GSA, the GL1X structural alphabet, and indexed. On them GL1X offers three tiers of structural comparison, and a search of the structures by sequence motif:
- Pairwise alignment of any two chains with TM-align, a Go port of TMalign.cpp that reproduces the reference program.
- Structure search: one chain against every indexed protein chain, in seconds, through GSA words, local alignment with E-values and TM-score rescoring.
- Comparisons made in advance for every record: the same entry in the other collection, and experimental chains against predicted models of the same UniProt accession.
- Motif search of the structures: every indexed chain, protein, DNA or RNA, whose residues with coordinates hold a pattern (QEEY, C-x(2)-C, N-{P}-[ST]-{P}…), never across a chain break, each occurrence with its author residue numbers so it is shown in 3D.
Where: the Structure search page (/bio/structure, tabs Align two
structures, Search similar structures and Find by motif), the MolNFT card
(Search similar structures in its header and 3D panel, the find bar over its
sequences, the Structure index panel with a search per chain and the
comparisons), the API (/api/bio/structure…) and MCP (structure_align,
structure_search, structure_motif, structure_comparisons).
This page is written for a scientist who is not a specialist in structural
bioinformatics. For each tool it says what question it answers, how GL1X
computes the answer (with the parameters in the code and the reasons for
them), how to read the numbers, where the method stops being reliable, and
how it was checked. Distances are in ångströms (1 Å = 0.1 nm). The worked
examples use the structures in internal/fold/testdata, so anyone can
recompute them with the code.
| Question | Tool | What answers it |
|---|---|---|
| Do these two chains have the same fold, and which residues sit at equivalent places in space? | TM-align | TM-scores, RMSD, the structure-based alignment and the superposition |
| Which indexed proteins have a structure like this chain? | Structure search | hits ranked by TM-score, with E-values |
| Is a predicted model close to the experimental structure? Do two NFTs of one PDB entry hold the same coordinates? | Comparisons made in advance | computed once and stored with each record |
| Which structures contain a short sequence pattern, and where does it lie in 3D? | Motif search | chains with the author residue numbers of every occurrence |
The full-atom analysis of the same structures (secondary structure, solvent accessibility, pockets, interfaces, 3D templates of active sites) is described in Structure analysis, and their small molecules in the Ligand index.
Reading structures #
GL1X reads structure files with its own readers (internal/fold), so nothing
outside the binary is needed. This section explains what a structure file
contains, what GL1X keeps of it and why.
What a structure file holds #
A structure file is a list of atoms. Each atom has a name (CA for the α-carbon, N, C, O, CB…), the residue it belongs to (a chemical component such as ALA or MSE, a chain identifier and a residue number), and Cartesian coordinates x, y and z in ångströms, in the frame of the experiment or of the model. Two more numbers come with each atom. The occupancy is the fraction of the molecules in the sample in which the atom sits at that place. The B-factor of an experimental structure is the atomic displacement parameter (Ų): it grows with thermal motion and disorder, so a mobile surface loop has higher values than a buried core. Structure prediction programs write their confidence in the same column; in an AlphaFold model it is the pLDDT, from 0 to 100, higher values meaning a more reliable position (Jumper et al. 2021).
A file can describe more than one conformation. Models (MODEL records in
PDB format, pdbx_PDB_model_num in mmCIF) are whole copies of the structure,
as in an NMR ensemble. Alternate locations (altLoc) are local: one residue
or atom written two or more times, with occupancies that add up to one.
Residues carry two numberings. The author numbering is the one papers cite: a
number with an optional insertion code (52A), so that a protein can keep the
numbering of a reference homologue even where it has extra residues. mmCIF
adds a sequential numbering (label_seq_id). Author numbers are labels, not
positions: the first six residues of RNase LE (1DIX) are numbered 1X, 2X, 3X,
4X, 2, 3. Standard residues of a polymer are written as ATOM records;
modified residues, ligands, ions and waters as HETATM.
Three formats hold the same content. PDB is the original text format of fixed columns. PDBx/mmCIF writes the same information as tables of the PDBx dictionary. BinaryCIF stores those tables column by column in MessagePack, each column compressed by a chain of encodings (Sehnal et al. 2020).
- Formats: PDB, PDBx/mmCIF and BinaryCIF (MessagePack with its column
encodings: run-length, delta, integer packing, fixed point, interval
quantization, string arrays, byte arrays);
Snifftells them apart. The gzip compression MolNFT records use is undone when the file is read from the chain or from IPFS. - Telling them apart: a file that begins with a MessagePack map is
BinaryCIF; one whose first line that is not blank or a comment begins with
data_is mmCIF; one with PDB record names (HEADER,ATOM,HETATM,MODEL,REMARK…) in its first 4 KB is PDB. mmCIF and BinaryCIF are read from their first data block, mmCIF with the STAR syntax it uses (quoted values, text fields between semicolons, loops).
What GL1X keeps #
Structural comparison needs one well-defined position per residue. GL1X keeps the polymer chains of one conformation and, for each residue, the atom that stands for it: CA for an amino acid, C3′ for a nucleotide.
| Question | What GL1X does |
|---|---|
| Which model? | The first one: in PDB format the atoms up to the first ENDMDL (or the second MODEL record); in mmCIF and BinaryCIF the rows of the model number of the first atom row. The number of models is recorded. |
| Which alternate location? | For each residue, the first alternate location it shows in file order (usually A); the atoms of the others are left out. Occupancies are not compared. A residue position written with two chemical components and no alternate locations (microheterogeneity) keeps the first component. |
| Which residues form chains? | The residues of protein, RNA and DNA chains. Waters (HOH, WAT, DOD, H2O) never belong to a chain; non-polymer groups are kept apart as ligands (below). In mmCIF and BinaryCIF a residue belongs to a polymer when it has a label_seq_id and its entity is a polymer; the entity's polymer type (_entity_poly.type) decides whether a chain is protein, RNA or DNA. Without it, the majority of its residues decides. |
| How is each residue written? | Its one-letter code, author number and insertion code, the coordinates of its CA atom (C3′ for nucleotides), its B-factor and whether it was written as HETATM. |
| What about modified residues? | Modified residues such as MSE (selenomethionine) count as their parent and keep their HETATM flag: MSE is M, SEP is S, PTR is Y, HYP is P, PSU is U, 5MC is C. D-amino acids take the letter of their L form; selenocysteine is U, pyrrolysine O; an amino acid GL1X does not know but with CA, N and C atoms is X; inosine is N. Residues are named by their PDB chemical components (see Names and identifiers). |
| A HETATM residue in a PDB file? | PDB files do not say which residues belong to a polymer. A HETATM residue is part of its chain when it is bonded to the residue before or after it (C–N, or O3′–P for nucleotides, at most 2.5 Å) or when its number lies within the numbers of the chain's ATOM residues (a modified residue between two gaps). Otherwise it is a ligand: a free amino acid, nucleotide or cofactor with the same atoms (ARG, GTP, SAH) numbered after the chain. |
| Broken values? | An atom whose coordinates are not numbers or lie beyond 10⁶ Å is left out; an occupancy or B-factor that is not a number reads as 0. |
| How large? | GL1X refuses a file with more than 2,000,000 atoms in its first model and stores at most 1,000 chains of a structure; a file has 240 seconds to be fetched and read. A BinaryCIF column may not decode to more values than the file has bytes (plus 1 KB, at most 200 million), so a small crafted file cannot claim gigabytes. |
Why one atom per residue? The backbone fixes the fold, and consecutive CA atoms of a protein lie about 3.8 Å apart, so the CA trace draws the chain's path with one point per residue. TM-align and GSA work on that trace alone, which makes them indifferent to missing side chains and fast. The same reading keeps the full atoms for the structure analysis.
Ligands: the non-polymer groups of the first model (cofactors, drugs,
ions, sugars, additives; waters left out), each with its component, author
chain and number, heavy atoms and the polymer residues within 4.5 Å of it,
and the components' names and formulas from _chem_comp or HETNAM,
HETSYN and FORMUL, kept in molecular_ligands and
molecular_ligand_components with the chains, in the same transaction
(→ Ligand index).
Chain breaks and numbering #
Experimental structures often lack residues that were too mobile to be seen: a disordered loop, a flexible terminus. The file then jumps from residue 49 to residue 56, and the two residues that follow each other in the file are not bonded. GL1X finds such gaps from the coordinates, not from the numbers (author numbers can skip without a gap, or restart).
Chain breaks: two consecutive residues whose CA atoms lie more than
4.3 Å apart (C3′ atoms more than 8.5 Å apart in DNA and RNA) are not
bonded, residues are missing between them; the residue after the gap
begins a new piece of the chain (breaks, 0-based). The same 4.3 Å rule
counts the chain breaks of the structure features and keeps GSA's local
frames to one piece. Chains stored before 2.8.1 get theirs from their
packed traces, a batch at a time, once the indexing process of 2.8.1
starts (no structure file is read again); the index follows.
The thresholds sit just above the bonded distances: about 3.8 Å between consecutive CA atoms, and 5 to 7.5 Å between consecutive C3′ atoms of a nucleic acid (the range the code's tests use). A piece of chain moved away from the rest breaks too.
Example (a test of the readers and of the motif search): 1AKI, hen egg-white
lysozyme, has 129 residues and no break. The same file without residues 50
to 55 has 123 residues with coordinates and one break, breaks = [49]: the
residue at position 49 (0-based) is Leu56, the first one after the gap. The
record's structure then writes its author numbering in runs as
"numbering": "1-49,56-129", and a motif that would join Gly49 to Leu56 is not
reported (see Motif search).
Header facts and predicted models #
Facts from the header: the entry ID, title, experimental method, the
number of models, UniProt accessions per chain (PDB DBREF, mmCIF
struct_ref and struct_ref_seq), and whether the file is a computed model
(ModelCIF tables, a THEORETICAL MODEL method or an AlphaFold header), in
which case B-factors are pLDDT.
In detail: PDB files give their accessions in DBREF records, or in
DBREF1/DBREF2 pairs for long accessions; mmCIF files in struct_ref, with
the chains from struct_ref_seq (or, failing that, from
_entity_poly.pdbx_strand_id). References to UniProt are recognized under
the database names UNP, UNIPROT, UNIPROTKB, SWS and TREMBL. A file counts as
a computed model when it has any ModelCIF (_ma_) table, or when its method
or title contains THEORETICAL MODEL, ALPHAFOLD or PREDICTED (in PDB files
also PREDICTION). The flag tells how to read the B-factor column, and
decides which side of an
experiment–prediction comparison a chain is
on.
Observed accessions (3.4.0). A file can map one chain to several
UniProt entries: a fusion protein (a receptor with T4 lysozyme inserted in
a loop, a protein with a fused partner), or an expression tag. A chain's
accessions are the entries whose mapped stretch its coordinates hold: each
reference's residue range for the chain (PDB DBREF columns 15–24,
DBREF1, mmCIF struct_ref_seq.pdbx_auth_seq_align_beg/_end, in author
numbering) must contain residues with coordinates, at least 10 of them, or
half of a shorter stretch (a peptide). A reference that states no range is
kept; when no reference passes (numbering that does not match the
coordinates), all of them are kept. declared_accessions lists every entry
the file maps to the chain. The experimental–predicted comparisons and the
protein pages follow the observed ones, so a fusion
chain is compared with the predicted models of the parts it holds. Example
(a test of the reader): a chain whose DBREF records map residues 1–20 to
p53 (P04637), 21–120 to S100A4 (P26447) and 121–140 to annexin A2 (P07355),
with coordinates for residues 121–140 only, keeps P07355 and declares all
three; a nine-residue peptide keeps its accession; a chain whose DBREF
range is numbered 501–520 while its coordinates run 1–20 keeps the declared
accession.
Biological assemblies (3.4.0). The readers also keep the biological
assemblies the file defines (mmCIF pdbx_struct_assembly,
pdbx_struct_assembly_gen, pdbx_struct_oper_list; PDB REMARK 350): for
each, its id, how it was determined (details: author, software or both),
its oligomeric state and count, the deposited chains it uses, the chain
copies its operators make and whether some are copies the deposited
coordinates do not hold (symmetry). They give each chain its assemblies,
and each interface and pocket the
assembly holding its chains in their deposited arrangement (moved together
by its operators). GL1X does not build the symmetry copies. Operator
expressions are read as written ((X0)(1-60) stays two ranges, never
expanded; 1,2,3 and 1-3 name the same operators), chains are looked up
by set, and the reading is bounded, so no file makes it costly: at most
4,096 generators, 4,096 operators, 1,024 assemblies, four factors of 256
items an expression, a million asym ids in all (a file built to the limits,
a thousand generators of 256 operators against 50,000 operators, reads in a
fraction of a second; one of 20,000 chains each in eight assemblies in
about half a second).
Storage, the index and the queues #
- Storage: each chain's trace is packed (
GC1: codes, coordinates to 0.001 Å, numbers, insertion codes, B-factors to 0.01, HETATM flags, delta-encoded and deflated) in about 9 bytes per residue, inmolecular_chains3dwith its sequence, GSA string, accessions and chain breaks; identical chains of a record point to the first one (same_as). For 1AKI the 129 residues pack into 1,166 bytes, 9.04 bytes a residue. - Identical chains are chains of one record of the same kind with the same sequence of residues with coordinates (the copies of a homo-oligomer, or of a molecule repeated in the crystal). Their coordinates may differ; the search index and the motif search keep the first one and name the others.
- The search index in each web process loads every chain at start,
then applies the records whose structure or chain rows changed, in order
of time, collection and token from the last one applied (a batch of 5,000
may end inside a group changed in one statement), once they are 15
seconds old, and rebuilds from scratch every six hours. Its status (in
GET /api/bio/structure) giveslast_errorwhile a load or refresh fails (the next one that succeeds clears it) andlast_failure, the last error with when it happened and when the index recovered (recovered_at), so a failure that passed no longer reads as a current one. Both leave the server's addresses, connection settings (quoted or not) and the user, password and host of a connection URL out (the log keeps them). - The queue: a worker pool of the molecular indexer reads each record's
structure file once (
GL1X_STRUCTURE_WORKERS; autotune: one per CPU, 4 to 16, 4 below 4 GB of memory) and records the outcome inmolecular_structures(complete, retry, failed, none). A passing failure (a node, a gateway, a timeout; a node that could not run a contract call within its gas cap or return-data limit, which before 3.4.0 was taken for the contract's answer — a revert, or a fault of the contract's own code such as an invalid opcode, still is) is retried two minutes later, then after twice as long each time, about 17 hours at most. A structure that failed (not a readable file, too large) or links none is read again too, after 6 hours, then after twice as long each time, a week at most (counted apart from the passing failures before it), going back to the queue only while fewer than 100 records wait in it, so new records never queue behind them. The file of a MolNFT v1 record comes straight from IPFS through the metadata the molecular indexer already kept for the record, without reading the contract and the metadata document again; a MolNFT v2 record's comes from the contract. Reading mostly waits on the node and the IPFS gateways, so the workers pause only while the node is slow to serve new blocks (a slow backfill of old blocks does not hold them back). When no file waits to be read for the first time, the free workers read the structures read before 2.9.0 again for their ligands, experimental structures first, keeping their chains as they are. Experimental structures read before 3.4.0 are read again for their biological assemblies and observed accessions alone (the header pass: a third of the free workers, at least one of two or more, aboutGL1X_HEADER_RATEstructures a minute, default 120, with bursts of a sixth of that;offor 0 stops it). - The comparison queue: a record whose structure was read waits for its
comparisons (
compared_atempty) in a queue of its own, a quarter of the CPUs at once (1 to 8), so TM-align, which is CPU work, never holds up reading (see Comparisons). A record not read yet is read on the spot when someone aligns or searches with it.
How the readers were checked #
The tests of internal/fold read the same entry, 1AKI, from its PDB, mmCIF and
BinaryCIF files and require the same chain, residues, author numbers and
names, coordinates within 0.002 Å, B-factors within 0.01, method, number of
models and UniProt accession (P00698). Other tests read a BinaryCIF written
by Mol*'s ciftools (T4 lysozyme, 3LZM), insertion codes (1DIX), an RNA chain
by its C3′ atoms (the riboswitch 4GXY, 162 nucleotides), a predicted model
whose B-factors are pLDDT, each BinaryCIF encoding with masks, the rules of
the table above on small hand-written files, and broken or hostile inputs. A
packed chain unpacks to its coordinates within 0.001 Å and its B-factors
within 0.006.
TM-align #
TM-align (Zhang & Skolnick 2005) superposes two protein structures without regard to their sequences and scores the result with the TM-score. It answers two questions at once: do these two chains share a fold, and which residues occupy equivalent places in space? It needs only the CA atoms (C3′ for nucleic acids), so it compares any two chains: an experimental structure with a predicted model, or two proteins whose sequences have no detectable similarity.
The TM-score #
TM-score = (1 / L_ref) · Σ_i 1 / (1 + (d_i / d0(L_ref))²)
d0(L) = 1.24 · (L − 15)^(1/3) − 1.8 (0.5 for short chains)
where d_i is the distance between the i-th pair of aligned CA atoms after superposition and L_ref the length of the chain the score is normalized by. A TM-score is between 0 and 1, does not depend on the length the way RMSD does, and has a statistical meaning: unrelated proteins score about 0.17, and above 0.5 two structures mostly share their fold (Xu & Zhang 2010).
Each aligned pair adds a term between 0 and 1 that depends on its distance relative to d0. A pair at distance d0 adds one half, a pair three times farther adds a tenth, and a residue of the reference chain that is not aligned adds nothing. The sum is divided by the length of the reference chain, so the TM-score reads as the share of the reference that is well superposed, with a soft rather than a sharp cut-off. The TM-score of a given alignment is the maximum of this sum over every superposition, which is what the TM-score search described below looks for.
| d / d0 | 0 | 0.5 | 1 | 2 | 3 |
|---|---|---|---|---|---|
| Term added by the pair | 1 | 0.8 | 0.5 | 0.2 | 0.1 |
Why d0 grows with length: two unrelated chains, superposed as well as possible, have residues farther apart on average when they are longer. d0 follows that growth so that the TM-score of random pairs does not depend on the length (Zhang & Skolnick 2004). For proteins GL1X uses the formula above with d0 = 0.5 Å for chains of 21 residues or fewer, and never less than 0.5 Å:
| Chain length L | d0 (Å) | score_d8 for two chains of length L (Å) |
|---|---|---|
| 30 | 1.26 | 7.66 |
| 50 | 2.26 | 8.35 |
| 100 | 3.65 | 9.47 |
| 129 | 4.21 | 9.95 |
| 200 | 5.27 | 10.85 |
| 300 | 6.36 | 11.80 |
| 500 | 7.94 | 13.18 |
| 1,000 | 10.54 | 15.41 |
(score_d8, the distance beyond which TM-align drops a pair from its final
alignment, is explained below.) For
lysozyme (129 residues, d0 = 4.21 Å) a pair 1 Å apart adds 0.947, a pair 2 Å
apart 0.816, a pair 4.21 Å apart 0.5 and a pair 8.4 Å apart 0.2.
Which length to divide by. The same alignment gives a different TM-score for each reference length. GL1X reports three: normalized by chain A, by chain B, and by their average length. When the chains differ in size the choice matters. Hen egg-white lysozyme (1AKI, 129 residues) against 1QGI chain A (259 residues; the test suite describes it as sharing the lysozyme-like fold) gives 0.534 normalized by the lysozyme, 0.320 normalized by 1QGI and 0.400 by the average length: most of the small protein finds a place in the large one, while most of the large one has no counterpart. Normalize by the chain whose fold you are asking about; normalize by the larger chain to ask whether the two whole chains are alike.
RMSD and the TM-score #
The root-mean-square deviation (RMSD) of N aligned pairs is the square root of the mean squared distance between them after the best superposition:
RMSD = √( (1/N) · Σ_i |R·x_i + t − y_i|² ) minimized over the rotation R and translation t
The best rotation and translation have a closed-form solution (Kabsch 1976), which TM-align uses for every superposition it tries. RMSD is a good measure for two copies of one structure, but a poor one for comparing different proteins. It depends on how many pairs are counted (a longer alignment includes worse pairs), and squaring makes it dominated by its largest deviations, so a single moved loop or domain inflates it however well the rest agrees. The TM-score saturates instead: a far pair adds almost nothing, never a penalty.
A computed example shows the difference. Take 1AKI and move part of it as a rigid body, as a hinge motion would, by rotating it about an axis through the CA atom of the first moved residue:
| Residues moved | Rotation | RMSD over all 129 pairs | TM-score | TM-align's aligned pairs, their RMSD |
|---|---|---|---|---|
| 101–129 (29 residues) | 10° | 1.26 Å | 0.932 | 129, 1.26 Å |
| 101–129 | 45° | 5.39 Å | 0.812 | 112, 1.94 Å |
| 61–129 (69 residues) | 10° | 1.67 Å | 0.877 | 129, 1.67 Å |
| 61–129 | 30° | 4.96 Å | 0.665 | 104, 2.87 Å |
| 61–129 | 45° | 7.34 Å | 0.610 | 93, 3.01 Å |
Turning the last 29 residues by 45° raises the RMSD over all residues to 5.39 Å, a value that would suggest unrelated structures, while the TM-score of 0.812 still says that most of the chain superposes. TM-align's own RMSD stays small because it is computed over the pairs it keeps aligned. Hence the rule for reading results: an RMSD means little without the number of pairs it was computed over.
How TM-align finds the alignment #
The algorithm builds several initial alignments (gapless threading, an alignment of secondary structures assigned from CA distances, alignments of superposed fragments, and a combination of secondary structure and distance), then improves each by dynamic programming on the score matrix 1/(1 + (d_ij/d0)²) of the current superposition, re-superposing with the TM-score's own search (fragments of the alignment as seeds, iterative extension) until the alignment stops changing, and keeps the best.
The search has to find two things at once, the residue correspondence and the superposition, and each depends on the other: hence the alternation. The details below follow the port; chain A, of length L_A, is moved onto chain B, of length L_B.
During the search TM-align uses parameters of the shorter length
L_min = min(L_A, L_B): a slightly larger d0 than the final one (the formula
above plus 0.8 Å), a distance d0_search for selecting close pairs (that d0
held between 4.5 and 8 Å), and a cut-off beyond which a pair no longer counts:
score_d8 = 1.5 · L_min^0.3 + 3.5 (Å; 9.95 Å for two chains of 129 residues)
Secondary structure is assigned from CA distances alone. A residue i is helix (H) or strand (E) when the distances between the five CA atoms i−2 to i+2 are within a tolerance of those of an ideal helix or strand; failing that it is a turn (T) when CA(i−2) and CA(i+2) are closer than 8 Å, and otherwise coil (C). The two residues at each end of an element are therefore left out.
| Distance between CA atoms | Ideal helix | Ideal strand |
|---|---|---|
| i−2 to i, i−1 to i+1, i to i+2 | 5.45 Å | 6.1 Å |
| i−2 to i+1, i−1 to i+2 | 5.18 Å | 10.4 Å |
| i−2 to i+2 | 6.37 Å | 13 Å |
| Tolerance on each | 2.1 Å | 1.42 Å |
The initial alignments, in the order TM-align tries them:
| Stage | Initial alignment | Refinement |
|---|---|---|
| 1. Gapless threading | B slides along A without gaps, at every offset that overlaps at least half of the shorter chain (and at least 5 residues); each offset gets a quick TM-score (superpose all pairs, then twice more on the pairs within about d0_search of each other, keep the best of the three) | always: up to 30 rounds with each gap penalty |
| 2. Secondary structure | the two H/E/T/C strings aligned by dynamic programming (1 for the same letter, gap penalty −1) | when its TM-score exceeds 0.2 × the best so far: up to 30 rounds with each gap penalty |
| 3. Local superposition | fragments of 20 and 100 residues (at most a third and a half of the shorter chain) taken from both chains every 15 to 45 residues, by chain length; each fragment pair is superposed and the whole chains aligned under that superposition (score 1/(1 + (d/d01)²), d01 = d0 + 1.5 Å, no gap penalty); the best by quick TM-score is kept | when its TM-score exceeds 0.4 × the best (0.1 when the shorter chain has 40 residues or fewer): up to 2 rounds with each gap penalty |
| 4. Superposition and secondary structure | the best alignment so far, superposed; the chains aligned again on 1/(1 + (d/d01)²) plus 0.5 where the secondary structures agree, gap penalty −1 | same condition: up to 30 rounds with each gap penalty |
| 5. Fragment threading | the longest stretch of each chain whose consecutive CA atoms lie within 4.25 Å (the limit relaxed by steps of 10% until the stretch holds 4 residues, or a third of the chain if that is fewer), threaded without gaps along the other chain | same condition: up to 2 rounds, gap penalty 0 only |
| 6. A given alignment | only when one is passed in (TM-align's -i) | up to 30 rounds with each gap penalty |
A refinement round aligns the two chains by dynamic programming (Needleman & Wunsch 1970) on the score matrix 1/(1 + (d_ij/d0)²) of the current superposition, where d_ij is the distance between residue i of A and residue j of B. A gap costs its opening penalty once, whatever its length (−0.6 in a first series of rounds, 0 in a second), and gaps at the ends are free. The new alignment is then superposed by the TM-score search, and the next round starts from that superposition, until the TM-score changes by less than 10⁻⁶. Such alignments always keep the order of both chains.
The TM-score search finds the superposition of a given alignment that
maximizes the TM-score. Its seeds are stretches of the aligned pairs of
decreasing length (all of them, then half, a quarter… down to 4 pairs), each
started every 40 aligned positions during the search. Each seed is
superposed; the pairs then closer than d0_search − 1 Å are superposed again,
then those closer than d0_search + 1 Å, up to 20 times or until the set of
pairs stops changing. Every superposition met along the way is scored, only
pairs within score_d8 counting, and the best is kept. Starting from short
fragments lets the search lock onto a well-superposed core even when the rest
of the alignment differs.
The final answer. The best alignment is superposed once more, with seeds
at every position. Aligned pairs farther apart than score_d8 after this
superposition are dropped (the alignment shows them as gaps); the rest is
the aligned length. The RMSD is computed over these pairs. The TM-scores
normalized by B, by A and by the average length are each maximized by the
TM-score search over the same pairs, with the d0 of their own length. The
superposition returned is that of the TM-score normalized by B.
Default and fast modes #
Fast mode follows fTM-align (Dong et al. 2018): fewer initial alignments and iterations, for searches and comparisons where speed matters. In the code the differences are these:
| Step | Default | Fast |
|---|---|---|
| Gapless threading | every offset | every fifth offset |
| Local superposition | fragments every 15 to 45 residues | five times farther apart |
| Fragment threading | stretch of at least 4 residues | at least 8 residues, fewer offsets tried |
| Refinement | up to 30 rounds per gap penalty | up to 2 |
| Final superposition | seeds at every position | seeds every 40 positions |
The fast mode usually gives the same answer. Hen egg-white lysozyme onto T4 lysozyme scores 0.4421 in the default mode and 0.4420 in the fast mode. Neither mode is guaranteed to find the higher score, because both are heuristics: for 1AKI against the unrelated 3KCS (a GFP-like β-barrel) the fast mode finds a TM-score of 0.333 and the default mode 0.308. This is why the precomputed comparisons keep the better of the two answers when they run both.
Nucleic acids #
Nucleic acid chains are aligned by their C3′ atoms and scored on the RNA scale of the TM-score; a protein chain is not aligned with a nucleic acid chain.
On that scale d0 is 0.3 Å for chains of up to 11 nucleotides, 0.4 Å for 12 to 15, 0.5 Å for 16 to 19, 0.6 Å for 20 to 23 and 0.7 Å for 24 to 29; from 30 nucleotides on, d0 = 0.6 · √(L − 0.5) − 2.5 Å (5.12 Å for the 162 nucleotides of 4GXY). Nucleic acid chains are not encoded in GSA and are not searched by structure; the motif search reads them.
The GL1X port #
The port (internal/fold/tmalign.go, align.go) translates
TMalign.cpp version 20190822 function by function and keeps the order of its
floating-point operations, so both programs give the same alignments, scores
and superpositions:
- Compared with the reference program (Debian's
tm-align20190822) on 2,260 comparisons in its default, fast (-fast), fixed-alignment (-I) and initial-alignment (-i) modes, the results agree; the only difference is one-icase where two alignments tie and a trigonometric function of the C library differs in its last bit. - The test suite carries 90 pairs with the reference program's answers in the
default and fast modes and in the fixed-alignment mode
(
internal/fold/testdata/tmalign_expected.json.gz) and checks them on every build, bit for bit on amd64.
Keeping the order of floating-point operations matters because rounding differs with the order of additions and multiplications, and a tiny difference can change which of two near-equal alignments wins. The reference answers (TMalign.cpp built with g++ -O2, printed to 15 significant digits) cover the 90 ordered pairs of ten test chains in the default and fast modes and 24 fixed-alignment cases. On amd64 the test requires the TM-scores within 10⁻¹², the RMSD and the superposition within 10⁻⁹, and the alignment strings, aligned lengths and identities to be the same; on other processors, which may fuse multiplications and additions, the TM-scores and RMSD within 10⁻⁴. Further tests align a chain with a rotated and translated copy of itself (TM-score 1, RMSD below 10⁻⁶), and refuse a chain of fewer than 3 residues, a protein against a nucleic acid, and an initial alignment that is not in the order of both chains.
Reading an alignment answer #
An alignment answer (POST /api/bio/structure/align, MCP structure_align)
gives the TM-scores normalized by chain A, by chain B and by their average,
RMSD over the aligned pairs, the aligned length, pairs within 5 Å, sequence
identity, the structure-based alignment (: pairs closer than 5 Å, . other
aligned pairs) with GSA rows, every aligned pair with its distance, author
residue numbers, confidence values, and the superposition (rotation and
translation, and the same transform as the column-major 4×4 matrix Mol*
takes). Two chains whose lengths multiply to more than 12 million cells are
not aligned (3,464 residues each).
| Field | Meaning |
|---|---|
tm_score.by_a, by_b, by_average | the TM-scores normalized by the length of A, of B (the reference A is moved onto) and of their average |
d0.a, d0.b, d0.average | the d0 of each normalization (Å) |
rmsd, aligned_length | RMSD over the aligned pairs and their number (pairs within score_d8) |
within_5a | aligned pairs closer than 5 Å, the : of the alignment |
identical, identity | identical residues among the aligned pairs, and their share of the aligned length |
alignment | rows a, match and b as TM-align prints them, and gsa_a, gsa_b, the GSA letters in the same columns (protein chains only) |
pairs | [position in A, position in B, distance in Å]: positions count the residues with coordinates from 0; residues turns them into author numbers |
confidence | each residue's B-factor (pLDDT for a predicted model) |
rotation, translation, matrix | x′ = rotation · x + translation moves A onto B; matrix is the same transform for Mol* |
Worked examples, all computed with the port on the test chains (A is moved onto B; default mode):
| A onto B | TM by A | TM by B | RMSD | Aligned | Within 5 Å | Identity |
|---|---|---|---|---|---|---|
| 1AKI (hen lysozyme, 129) onto 2NWD X (a lysozyme, 130) | 0.978 | 0.971 | 0.65 Å | 129 | 129 | 60.5% |
| 1AKI onto 1HML A (α-lactalbumin, 123) | 0.876 | 0.916 | 1.47 Å | 123 | 122 | 36.6% |
| 3KCS A (214) onto 6OA8 A (232), two GFP-like barrels | 0.929 | 0.861 | 1.76 Å | 213 | 207 | 23.9% |
| 1AKI onto 1QGI A (259) | 0.534 | 0.320 | 4.01 Å | 112 | 92 | 7.1% |
| 1AKI onto 3LZM A (T4 lysozyme, 164) | 0.442 | 0.370 | 4.36 Å | 90 | 64 | 10.0% |
| 1AKI onto 3KCS A (unrelated) | 0.308 | 0.224 | 5.67 Å | 83 | 44 | 4.8% |
The first three pairs share their fold beyond doubt, the two barrels with only 24% of their aligned residues identical: structure stays similar long after sequence has diverged. Hen egg-white and T4 lysozyme are a classic distant pair (the 3LZM file itself cites a paper titled "Common Precursor of Lysozymes of Hen Egg-White and Bacteriophage T4"): their TM-scores fall below 0.5 and only 90 residues align, 64 of them within 5 Å. Part of their alignment:
1AKI 21 RGYSLGNWVCAAKFESNFNTQATNRNTDGSTDYGILQINSRWWCN---DGRTPG--SRNLC-NI
.: :::::::::: :::.:::....::::: ::::::. ..:: . . .:
3LZM 1 ---MN-IFEMLRIDEG--LRLKIYKDTEGYYTIG-IGHLLTK---SPSLNAA--KSE-L--DKA
The match line marks the core that superposes; in the full alignment much of the second half of T4 lysozyme has no counterpart. The unrelated pair at the bottom of the table shows what chance looks like at this size: a TM-score near 0.2 to 0.3, with an alignment of 83 pairs that is mostly meaningless.
Pitfalls of pairwise alignment #
- Normalization. A TM-score above 0.5 normalized by a short chain does not mean the two chains are alike: it means the short one fits into the long one. Read both normalizations.
- Order. Alignments keep the order of both chains. A circular permutation or a swapped domain is not aligned as such; only the longest part in order is.
- Rigid bodies. The superposition is rigid. Two conformations of a hinged protein score lower than their domains would separately; align a domain alone by sending a structure file that holds only it.
- Predicted models. Low-confidence regions of a predicted model (low pLDDT, often disordered tails) are aligned like any other residues and lower the TM-score normalized by the model. The precomputed comparisons report the mean confidence of the aligned residues, which helps to tell such cases apart.
- What is compared. Only the first model and the first alternate location are read, so one conformer of an NMR ensemble stands for all. Name the chain you mean: a chain left out is chosen for you (see API and MCP).
- Size. Chains of fewer than 3 residues are not aligned, nor two chains whose lengths multiply to more than 12 million.
GSA, the GL1X structural alphabet #
Comparing one chain with hundreds of thousands of others by TM-align alone
would take hours. Like amino acids for sequences, a structural alphabet writes
each residue of a chain as one letter of a small alphabet so that chains can
be compared as strings, quickly, before TM-score confirms the best. GSA is
GL1X's own: 20 states, written a to t (lower case, to tell them from amino
acids), computed from CA atoms only.
At the pace of the benchmark below (616,200 TM-align runs in 5 hours 17 minutes on two virtual CPUs), one query against the 707,000 chains of the speed test would take about six hours. An alphabet removes the expensive part. A 3D comparison has to search for a superposition, and it cannot be prepared in advance; a GSA letter depends only on the shape of the chain around a residue, not on where the chain sits or how it is turned, so every chain is encoded once, when it is indexed. Comparing two residues then costs one lookup in a table of scores, and the methods that make sequence search fast apply unchanged: short words looked up in a table, two hits on a diagonal, and local alignment with E-values. TM-score is computed only for the few hundred best candidates.
What a GSA letter describes #
For each residue i GSA computes 14 numbers from the CA trace. A local frame is built at i from the positions of i−1, i and i+1 (e2 along the chain, e1 along the outward bisector, e3 their cross product), and a virtual side-chain centre is placed 2.4 Å from CA along e1. The residue's closest non-local neighbour j is the residue whose centre is nearest to i's centre, more than two positions away along the chain and within 16 Å.
a = CA(i−1) − CA(i) b = CA(i+1) − CA(i)
cos θ(i) = (a · b) / (|a| · |b|) virtual bond angle at i
τ(i) = dihedral(CA(i−1), CA(i), CA(i+1), CA(i+2)) virtual torsion
e2 = unit(CA(i+1) − CA(i−1)) along the chain
e1 = unit(u − (u · e2) · e2), u = −(a + b) outward bisector
e3 = e1 × e2
centre(i) = CA(i) + 2.4 Å · e1
j = the residue k with |k − i| > 2 whose centre is nearest to centre(i), if closer than 16 Å
r = CA(j) − CA(i)
| # | Feature | Describes |
|---|---|---|
| 0 | cos θ(i) | the virtual bond angle at i (i−1, i, i+1) |
| 1, 2 | sin, cos τ(i) | the virtual torsion of i−1, i, i+1, i+2 |
| 3, 4 | sin, cos τ(i−1) | the virtual torsion of i−2, i−1, i, i+1 |
| 5 | d(i, j) | the CA–CA distance to the neighbour (capped at 16 Å) |
| 6, 7, 8 | r̂ · e1, e2, e3 | the direction of the neighbour in i's frame |
| 9 | e2(i) · e2(j) | relative chain direction (parallel or antiparallel) |
| 10 | e1(i) · e1(j) | relative side-chain direction |
| 11 | sign(j − i) · min(log₂ abs(j − i), 8) / 8 | sequence separation, signed and logarithmic |
| 12 | cos θ(j) | the neighbour's own conformation |
| 13 | contacts | CA atoms within 10 Å of i's centre (how buried i is) |
What the features capture. The virtual bond angle and torsion of the CA trace tell helix from strand: the helical states of GSA have θ near 93° and τ between +50° and +59°, the main strand states θ of 120° to 123° and τ between −146° and −161°. The two torsions through i see one residue on each side, so the start and the end of a helix differ. The outward bisector points away from the two neighbours, roughly where the side chain points; the centre placed along it makes residues whose side chains face each other near neighbours even when their CA atoms are not the closest. Skipping the residues at most two positions away leaves out those that are close in any conformation, and the 16 Å reach keeps only residues nearby. The direction and orientation features say how the neighbour sits: on the side-chain side or not, in a parallel or antiparallel chain (as across the strands of a β-sheet), with side chains pointing the same way (+1) or at each other (−1). The separation is signed because a partner earlier and a partner later in the chain are different situations, and logarithmic because 3 and 6 residues differ more than 103 and 106; it stops growing at 256. The contact count measures burial.
Chain breaks (consecutive CA atoms more than 4.3 Å apart) are respected: angles and torsions that would span a break are left at neutral values. A residue without a frame (the first or last residue of a piece of chain) takes cos θ = −0.25 (θ ≈ 104.5°, between helix and strand), a torsion whose four atoms are not joined takes sin = cos = 0, and a residue without a frame or without any neighbour within 16 Å gets the neighbour features of none (a distance of 16 Å, the others 0). Its contacts are still counted. The features are standardized (mean and scale over the training set) and weighted (the sequence separation counts twice, as the training's feature search chose); the residue's state is the nearest of 20 centroids:
z_f = w_f · (v_f − mean_f) / sd_f w = 2 for the separation (feature 11), 1 for the others
state(i) = the k among the 20 states that minimizes Σ_f (z_f − c_kf)²
The first five features see the backbone's local conformation, as classic structural alphabets do (Protein Blocks, de Brevern et al. 2000; 3D-BLAST, Yang & Tung 2006); the others see the residue's tertiary environment, the idea that made Foldseek's 3Di alphabet sensitive (van Kempen et al. 2024). GSA's contribution is a CA-only alphabet trained on SCOP for this search pipeline, every stage from its states to its search thresholds, with an open recipe that reproduces its parameters.
Worked example: residues of hen egg-white lysozyme (1AKI), with the secondary structure that GL1X's DSSP assigns from the full atoms (the feature values are the code's own):
| Residue (DSSP) | θ, τ(i) | Closest non-local neighbour | Orientation (e2·e2, e1·e1) | CA within 10 Å | State |
|---|---|---|---|---|---|
| Lys1 (chain start) | no frame | none | — | 13 | c |
| Ala31 (α-helix) | 91.9°, +49.6° | Trp111, 4.80 Å, 80 residues later | −0.71, −0.60 | 24 | p |
| Thr43 (β-strand) | 128.5°, −171.0° | Tyr53, 4.90 Å, 10 later | −1.00, +1.00 | 20 | r |
| Thr51 (β-strand) | 128.3°, −134.7° | Arg45, 4.45 Å, 6 earlier | −0.87, +0.82 | 20 | a |
| Ile58 (β-strand) | 112.6°, −118.4° | Ser91 (in a helix), 7.79 Å, 33 later | −0.38, −1.00 | 27 | k |
| Leu129 (chain end) | no frame | none | — | 12 | c |
Thr43 and Tyr53 lie on neighbouring strands of the antiparallel β-sheet of
lysozyme (chain directions opposite, side chains on the same side of the
sheet). Thr43, whose partner comes later, is r; Thr51, whose partner comes
earlier, is a. Over the first 60 residues the three strings read:
DSSP -B--HHHHHHHHHHTT-TTBTTB-HHHHHHHHHHHHTTBTT-EEE-TTS-EEETTTTEET
seq KVFGRCELAAAMKRHGLDNYRGYSLGNWVCAAKFESNFNTQATNRNTDGSTDYGILQINS
GSA crkhnftgfpqfpqibjdrnpobaefpssfpfsffiolbnplrhrhobbiabkisiakan
The helix of residues 5 to 14 is written as n, a helix start, followed by
helical states (f, t, g, p, q); the strands 43 to 45 and 51 to 53
read rhr and abk, and the chain's first residue c.
GSA strings do not depend on where a chain sits or how it is turned. A test encodes every test chain before and after a rotation and translation and allows at most 1% of the states to change, where a state boundary falls between two rounding errors. A chain cut in two and the halves moved far apart still gets one letter per residue.
The twenty states #
The centroids of the states are points in the standardized feature space.
Converted back to physical units they give the typical geometry of each
state. The table lists them with each state's share of the training
residues, its substitution score against itself (in 1/8 bit, see below), and
the secondary structure GL1X's DSSP assigns to its residues in the protein
chains of 10 residues or more of eight entries in internal/fold/testdata
(1AKI, 1DIX, 1GBT, 1HVR, 1RMD, 3HSY, 3LZM, 4DST: 1,948 residues; H counts H,
G and I, E counts E and B).
| State | Share | Self score | Local shape | Closest non-local neighbour, typically | CA within 10 Å | DSSP H / E / other |
|---|---|---|---|---|---|---|
| a | 6.1% | 28 | strand (θ 122°, τ −156°) | 4.8 Å, about 24 residues earlier, antiparallel, the partner extended | 18.8 | 0.00 / 0.74 / 0.26 |
| b | 3.7% | 16 | extended (θ 111°, τ −161°) | 6.7 Å, about 8 residues later | 11.8 | 0.01 / 0.32 / 0.67 |
| c | 1.7% | 19 | no frame: chain ends and breaks | none within 16 Å | 8.4 | 0.00 / 0.00 / 1.00 |
| d | 4.5% | 20 | extended (θ 119°, τ −134°) | 6.0 Å, about 10 earlier | 15.6 | 0.00 / 0.36 / 0.64 |
| e | 3.9% | 27 | helix start (τ(i−1) −136°, τ(i) +54°) | 6.1 Å, about 32 earlier | 16.8 | 0.23 / 0.08 / 0.69 |
| f | 8.1% | 23 | helix (θ 93°, τ +54°) | 6.6 Å, about 37 later, on the side-chain side | 21.1 | 0.90 / 0.01 / 0.09 |
| g | 3.4% | 30 | helix (θ 93°, τ +54°) | 6.7 Å, about 33 earlier, the partner extended | 21.5 | 0.78 / 0.00 / 0.22 |
| h | 4.2% | 23 | extended (θ 119°, τ −111°) | 6.1 Å, about 13 later | 10.2 | 0.00 / 0.33 / 0.67 |
| i | 3.3% | 27 | extended after a helical torsion (τ(i−1) +62°, τ(i) −130°) | 6.4 Å, about 35 later | 18.4 | 0.09 / 0.28 / 0.63 |
| j | 7.8% | 15 | helix (θ 93°, τ +56°) | 5.7 Å, about 4 later, in the same helix | 10.3 | 0.76 / 0.02 / 0.23 |
| k | 6.4% | 26 | strand (θ 121°, τ −148°) | 6.6 Å, about 33 later, on the side-chain side | 22.5 | 0.00 / 0.64 / 0.36 |
| l | 7.5% | 22 | strand (θ 121°, τ −146°) | 6.7 Å, about 36 earlier | 21.8 | 0.01 / 0.50 / 0.49 |
| m | 2.9% | 25 | extended after a helical torsion (τ(i−1) +59°, τ(i) −122°) | 6.3 Å, about 16 earlier | 8.9 | 0.00 / 0.09 / 0.91 |
| n | 4.2% | 27 | helix start (τ(i−1) −134°, τ(i) +57°) | 6.3 Å, about 38 later | 17.0 | 0.22 / 0.08 / 0.70 |
| o | 3.7% | 21 | turn (θ 98°, τ(i−1) −114°, τ(i) +89°) | 6.5 Å, about 3 or 4 earlier | 7.7 | 0.01 / 0.01 / 0.97 |
| p | 5.0% | 24 | helix (θ 93°, τ +53°) | 6.5 Å, about 31 later | 17.2 | 0.77 / 0.00 / 0.23 |
| q | 6.9% | 17 | helix (θ 93°, τ +50°) | 5.7 Å, about 4 earlier, in the same helix | 9.7 | 0.73 / 0.00 / 0.27 |
| r | 5.5% | 29 | strand (θ 123°, τ −161°) | 4.7 Å, about 25 later, antiparallel, the partner extended | 18.9 | 0.00 / 0.79 / 0.21 |
| s | 7.5% | 23 | helix (θ 93°, τ +53°) | 6.5 Å, about 42 earlier | 21.0 | 0.85 / 0.00 / 0.15 |
| t | 3.9% | 24 | helix (θ 94°, τ +59°) | 6.9 Å, about 24 earlier | 12.6 | 0.58 / 0.02 / 0.40 |
How the values were obtained: θ from the mean cos θ of the state, τ as the
direction of the mean (sin τ, cos τ), the separation as 2 to the power
8 × abs(mean) with its sign, the other columns directly; they describe a
typical member of the state, not every member. The states split each kind of
local shape by environment. Among the helical states, f, g and s are
buried (about 21 CA atoms around the centre) with a partner far along the
chain, g on a strand-like residue; j and q are exposed, their nearest
non-local neighbour being three or four residues away in the same helix: the
face of a helix turned to the solvent. Among the strands, a and r pair
with an extended residue 4.7 to 4.8 Å away in an antiparallel chain, as across
a β-sheet, the partner earlier for a and later for r, while k and l
are buried strands packed against a distant element. c collects residues
with no frame or no neighbour.
Scoring GSA alignments #
Two chains written in GSA are compared as protein sequences are, by local alignment with a substitution matrix and gap costs, except that each position is a pair (GSA state, amino acid) and both halves count.
The GSA matrix scores two states by a log-odds ratio: how much more often they sit at equivalent places of related structures than they would meet by chance. Equivalent residues are the pairs closer than 5 Å in the TM-align alignments of training domains of one superfamily; p(a, b) is the frequency of states a and b among them, q(a) the share of state a among the training residues:
S(a, b) = round(8 · log₂( p(a, b) / (q(a) · q(b)) )) in units of 1/8 bit
Pair counts are symmetric with a pseudocount of 0.5 per pair of states, and
the state counts get one more each. A state scores +15 (j) to +30 (g)
against itself; the most different pair, r against s, scores −37. Two
states drawn at random score −8.8 units on average, negative as local
alignment needs. The states that score least with themselves (j, b, q)
are common and say little about a fold; buried or paired states (g, r,
a) say most. The relative entropy of the matrix,
Σ p(a, b) · log₂(p(a, b) / (q(a) · q(b))) = 1.1766 bits per aligned pair, is
the information one aligned pair carries, on average, about relatedness.
Amino acids add BLOSUM62 (Henikoff & Henikoff 1992), which is given in half bits, with weight 0.75. In units of 1/8 bit that is three times the BLOSUM62 entry: W–W 33, C–C 27, A–A 12, L–I 6, A–R −3, X–X −3 (X is the code of any residue other than the twenty).
A pair of positions i of the query and j of the target scores
s(i, j) = S_GSA(state_i, state_j) + 3 · BLOSUM62(aa_i, aa_j)
A buried helix leucine (f, Leu) against a buried helix isoleucine (f, Ile)
scores 23 + 6 = 29 units; against a leucine in state s −3 + 12 = 9; against
a leucine in the strand state a −29 + 12 = −17. The structure term
dominates: the same amino acid in another structural setting scores below
zero.
Gaps cost 48 units to open and 4 per residue: a gap of k residues costs 48 + 4k (6 bits plus 0.5 bit per residue). Affine gap costs (Gotoh 1982) make one long gap cheaper than several short ones, as insertions in proteins come in loops. The best local alignment (Smith & Waterman 1981) is found by the recurrences
H(i, j) = max(0, H(i−1, j−1) + s(i, j), E(i, j), F(i, j))
E(i, j) = max(E(i−1, j) − 4, H(i−1, j) − 52) gap in the target
F(i, j) = max(F(i, j−1) − 4, H(i, j−1) − 52) gap in the query
score = the largest H(i, j)
E-values and bits. The best local alignment scores of unrelated chains follow an extreme-value (Gumbel) distribution, as for sequences (Karlin & Altschul 1990), which gives every score an E-value, the number of alignments at least as good expected by chance in the whole search:
E = K · m · n · e^(−λ·S) λ = 0.0166849, K = 0.00101548 (per unit)
bits = (λ·S − ln K) / ln 2 so that E = m · n · 2^(−bits)
S is the raw score in units, m the query length and n the residues of every
indexed protein chain: the whole index, also when collection keeps one
collection's chains, so E-values do not change with that filter. λ and K are
measured, not derived from the matrix: they were fitted by maximum likelihood
to the best scores of unrelated training pairs (domains of different folds),
because the sum of GSA and amino-acid scores is not the log-odds score of a
single distribution. The score a hit needs, against an index of 123 million
residues (the size of the speed test below):
| Query length | E = 10 | E = 1 | E = 10⁻³ |
|---|---|---|---|
| 129 | 857 units (30.6 bits) | 995 (33.9 bits) | 1,409 (43.9 bits) |
| 300 | 907 (31.8 bits) | 1,045 (35.1 bits) | 1,459 (45.1 bits) |
Hen egg-white lysozyme against α-lactalbumin (1HML) scores 2,398 units (67.7 bits): E = 6.8 × 10⁻¹¹ in such an index. Against T4 lysozyme it scores 203 units (14.8 bits): E = 5.4 × 10⁵, no better than chance. Only the 3D superposition tells that these two are related at all.
Training (GSA-1) #
The recipe is in internal/fold/gsatrain and internal/fold/train.go; its
output is internal/fold/gsa_params.go.
- Data: the SCOP40 benchmark set, 11,206 SCOPe domains at 40% sequence identity, with the CA coordinates of their Protein Data Bank entries (read in the CAL format of the test data of Reseek). The 11,199 domains of at least 20 residues are split by fold, in two halves by a hash of their fold's SCOP identifier: 6,063 domains of the training folds and 5,136 of the test folds, so no test domain shares a fold with any training domain.
- States: k-means (20 centroids) over the standardized, weighted features of the training residues.
- Substitution scores: log-odds of pairs of states in 17,563 TM-align alignments of same-superfamily pairs of training domains, against the background frequencies of the states: 1.1766 bits of relative entropy per aligned pair, in units of 1/8 bit.
- Scoring: an aligned pair of residues scores its GSA log-odds plus 0.75 times its BLOSUM62 score (also in 1/8 bit); gaps cost 6 bits to open and 0.5 bit to extend (48 and 4 units).
- Statistics: the scores of local alignments of 1,792,744 unrelated pairs (different folds) fit a Gumbel distribution with λ = 0.0166849 and K = 0.00101548 (per unit), which gives every alignment an E-value: E = K · m · n · e^(−λ·S) for a query of m residues and a database of n.
- Choices made on the training folds only: the scoring weights and gaps, the feature weights (only the doubled separation helped, by 0.03 in summed sensitivity), and the search's word threshold.
Splitting by fold is what makes the test meaningful. A split by domain would put close relatives of every test domain in the training set, and the benchmark would measure memory rather than the ability to recognize new folds.
The steps in more detail. The features are standardized by their mean and standard deviation over the training residues. k-means runs on a random sample of 300,000 training residues, seeded by k-means++ and iterated (Lloyd steps, up to 100) until no residue changes state, three times; the run of least inertia gives the centroids. The training pairs are up to 150 random pairs of each superfamily, aligned by the TM-align port in its default mode. The tuning stages change one thing at a time and score it by the summed sensitivity (family + superfamily + fold) of 300 training queries, measured by local alignment, or by the whole search for the search settings:
| Stage | Values tried | Chosen |
|---|---|---|
| Features | each group of features (local shape, distance, direction, orientation, separation, the partner's angle, contacts) doubled, halved or dropped | separation doubled |
| Amino-acid weight | 0, 0.25, 0.5, 0.75, 1 | 0.75 |
| Gap costs | opening 3, 4, 5, 6 or 8 bits, extension 0.25, 0.5 or 1 bit | 6 and 0.5 |
| Search settings, among decoys making 30 million residues | word thresholds 50, 55, 60, 65, 70; 1,000, 2,000 or 4,000 chains aligned | 55 and 2,000, which keep 98% of the superfamily sensitivity of threshold 50 in 70% of the time |
The Gumbel parameters are fitted, by maximum likelihood, to the scores of the training queries against the training domains of other folds. The test folds are then measured once. The run behind GSA-1 (version 2.5.0) can be repeated:
go run ./internal/fold/gsatrain -cal scop40.cal.gz -pairs pairs.gob.gz -stage pairs # TM-align the training pairs once
go run ./internal/fold/gsatrain -cal scop40.cal.gz -pairs pairs.gob.gz -queries 300 -decoys 30000000 -out internal/fold/gsa_params.go
(scop40.cal.gz is test_data/scop40.cal.gz of Reseek; the seed is 1 by
default.)
Benchmarks #
The benchmarks use the levels of the SCOP classification (Murzin et al. 1995; Fox et al. 2014). Domains of one family are clearly related, by sequence identity or by very similar structures and functions. Families whose proteins have low sequence identity but whose structures and functions suggest a common origin form a superfamily. Superfamilies with the same major secondary structures in the same arrangement and connections share a fold, whether or not they have a common origin. Finding family members is the easy task, finding members of the same fold in other superfamilies the hardest.
Sensitivity up to the first false positive: for each query domain, the targets are ranked by the method's score; counting from the top until the first domain of another fold, the share of the query's family members found (family), of its superfamily members of other families (superfamily) and of its fold members of other superfamilies (fold), averaged over the queries.
GSA-1 on the 947 queries of the test folds (folds it never saw), against the 5,136 test domains:
| Method | Family | Superfamily | Fold |
|---|---|---|---|
| Local alignment of GSA and amino acids | 0.880 | 0.590 | 0.098 |
| The structure search (shortlist, alignment, TM-score), among decoys making a database of 30 million residues | 0.895 | 0.660 | 0.159 |
| Amino acids alone (BLOSUM62, gaps 11/1), as a sequence search would | 0.554 | 0.165 | 0.003 |
| (Training folds, local alignment of GSA and amino acids) | 0.836 | 0.442 | 0.056 |
How to read a row: a superfamily value of 0.590 means that, on average, a query ranks 59% of its superfamily relatives from other families above the first domain of a different fold. The test queries are 1,000 test domains drawn at random, of which the 947 with relatives among the test domains count. The test folds, which the training never saw, score no lower than the training folds: the alphabet generalizes to new folds. With the same alignment program, adding structure more than triples the superfamily sensitivity of amino acids alone.
The decoys put the search at the size of a real database: synthetic chains whose GSA states come from an order-2 Markov chain fitted to the test domains (so their words have the frequencies of real chains), with amino acids drawn from each state's frequencies and the lengths of real domains. They compete for the shortlist and in the local alignment, and a decoy ranked above a relative counts as a false positive; having no coordinates, they are never rescored by TM-score. The other test domains compete at every stage.
Against TM-align itself: 120 test queries with relatives at every level, against the 5,136 test domains, every method ranking the same targets (TM-align by the TM-score normalized by the query, computed for every one of 616,200 pairs). The second set of columns uses the denominators of Foldseek's benchmark script.
| Method | Family | Superfamily | Fold | Family | Superfamily | Fold |
|---|---|---|---|---|---|---|
| TM-align, every pair (default mode) | 0.897 | 0.763 | 0.317 | 0.897 | 0.680 | 0.305 |
| GSA structure search | 0.908 | 0.705 | 0.186 | 0.908 | 0.626 | 0.179 |
| GSA and amino acids, local alignment | 0.872 | 0.588 | 0.114 | 0.872 | 0.513 | 0.101 |
| GSA alone | 0.822 | 0.536 | 0.100 | 0.822 | 0.463 | 0.085 |
| Amino acids alone | 0.515 | 0.151 | 0.002 | 0.515 | 0.119 | 0.002 |
The search finds 101% of TM-align's family sensitivity, 92% of its superfamily sensitivity and 59% of its fold sensitivity, at a tiny fraction of the cost: the 616,200 TM-align runs took 5 hours 17 minutes on two virtual CPUs (about 2.6 minutes per query against 5,135 targets), while the search answered each test query in about a second (971 ms) against the test domains among decoys, a database of 31 million residues, 33 times larger. For scale, Foldseek reports 86%, 88% and 133% of the sensitivity of Dali, TM-align and CE on its own SCOPe benchmark, at four to five orders of magnitude less time (van Kempen et al. 2024). The numbers come from different benchmarks (data versions, splits, queries and decoys differ) and are not directly comparable; GL1X has not run Foldseek on its benchmark.
What the comparison says in practice: for close and moderately distant relatives the search is as good as aligning every pair with TM-align, while at the fold level it finds well under two thirds of what exhaustive TM-align finds. Relationships at the fold level depend on the overall arrangement of elements more than on local runs of similar letters, which is what a local alignment of strings measures.
Speed #
On the 2-vCPU test machine, a search of 123 million residues (707,000 chains, an index the size of the MolNFT sequence databases built from the SCOP domains among decoys) takes about 3 seconds (median of 20 queries, at most 6), most of it the shortlist, which uses every CPU. Each web process holds the index in 2 bytes per residue and follows the database within seconds.
The search pipeline #
A query chain of 10 to 5,000 residues (a record's, or one in a structure file
you send) against every indexed protein chain (internal/fold/search.go,
structsearch.go). The structure search pipeline narrows the whole index
down in stages, each cheaper per chain than the next: a scan of words keeps a
few thousand chains, local alignment orders them and gives E-values, and the
TM-score and TM-align judge the best of them in 3D.
- Index. Every indexed protein chain is a string of pair codes, 2 bytes per residue, held in memory: each 16-bit code holds the residue's GSA state in its high bits and its amino acid (one of 21 codes, the twenty and X) in its low five bits. The index holds every protein chain of 10 residues or more encoded in the current alphabet (GSA-1), identical chains of a record once.
- Words. The query's words of three GSA states and their neighbourhood (every word scoring at least 55 units against one of the query's, at most 32 query positions per word so a long helix cannot flood the scan) are looked up in a scan of the index, with a bit vector of present words. A word is 15 bits (5 per state), so the vector of present words has 32,768 bits; the scan reads each target residue once, shifts its state into the current word and tests one bit, and only a word that is present looks up its query positions. A word that more than 32 query positions would seed keeps 32 of them, evenly spaced.
- Two hits. A chain is a candidate when two words hit the same diagonal within 40 residues; an ungapped extension with an X-drop of 60 units must reach 60 units. At most 2,000 candidates, best first, are aligned. A diagonal is a fixed offset between target and query positions; the second word must start after the first one ends. The extension adds the pair scores in both directions from the second word and stops where the running score has fallen 60 units below its best; a chain's best extension ranks it. Single word matches occur by chance everywhere, while a real similarity produces several on one diagonal, as in gapped BLAST (Altschul et al. 1997).
- Local alignment. Smith–Waterman alignment of GSA states and amino acids (the scores above, affine gaps) with a query profile; each alignment's E-value follows from its score and the Gumbel parameters. The profile holds, for each query position, its score against every pair code, so the inner loop of the alignment is one table lookup per cell.
- TM-score. The best 200 alignments are rescored by superposing the
target onto the query along the alignment (TM-align's TM-score search,
seeds every 40 residues), which gives the TM-scores by query and by target
length, RMSD, aligned length and identity. When
limitasks for more than 200 hits, that many are rescored. They are rescored whatever their E-value. The TM-score search uses the d0 of the query; the aligned pairs then withinscore_d8give the TM-score by the query (d0 of the query length), by the target (d0 of the target length), and the RMSD and identities over them. - TM-align. The best 10 are realigned by TM-align in its fast mode,
starting from the alignment found, so the best hits carry TM-align's own
alignment. TM-align also tries its own initial alignments (its
-imode), and the realigned answer replaces the rescored one only when its TM-score by the query is at least as high. A pair whose lengths multiply to more than 4 million is not realigned. - Ranking. Hits come by TM-score normalized by the query, then E-value.
A hit beyond the E-value cut-off (
max_evalue, 10) stays when its TM-score shows the query's fold (0.5 or more). Identical chains of a record are one hit; the query's own chain comes first.collectionkeeps one collection's chains,min_tmhits with at least that TM-score. Rescored hits come before the others, which are ordered by E-value;min_tmleaves out the hits that were not rescored.limitis 50 by default, 500 at most. Identical requests on the same state of the index share one answer.
The answer gives each hit's record and chain (with its identical chains), the TM-scores, RMSD, aligned length, identity, the query and target ranges, E-value and bit score, whether it was rescored and refined, and the work done (chains shortlisted, aligned, rescored, refined, and the time of each stage).
Why these values. A neighbourhood threshold of 55 units admits, for the
lysozyme query 1AKI, 4.0 words per query position on average (8.5 at 50, 1.7
at 60): enough to seed relatives whose letters differ, few enough to keep the
scan fast. A word of three strong states such as fff (23 + 23 + 23 = 69
units against itself) has ffp (58) in its neighbourhood but not fpp (47).
A word of three weak states such as jjj (45 against itself) is not even in
its own neighbourhood: 168 of the 8,000 possible words score below 55 against
themselves, so a stretch of exposed helix cannot seed a hit alone. The cap of
32 positions per word keeps a long helix, whose few words repeat at almost
every position, from multiplying the work. Rescoring 200 alignments and
realigning 10 bounds the 3D work of a query whatever the size of the index.
The search's own tests check that rescoring gives TM-scores within 0.03 of
TM-align's for the same alignment.
Example: a search with lysozyme #
The test suite indexes the ten chains of
internal/fold/testdata/chains_ca.pdb.gz (1,813 residues;
internal/fold/search_test.go). A search with hen egg-white
lysozyme (1AKI chain A, 129 residues) in the default settings shortlists all
ten chains (the index is tiny), finds 8 within E ≤ 10, rescores 10 and
realigns 10:
| Hit | Score (units) | Bits | E-value | TM by query | TM by target | RMSD | Aligned | Identical |
|---|---|---|---|---|---|---|---|---|
| 1AKI A (itself) | 5,118 | 133.1 | 1.9 × 10⁻³⁵ | 1.000 | 1.000 | 0.00 Å | 129 | 129 |
| 2NWD X (a lysozyme) | 3,764 | 100.5 | 1.3 × 10⁻²⁵ | 0.978 | 0.971 | 0.65 Å | 129 | 78 |
| 1HML A (α-lactalbumin) | 2,398 | 67.7 | 1.0 × 10⁻¹⁵ | 0.876 | 0.916 | 1.47 Å | 123 | 45 |
| 1QGI A | 429 | 20.3 | 0.185 | 0.527 | 0.317 | 4.03 Å | 112 | 10 |
| 3LZM A (T4 lysozyme) | 203 | 14.8 | 8.0 | 0.442 | 0.369 | 4.36 Å | 90 | 9 |
| 6OA8 A | 199 | 14.7 | 8.6 | 0.331 | 0.220 | 5.23 Å | 80 | 6 |
| 5EEP A | 202 | 14.8 | 8.2 | 0.277 | 0.263 | 5.13 Å | 67 | 3 |
| 1NI7 A | 200 | 14.8 | 8.4 | 0.271 | 0.248 | 5.13 Å | 68 | 2 |
3KCS and 1GL4 were rescored too and left out: their E-values exceed 10 and their TM-scores are below 0.5. The order follows the TM-score by the query, not the alignment score: 5EEP scores 202 but ranks below 6OA8 (199). The last three rows are what chance looks like.
In a real index the E-values are larger, in proportion to its size. In an index of 123 million residues, 67,800 times the size of this one, 1HML would have E = 6.8 × 10⁻¹¹, still far below 1; 1QGI 1.3 × 10⁴, kept only because its TM-score of 0.527 reaches 0.5, and only if it is shortlisted and its alignment is among the 200 best scores; T4 lysozyme 5.4 × 10⁵, with a TM-score of 0.442: not reported.
Reading the hits #
| Field | Meaning |
|---|---|
tm_score.query, tm_score.target | the TM-scores normalized by the query's and by the target's length (absent when the hit was not rescored) |
rmsd, aligned_length | RMSD over the aligned pairs within score_d8, and their number |
identical, identity | identical residues among the aligned pairs, and their share |
query_range, target_range | the first and last aligned positions, counted from 1 among the residues with coordinates (not author numbers) |
score, bits, evalue | the local alignment score of GSA and amino acids, its bit score and E-value |
rescored, refined | whether the hit has TM-scores, and whether TM-align realigned it |
self, identical_chains | whether the hit is the query's own chain, and the record's chains identical to it |
How to interpret a hit:
| What you see | What it means |
|---|---|
| TM by query ≥ 0.5 | the hit most likely has the query's fold over most of the query's length |
| TM by query high, TM by target low | the query matches part of a larger target (a domain of it) |
| TM by query low, TM by target high | the target is a fragment or one domain of the query |
| Small E-value, TM-score below 0.5 | the strings share a similar stretch, but the 3D superposition does not extend it to the fold |
| TM-score ≥ 0.5, large E-value | a similar fold with little local similarity, kept by the 0.5 rule |
rescored false | the alignment was not among the best rescored; only the E-value speaks |
What the search can miss #
- Distant folds. At the fold level the search finds under two thirds of what exhaustive TM-align finds (see Benchmarks). T4 and hen lysozyme are an example.
- Seeding. A relative must share two words on one diagonal within 40 residues and an ungapped stretch scoring 60 units. Strongly diverged structures may share neither.
- Order. Local alignment and TM-align keep the order of both chains: circular permutations and swapped domains are found, if at all, through their longest part in order.
- Crowding. Only the 2,000 best ungapped scores are aligned and only the
200 best alignments (or
limit) are rescored. A query with many close relatives in the index, such as a much-studied protein, fills those places with them; ask for a largerlimitor keep onecollection. - Whole chains. GSA does not split chains into domains. A query of two domains whose hit matches only one of them gets a TM-score by query no higher than that domain's share of the query; read the TM-score by target, or search with a structure file that holds the domain alone.
- Scope. Only protein chains are searched, with queries of 10 to 5,000 residues. The E-value statistics were fitted on single SCOP domains.
Motif search of the structures #
Which structures hold a sequence motif, and where it lies in them
(internal/bio/structmotif.go):
- Patterns: the language of the motif search of sequences (see
Bioinformatics): residues (QEEY),
xfor any residue,[ST]one of,{P}any but,x(3)a repeat,<and>for the first and the last residue; PROSITE dashes are ignored. A pattern is read as amino acids, and also as bases when it is written in bases only (A C G T U N); it needs two positions that are not any residue. - What is scanned: every chain of every indexed structure, identical chains of a record once, over its residues with coordinates in file order: protein chains through the amino acids of the pair codes the structure index holds (no second copy in memory), DNA and RNA chains, short peptides and chains with residues other than the twenty (selenocysteine U, pyrrolysine O, B, Z, J) through their own residues. Occurrences overlap as in the sequence scan; each is counted.
- Never across a break: an occurrence that spans a chain break (residues
missing between two residues that follow each other in the file) is not
one; so every occurrence is a stretch of chain that exists in 3D. Until the
breaks of a chain stored before 2.8.1 are computed, the page's rows are
checked against its trace and the answer says how many chains wait
(
database.breaks_pending). - Speed: an exact scan on every CPU; 120 million residues (400,000 chains of 300) in 0.1 to 0.3 s on two vCPUs. An answer serves the pages that follow it for a minute while the index changes; identical requests share it.
- The answer: the pattern as read, chains, records and occurrences in all, the counts by collection, what the occurrences of a pattern with choices hold; then a page of chains, shortest first, each with its record, chain and identical chains, kind (protein, dna, rna), length, how often the motif occurs, up to 20 occurrences with their positions among the chain's residues with coordinates and their author residue numbers (with insertion codes), the residues around the first, the structure file for the viewer, and a link that opens the record with the motif marked.
Why a motif search of structures, when the sequences can be searched? A sequence record lists the residues that were in the sample; the structure holds only those that were seen. A motif found in the sequence may lie in a disordered loop with no coordinates, or straddle a gap. The structure scan answers a different question: where is this pattern in a 3D model I can look at? Short motifs score far below any BLAST cut-off, so the scan reads every residue instead of seeding and scoring.
A residue matches a position only when it certainly does: B (D or N) matches
[DN] but not D, X matches only x, and an N in a nucleic acid matches only
a position that allows any base. A pattern has at most 100 positions and 400
characters. The residues around an occurrence are the 12 on each side of the
first one. For a pattern with choices, the answer counts what the occurrences
hold and lists the 20 most frequent strings (none when the occurrences hold
more than 4,096 different ones).
The Find by motif tab of the structure page shows the hits with the motif in context, pages, filters by collection, and opens any hit in Mol* with the motif's residues as ball-and-stick, selected, the camera on the first occurrence. Examples to start from: the Rossmann fold's G-x-G-x(2)-G, N-glycosylation N-{P}-[ST]-{P}, RGD, the C2H2 zinc finger C-x(2)-C-x(12)-H-x(3)-H, the ER retention signal KDEL> and the UUCG tetraloop.
On the MolNFT card, a find bar over the sequences takes a fragment or a
motif (spaces, dashes and the numbers of a pasted block of sequence are
ignored), marks every occurrence, brings one at a time into view (Enter,
Shift+Enter or the arrows), and shows it in the 3D structure: the residues
with coordinates of the chains Mol* loaded are searched the same way, never
across a break, and the occurrences in the chain of the sequence are shown
as ball-and-stick, the camera on the one in view. The address keeps the find
(?find=QEEY&chain=A), so a link opens the record with it; motif hits of the
molecular search and of the structure search link records that way.
Filters on the structure analysis #
The API can keep only the occurrences whose residues have given properties of the structure analysis. With any of these filters, chains not analysed yet are left out. Occurrences in analysed chains also carry their DSSP letters, the relative accessibility of their residues and the sites they touch.
| Parameter | Keeps an occurrence when |
|---|---|
ss | every residue has the secondary structure asked for: helix (DSSP H, G, I), strand (E, B), loop (−, T, S, P and residues without a full backbone), or DSSP letters (ss=GH) |
rsa_min, rsa_max | the relative accessibility (%, 0 to 254) is within the bounds: of the residue at rsa_position (1-based in the motif), or else the mean of the occurrence's residues of known accessibility |
site | some residue lines a pocket, lies at an interface or touches a ligand (comma-separated, each one required) |
paired | every nucleotide is base-paired (paired) or none is (unpaired) |
Example: motif=C-x(2)-C&ss=helix keeps the CxxC motifs that lie wholly in
helices; motif=N-{P}-[ST]-{P}&rsa_min=30&rsa_position=1 keeps the
N-glycosylation sequons whose asparagine is exposed.
Example: a chain with missing residues #
The motif search's test reads 1AKI three times, once complete, once without residues 50 to 55, and once with Cys6 renamed to selenocysteine. In the chain without residues 50 to 55 the residues with coordinates read …NRNTDG LQINS… with a break between Gly49 and Leu56:
| Pattern | Complete chain | Chain without 50–55 | Chain with selenocysteine 6 |
|---|---|---|---|
STDYGI (residues 50 to 55) | found | not found: no coordinates | found |
TDGLQ (47 to 49, then 56 and 57) | not in the sequence | not found: it spans the break | not in the sequence |
LQINS | found at residue 56 | found, first residue numbered 56 | found |
KVFGRC | found, residues 1 to 6 | found | not found: residue 6 reads U |
<KVFGRx | found | found | found: x stands for U |
The occurrence of LQINS in the gapped chain starts at position 50 among its
residues with coordinates; the answer gives that position and the author
number 56, which is what the viewer needs.
Comparisons made in advance #
After a record's structure is read, the comparison queue compares its chains
with what the index already holds (molecular_comparisons):
- The same entry in the other collection. A MolNFT v1 and a MolNFT v2
record of one PDB entry: each chain against the same chain of the other
record, with TM-scores and RMSD, and whether the coordinates agree residue
by residue without any superposition (
identical_coordinates, the largest deviation by residue number). It tells whether two NFTs of one entry hold the same structure. - Experimental against predicted. An experimental chain against the predicted models (AlphaFold DB and other computed models) of its UniProt accession, or a predicted model against the experimental chains of its accession: TM-scores, RMSD, how much of each chain aligns, and the mean confidence (pLDDT) of the aligned residues. It tells how well a prediction matches experiment, for every accession present in both.
Each pair is aligned the cheapest way that gives TM-align's answer, and the
comparison records which (detail.mode):
- identical: two chains of one entry with the same residues (numbers, insertion codes, one-letter codes) at the same coordinates within the precision of the files (0.0015 Å) are aligned residue by residue under the identity superposition: TM-score 1 and RMSD 0, the answer TM-align itself gives (checked on the PDB and BinaryCIF files of 1AKI), without running it. This is the usual case for one entry minted in both collections.
- fast: TM-align's fast mode runs first; a pair it superposes well (TM-score of at least 0.8, as an experiment and a prediction of one protein mostly are) keeps that answer. On 60 pairs of one family the fast mode differs from the default by 0.0045 in TM-score on average.
- default: any other pair is aligned again in TM-align's default mode, and the better of the two answers is kept.
A pair is computed once: each comparison records the readings of the two
structures it was computed from (a_read, b_read, 3.4.0), and when both
records wait in the queue, the second one finds the pair already computed
from the current readings. A record read again keeps its comparisons:
comparing it aligns again the pairs computed from an earlier reading of
either structure, whichever record of the pair found them (up to 5,000 a
run; the old answer is shown until then), and drops a pair whose chain is
gone or that no longer pairs; a comparison of chains loaded before their
structure was read again is not kept, and a record whose partner was read
again during its comparison stays in the queue. When its
chains pair otherwise — their observed accessions changed (3.4.0), a chain
came or went or changed kind, or the structure turned from experiment to
model or back — its experimental–predicted comparisons go and are made
anew, and the other record of each pair that went is compared again too (a
pair is made by whichever of its records finds the other). The MolNFT
card lists a record's comparisons in its Structure index panel, each with a
link that runs the alignment; the admin's Bio tab counts them, by mode, with
the pace of both queues.
The tolerance of 0.0015 Å is one and a half times the 0.001 Å to which PDB and mmCIF files write coordinates. The identical case is checked by a test: the PDB and BinaryCIF files of 1AKI give TM-align's own scores within 10⁻⁵, while moving one atom by 0.01 Å, changing a residue, renumbering one, adding an insertion code or removing a residue makes the chains different. In the fast and default cases, "the better" means the larger sum of the two TM-scores.
Reading a comparison #
| Field | Meaning |
|---|---|
kind | same_entry or experimental_predicted |
a, b | the two chains: for same_entry one row per pair, its two records in a fixed order; for experimental_predicted the experimental chain as a and the model as b |
tm_score.by_a, tm_score.by_b | the TM-scores normalized by chain a and by chain b |
rmsd, aligned_length, identity | as in an alignment |
detail.coverage_a, detail.coverage_b | the aligned length over the length of each chain |
detail.mean_b_aligned_a, detail.mean_b_aligned_b | the mean B-factor of the aligned residues of each chain: pLDDT on the model's side |
detail.range_a, detail.range_b | the author numbers of the first and last aligned residue |
detail.matched_by_number, detail.max_deviation_by_number, detail.identical_coordinates | residues with the same author number in both chains, the largest distance between them without superposition, and whether every residue matches within 0.0015 Å |
detail.mode | identical, fast or default |
For an experiment and a prediction, read the TM-score normalized by the experimental chain with the coverage: a model often covers the whole protein while the experiment saw only part, so the model's own normalization is lower. A high mean pLDDT over the aligned residues together with a high TM-score says that the confident part of the model agrees with experiment. A low TM-score with a high pLDDT is the case worth a closer look: a confident prediction of a different conformation, or an experimental structure in another state (bound to a partner, for example).
Which pairs are compared #
For the same entry, a record is compared with up to 20 other read records of the same PDB ID, chain by chain where the chain identifier and kind are the same. For experiment and prediction, each protein chain with UniProt accessions is compared with the chains of records of the other kind (by the predicted flag) that share an accession, identical chains once. A record makes at most 100 comparisons (partners beyond are left to them), and chains whose lengths multiply to more than 9 million are not compared.
API and MCP #
curl -s https://YOUR-DOMAIN/api/bio/structure # engines, GSA, limits, the index, records read
curl -s https://YOUR-DOMAIN/api/bio/structure/align -H 'Content-Type: application/json' -d '{
"a": {"contract": "0xde3723766bc32dcacd03c17baa400a7b36837eba", "token_id": "1"},
"b": {"contract": "0xd58b01f6c18086e5202cdc5d7ad3e41790360102", "token_id": "1", "chain": "A"}, "mode": "default"}'
curl -s https://YOUR-DOMAIN/api/bio/structure/search -H 'Content-Type: application/json' -d '{
"query": {"contract": "0xd58b01f6c18086e5202cdc5d7ad3e41790360102", "token_id": "6", "chain": "A"}, "limit": 25, "min_tm": 0.5}'
curl -s 'https://YOUR-DOMAIN/api/bio/structure/motif?motif=N-%7BP%7D-%5BST%5D-%7BP%7D&limit=20' # structures with a motif
curl -s https://YOUR-DOMAIN/api/bio/records/0xd58b01f6c18086e5202cdc5d7ad3e41790360102/6/structure # chains, GSA, comparisons
GET /api/bio/structure/motif takes motif, collection (a contract
address), limit (default 50, at most 500) and offset; errors say why
(invalid_motif, motif_too_general, missing_motif, invalid_limit,
invalid_offset, structure_index_loading). A record's structure lists, for
each chain, its author numbering in runs ("numbering": "1-49,56-129,130A":
one item per residue or run of consecutive numbers) and its breaks.
The motif route also takes the analysis filters ss, rsa_min, rsa_max,
rsa_position, site and paired (above),
with the errors invalid_ss, invalid_rsa, invalid_site and
invalid_paired; offset goes up to 1,000,000. Every occurrence gives
start and end (positions from 1 among the chain's residues with
coordinates), residues, and first, last and numbers (author numbers).
The answer's database says how many chains and residues were scanned and
how many chains wait for their breaks; cached says whether a kept answer
served the page.
A record's structure (GET /api/bio/records/{contract}/{tokenId}/structure)
gives how the file was read (status, format, source, entry_id,
title, method, predicted, models, file_bytes, file_sha256) and,
for each chain, its kind, length, sequence, gsa, mean_b,
accessions, same_as, first and last residue, numbering and breaks, and
whether it can be a search query (searchable: a protein chain of 10
residues or more that is not a copy); then its comparisons.
…/structure/comparisons returns the comparisons alone.
A side of an alignment, or a search query, may be a structure file instead of
a record: {"structure": "<PDB or mmCIF text>", "format": "", "chain": "A", "name": "my model"} (up to GL1X_STRUCTURE_MAX_UPLOAD_MB, 20 MB). A chain
left out is the first protein chain. The page addresses run a request when
opened: /bio/structure?tab=search&q={contract}:{token}:{chain}&run=1,
/bio/structure?a=…&b=…&run=1.
More precisely, a chain left out is the first protein chain of 10 residues or
more, or else the first chain; "chain": "_" names a chain without an
identifier. Each client address may send 6 alignments or searches in a burst
and then one every 2 seconds, and 20 motif searches in a burst and then one a
second (structure_rate_limited); a server whose slots and queue are full
answers structure_busy.
MCP: structure_align (two records' chains; details adds every aligned
pair), structure_search (a record's chain; limit, collection, min_tm),
structure_motif (the structures that hold a motif, with residue numbers;
collection, limit, offset), structure_comparisons (a record's chains,
GSA and comparisons), and bio_dataset with source: structure_search to turn
the hits into a dataset.
The MCP tools take records only, not structure files. structure_align
takes a_contract, a_token_id, a_chain, b_contract, b_token_id,
b_chain and mode (default or fast); without details the answer leaves
out the pairs, residue numbers, confidence values and the Mol* matrix.
structure_search returns 10 hits by default (at most 100), and
structure_motif 20 chains (at most 100); the motif tool has no analysis
filters.
| Setting | Default | What it does |
|---|---|---|
GL1X_STRUCTURE_WORKERS | autotune: one per CPU, 4–16 (4 below 4 GB) | structure files read at once (0: none, at most 32); comparisons run a quarter of the CPUs at once (1–8) |
GL1X_STRUCTURE_SEARCH | on | the search index in the web processes (off: no search; alignment still works) |
GL1X_STRUCTURE_CONCURRENCY | one per 8 CPUs, at least 2, at most 16 | alignments and searches at once (4 × as many wait up to 20 s) |
GL1X_STRUCTURE_TIMEOUT | 120s | one alignment or search |
GL1X_STRUCTURE_MAX_UPLOAD_MB | 20 | a structure file sent with a request (1 to 200) |
GL1X_STRUCTURE_TEMPLATES | on | keep every protein chain's CA and side-chain points in memory (six bytes a residue) for the 3D templates of the structure analysis |
GL1X_HEADER_RATE | 120 | experimental structures read before 3.4.0 read again a minute, about, for their biological assemblies and observed accessions (off or 0: not read again; up to 6000) |
References #
- Altschul SF, Madden TL, Schäffer AA, et al. (1997) Gapped BLAST and PSI-BLAST: a new generation of protein database search programs. Nucleic Acids Res 25:3389–3402.
- de Brevern AG, Etchebest C, Hazout S (2000) Bayesian probabilistic approach for predicting backbone structures in terms of protein blocks. Proteins 41:271–287.
- Dong R, Pan S, Peng Z, Zhang Y, Yang J (2018) mTM-align: a server for fast protein structure database search and multiple protein structure alignment. Nucleic Acids Res 46:W380–W386.
- Fox NK, Brenner SE, Chandonia J-M (2014) SCOPe: Structural Classification of Proteins—extended, integrating SCOP and ASTRAL data and classification of new structures. Nucleic Acids Res 42:D304–D309.
- Gotoh O (1982) An improved algorithm for matching biological sequences. J Mol Biol 162:705–708.
- Henikoff S, Henikoff JG (1992) Amino acid substitution matrices from protein blocks. Proc Natl Acad Sci USA 89:10915–10919.
- Jumper J, Evans R, Pritzel A, et al. (2021) Highly accurate protein structure prediction with AlphaFold. Nature 596:583–589.
- Kabsch W (1976) A solution for the best rotation to relate two sets of vectors. Acta Crystallogr A 32:922–923.
- Karlin S, Altschul SF (1990) Methods for assessing the statistical significance of molecular sequence features by using general scoring schemes. Proc Natl Acad Sci USA 87:2264–2268.
- Murzin AG, Brenner SE, Hubbard T, Chothia C (1995) SCOP: a structural classification of proteins database for the investigation of sequences and structures. J Mol Biol 247:536–540.
- Needleman SB, Wunsch CD (1970) A general method applicable to the search for similarities in the amino acid sequence of two proteins. J Mol Biol 48:443–453.
- Sehnal D, Bittrich S, Velankar S, et al. (2020) BinaryCIF and CIFTools — lightweight, efficient and extensible macromolecular data management. PLoS Comput Biol 16:e1008247.
- Smith TF, Waterman MS (1981) Identification of common molecular subsequences. J Mol Biol 147:195–197.
- van Kempen M, Kim SS, Tumescheit C, et al. (2024) Fast and accurate protein structure search with Foldseek. Nat Biotechnol 42:243–246.
- Xu J, Zhang Y (2010) How significant is a protein structure similarity with TM-score = 0.5? Bioinformatics 26:889–895.
- Yang J-M, Tung C-H (2006) Protein structure database search and evolutionary classification. Nucleic Acids Res 34:3646–3659.
- Zhang Y, Skolnick J (2004) Scoring function for automated assessment of protein structure template quality. Proteins 57:702–710.
- Zhang Y, Skolnick J (2005) TM-align: a protein structure alignment algorithm based on the TM-score. Nucleic Acids Res 33:2302–2309.
- Edgar RC. Reseek, protein structure alignment and search (github.com/rcedgar/reseek): source of the SCOP40 CA coordinates (test data) used to train and test GSA.