Skip to content

Validate residue-span homogeneity when converting atomarray to gemmi #340

Description

@DorisMai

_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:

  • Assert all atoms in a span share res_id, res_name, chain_id, hetero
  • Assert (atom_name, altloc) is unique within the span
  • Tests should be added too

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions