neurosnap.algos.ipsae module#
- neurosnap.algos.ipsae.calculate_ipSAE(protein, plddt, pae_matrix, *, model=None, pae_cutoff=10.0, dist_cutoff=10.0, pDockQ_cutoff=8.0, return_pml=False)[source]#
Compute ipSAE/ipTM and related interface scores for all chain pairs.
Uses a Neurosnap
Proteinto derive an ordered residue list (one representative atom per residue) and evaluates multiple interface confidence metrics between every ordered pair of chains: ipSAE (three d0 variants), inter-chain ipTM (d0chn), pDockQ, pDockQ2, and LIS. Symmetric summaries include both per-direction asymmetry and pairwise maxima and minima.- Alignment contract:
The function derives the residue order from the structure (biopolymer residues only) and expects
plddt(N,) andpae_matrix(N, N) to match that order exactly. If they originate from AlphaFold/Boltz, map them to this residue list first.
- Parameters:
protein (
Protein) – NeurosnapProteincontaining the structure. Only standard amino acids and nucleotides with a valid representative atom are used.plddt (
ndarray) – Per-residue pLDDT aligned to the derived residue order (normalized to [0-100] NOT [0-1]).pae_matrix (
ndarray) – Residue–residue PAE (Å) aligned to the same order.model (
Optional[int]) – Structure model ID to analyze. Defaults to the first model.pae_cutoff (
float) – PAE threshold (Å) for ipSAE and counting “valid” pairs.dist_cutoff (
float) – Distance cutoff (Å) for interface-restricted counts.pDockQ_cutoff (
float) – Distance cutoff (Å) used by pDockQ/pDockQ2 neighbor tests.return_pml (
bool) – If True, returns a PyMOL coloring alias script underpml.
- Returns:
by_residue: Per-direction arrays (length N) for each chain pair: -
iptm_d0chn: ipTM using d0 based on total residues in the pair. -ipsae_d0chn: ipSAE with PAE cutoff, same d0 as above. -ipsae_d0dom: ipSAE with PAE cutoff, d0 from count of residuesthat have inter-chain PAE < cutoff (domain-level).
ipsae_d0res: ipSAE with PAE cutoff, d0 per row from the number of valid partners in the other chain (residue-level).n0res_byres/d0res_byres: Companion per-row counts and d0.
asym: Best single-residue values per direction (A→B, B→A) and the residue identifier strings that achieve them: -
iptm_d0chn,ipsae_d0chn,ipsae_d0dom,ipsae_d0res-*_resentries contain the winning residue labels.max: Symmetric maxima for each metric across directions plus the residue label responsible for the maximum: -
iptm_d0chn,ipsae_d0chn,ipsae_d0dom,ipsae_d0res-*_rescontain the max-residue labels.min: Symmetric minima for each metric across directions plus the residue label responsible for the minimum: -
iptm_d0chn,ipsae_d0chn,ipsae_d0dom,ipsae_d0res-*_rescontain the min-residue labels.counts: Supporting counts and d0 companions: -
n0chn,d0chn: Total residues and d0 for each chain pair. -n0dom,d0domand their*_max/*_mincounterparts. -n0res,d0resand their*_max/*_mincounterparts. - Pair/unique-residue tallies with and without distance constraints.scores: Interface-level auxiliary scores: -
pDockQ,pDockQ2,LIS.params: The parameters actually used (cutoffs, model).
pml: Optional PyMOL alias script string (if
return_pmlis True).residue_order: The derived residue metadata: -
names(3-letter codes),chains(chain IDs),numbers(seq IDs).
- Return type:
A dictionary with the following top-level keys
- Raises:
ValueError – If the derived residue list is empty, or if
plddt/pae_matrixshapes do not match the derived residue count/order.
Notes
Representative atom per residue: * Proteins: Cβ (GLY→Cα; fallback to Cα if Cβ missing). * Nucleic acids: prefer C3′/C3*, then C1′/C1*, then P.
Non-standard residues encountered in the structure are removed from the supplied pLDDT/PAE arrays automatically when present so the alignment matches the retained biopolymer subset.
Chain-type classification (protein vs nucleic acid) sets a minimum d0 (2.0 for any pair containing NA; 1.0 otherwise) and influences d0 via the standard length-based formula.
pDockQ neighbors use
pDockQ_cutoffon the representative-atom distances.LIS averages
(12 - PAE) / 12for PAE ≤ 12 Å over inter-chain pairs only.
- neurosnap.algos.ipsae.extract_interchain_metrics(res)[source]#
Extracts major inter-chain confidence metrics from a calculate_ipSAE() result.
This helper flattens the most relevant directional interface metrics into a clean, consistent structure suitable for export or downstream analysis. It includes the primary ipSAE/ipTM scores and auxiliary interface predictors like pDockQ, pDockQ2, and LIS.
- Parameters:
res (dict) – Output dictionary from calculate_ipSAE(). Must contain “asym” and “scores” keys as returned by the main ipSAE computation.
- Returns:
- Nested dictionary of the form:
- {
“iptm_d0chn”: {chain1: {chain2: float}}, “ipsae_d0chn”: {chain1: {chain2: float}}, “ipsae_d0dom”: {chain1: {chain2: float}}, “ipsae_d0res”: {chain1: {chain2: float}}, “pDockQ”: {chain1: {chain2: float}}, “pDockQ2”: {chain1: {chain2: float}}, “LIS”: {chain1: {chain2: float}},
}
Each key corresponds to a metric describing the confidence or stability of the interaction between two chains (e.g., “A”→”B” and “B”→”A”).
- Return type: