neurosnap.algos.lddt module#
Code for LDDT (Local Distance Difference Test) calculation.
- neurosnap.algos.lddt.calc_lddt(reference, prediction, *, chains_ref=None, chains_pred=None, R=15.0, sep_thresh=-1, T_set=(0.5, 1.0, 2.0, 4.0))[source]#
Compute lDDT from distance maps or single-model Neurosnap structures.
For structure inputs, lDDT is computed over aligned analysis sites rather than only canonical amino-acid residues. Protein and nucleotide residues, including modified residues recognized from residue chemistry/backbone content, contribute one representative site per residue. Proteins use
CBwhen available and fall back to backbone atoms; nucleotides use a deterministic sugar/phosphate proxy atom. Non-polymer residues such as ligands contribute one site per heavy atom, while waters and hydrogens are ignored.- Parameters:
reference (
Union[ndarray,Structure]) – Distance map or single-model structure used as the ground truth.prediction (
Union[ndarray,Structure]) – Distance map or single-model structure to compare against the reference.chains_ref (
Optional[List[str]]) – Chain identifiers to include when reference is a structure.chains_pred (
Optional[List[str]]) – Chain identifiers to include when prediction is a structure.R (
float) – Maximum reference distance to consider when defining the L set.sep_thresh (
int) – Minimum sequence separation between residue pairs.T_set (
Sequence[float]) – Error thresholds used to compute preserved distance fractions.
- Return type:
- Returns:
lDDT score between the reference and prediction. Typical range is [0.0, 1.0], where 1.0 indicates perfect local distance agreement and 0.0 indicates no preserved distances under the selected thresholds. Returns NaN when no residue pairs satisfy the L-set criteria (for example, no pairs within R and above sep_thresh).
- Raises:
ValueError – If distance maps do not share the same shape.
TypeError – If the inputs are not both arrays or both structure containers.