torchref.refinement.targets.combined module
Combined targets for refinement (e.g., geometry + ADP).
Integrate multiple component targets into a single combined target using nn.ModuleDict for clean organization and easy access.
Integrate into lossState via add_to_state
- class torchref.refinement.targets.combined.CombinedTargets(verbose=0)[source]
Bases:
TargetBase class for combined targets.
Uses nn.ModuleDict to store component targets for clean organization and easy access via dictionary-style notation.
Subclasses should override _create_targets() to define their component targets.
- Parameters:
verbose (int, optional) – Verbosity level. Default is 0.
- _targets
Dictionary of component targets.
- Type:
nn.ModuleDict
- __init__(verbose=0)[source]
Initialize CombinedTargets.
- Parameters:
verbose (int, optional) – Verbosity level. Default is 0.
- class torchref.refinement.targets.combined.CombinedModelTargets(model=None, verbose=0)[source]
Bases:
ModelTargetBase class for combined targets that only need Model (geometry/ADP targets).
Uses nn.ModuleDict to store component targets for clean organization and easy access via dictionary-style notation.
Subclasses should override _create_targets() to define their component targets.
- Parameters:
- _targets
Dictionary of component targets.
- Type:
nn.ModuleDict
- class torchref.refinement.targets.combined.TotalGeometryTarget(model=None, verbose=0)[source]
Bases:
CombinedModelTargetsComputes weighted sum of all geometry restraint NLLs.
Uses nn.ModuleDict to store component targets: - ‘bond’: BondTarget - ‘angle’: AngleTarget - ‘torsion’: TorsionTarget - ‘planarity’: PlanarityTarget - ‘chiral’: ChiralTarget - ‘nonbonded’: NonBondedHTarget (includes riding hydrogen VDW)
The torsion weight is reduced because:
Protein torsions naturally deviate from ideal (Ramachandran plot)
Side chain rotamers have discrete populations, not single ideals
High torsion weight can over-constrain the structure
The nonbonded weight is very low because:
PROLSQ repulsion is already steep (E ~ violation^4)
Most contacts should be satisfied by covalent geometry
High VDW weight can prevent proper packing
Set weight to 0 to disable a component.
- Parameters:
Examples
geom_target = TotalGeometryTarget(model) loss = geom_target() bond_loss = geom_target['bond']() for name, target in geom_target.items(): print(f"{name}: {target()}")
- class torchref.refinement.targets.combined.TotalADPTarget(model=None, verbose=0)[source]
Bases:
CombinedModelTargetsTotal ADP restraint target combining global, similarity, and local components.
Uses nn.ModuleDict to store component targets: - ‘simu’: ADPSimilarityTarget (SIMU-like bond similarity) - ‘locality’: ADPLocalityTarget (spatial smoothness) - ‘KL’: ADPEntropyTarget (KL divergence regularization)
B-factors follow a LOG-NORMAL distribution (B > 0, right-skewed). If B ~ LogNormal(μ, σ), then log(B) ~ Normal(μ, σ).
This target combines:
Similarity restraint (SIMU-like): Bond-based B-factor similarity - Enforces bonded atoms have similar B-factors - Based on covalent bond topology (strongest local constraint)
Locality restraint: Spatial smoothness - nearby atoms should have similar B - Uses K-NN with distance-based sigma (d² scaling) - Medium-range spatial correlation
KL divergence: Controls the spread of B-factor distribution - Prevents overfitting by controlling distribution width
Log-normal distribution properties:
If log(B) ~ N(μ, σ), then:
Mean of B: exp(μ + σ²/2)
Mode of B: exp(μ - σ²)
For typical proteins: σ_logB ≈ 0.3-0.5 (in log space)
- Parameters:
Examples
adp_target = TotalADPTarget(model) loss = adp_target() simu_loss = adp_target['simu']() for name, target in adp_target.items(): print(f"{name}: {target()}")
- print_statistics()[source]
Print comprehensive ADP restraint statistics.
Displays statistics from all registered ADP targets.