torchref.refinement.targets.geometry.chiral module

class torchref.refinement.targets.geometry.chiral.ChiralTarget(model=None, verbose=0)[source]

Bases: GeometryTarget

Chiral volume restraint target.

Restrains the signed volume of tetrahedral chiral centers to maintain correct stereochemistry (R vs S configuration, L vs D amino acids).

The chiral volume is computed as:

V = v1 · (v2 × v3)

where vi = position of neighbor i - position of center.

For standard protein Cα atoms with ordering (N, C, CB): - L-amino acids: positive volume (~+2.5 ų) - D-amino acids: negative volume (~-2.5 ų)

The loss function penalizes deviations from the ideal signed volume:

NLL = 0.5 * ((V - V_ideal) / σ)² + log(σ) + 0.5 * log(2π)

For achiral centers (volume_sign=’both’), we restrain the absolute volume.

name: str = 'geometry/chiral'
__init__(model=None, verbose=0)[source]

Initialize model target.

Parameters:
  • model (Model, optional) – Reference to the Model object (optional for empty init).

  • verbose (int, optional) – Verbosity level. Default is 0.

forward()[source]

Compute and return the loss. Override in subclasses.

get_violations(threshold=0.5)[source]

Get information about chiral volume violations.

Parameters:

threshold (float, optional) – Report deviations larger than this (ų). Default is 0.5.

Returns:

Dictionary with ‘indices’, ‘volumes’, ‘ideal_volumes’, ‘deviations’.

Return type:

dict

stats()[source]

Get chiral volume statistics.