_build_gemmi_residue (src/sampleworks/eval/synthetic_utils.py:360) reads per-residue fields (res_id, res_name, seqid, subchain, het_flag, etc.) from start_idx alone, assuming every atom in the span is part of the same residue.
The spans come from _residue_group_bounds, which only breaks on (chain_id, res_id) changes. So malformed input could slip through undetected:
- atoms in one span with differing res_name (or chain_id/hetero) — grouping wouldn't catch a res_name change alone
- duplicate atoms within a residue (same (atom_name, altloc))
For defensive programming, _build_gemmi_residue (or _residue_group_bounds) should:
Should you check that they're all the same? It seems like good defensive programming to make sure you don't make a residue out of atoms that aren't already part of the same residue.
and same name, and no atoms are repeated, etc... all of which should have tests too.
Originally posted by @marcuscollins in #322
_build_gemmi_residue(src/sampleworks/eval/synthetic_utils.py:360) reads per-residue fields (res_id, res_name, seqid, subchain, het_flag, etc.) fromstart_idxalone, assuming every atom in the span is part of the same residue.The spans come from
_residue_group_bounds, which only breaks on (chain_id, res_id) changes. So malformed input could slip through undetected:For defensive programming,
_build_gemmi_residue(or_residue_group_bounds) should:Originally posted by @marcuscollins in #322