Pull Request №707 RosettaCommons/rosetta/main ← lyskov-ai/rosetta/fix/off-by-one-1-indexed-loops-batch
Merge: 91e8dceb14197d722d77bbb2030a7a0240653d86←9f26b0468d3e771e44a89a18f0aeee8e42457326
Fix off-by-one loops over 1-indexed residue/atom/element ranges
----------------
Merge commit message:
Fix off-by-one loops over 1-indexed residue/atom/element ranges
Replace `i < container.size()` with `i <= container.size()` (or the
matching `i < pose.size()` -> `i <= pose.size()`) across 35 loops where
the body uses `i` as a direct 1-indexed element accessor
(`pose.residue(i)`, `vec[i]`, etc.) — so the last residue/atom/element
was silently being skipped.
Also fixes two related copy-paste bugs in pose_sewing that surfaced
during the audit: the distance check `pose.residue(upstream_res).xyz(2)
.distance(pose.residue(upstream_res).xyz(2))` was self-distance (always
zero, condition always satisfied) — should compare upstream vs
downstream residue xyz. Affects helix_pair detection in
BlockwiseAnalysisMover and OmnibusDisulfideAnalysisLabelerMover.
Skipped candidates: loops with pair access `[i+1]` (correct stop at
size-1), cutpoint-style "between residues" loops, MEM-chain-skipping
loops in protocols/membrane, separator-style "all-but-last + last raw"
patterns, suite/connection enumerations (N-1 connections for N
segments), and commented-out code.