Skip to content

fix(io): match residues that share a number under insertion codes - #107

Closed
daylight-00 wants to merge 1 commit into
RosettaCommons:release/atomworks-3-0from
daylight-00:fix/add-missing-atoms-ins-code
Closed

daylight-00 wants to merge 1 commit into
RosettaCommons:release/atomworks-3-0from
daylight-00:fix/add-missing-atoms-ins-code

Conversation

@daylight-00

@daylight-00 daylight-00 commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

📋 PR Checklist

  • This PR is tagged as a draft if it is still under development and not ready for review.
  • I have ensured that all my commits follow angular commit message conventions.
  • I have run make format on the codebase before submitting the PR (this autoformats the code and lints it).
  • I have named the PR in angular PR message format as well (c.f. above), with a sensible tag line that summarizes all the changes in the PR.

ℹ️ PR Description

What changes were made and why?

  • add_missing_atoms_for_chain() looked a chain's residues up by res_id alone. A PDB chain can repeat a number under insertion codes (1PPB chain L runs 1H, 1G, ... 1A, 1), and both the atom array and chain_info["res_id"] list those residues in file order, so the lookup collided: parse("1PPB.pdb") with the default add_missing_atoms raised AssertionError: Mismatch: residue ID 1 in chain L has name CYS instead of THR.
  • Residues are keyed by (res_id, n), with n counting earlier residues that share the number. Unique numbers, as in mmCIF (label_seq_id), key as (res_id, 0) and are looked up as before.
  • Atoms inserted into a partial residue already copy ins_code from that residue, so nothing else needed to change.

How were the changes tested?

  • New tests/io/test_insertion_codes.py: a PDB chain numbered 1H, 1G, 1F, 1, 2 parses with the defaults, keeps its five residues in order and gains the missing atoms without coordinates. It fails on release/atomworks-3-0 with the assertion above.
  • parse("1PPB.pdb"): raises on release/atomworks-3-0 @ e0f2e4d; with the change, chains L and H keep all 295 polymer residues (same (res_id, ins_code, res_name) sequence as the file) and all 2380 resolved atoms.
  • Parsing 12 real inputs (.cif of 1UBQ, 1CBN, 2HHB, 6LZB, 4HBT, 3NEZ, 1KX5, 5T4J, 6QHP and .pdb of 1UBQ, 2HHB, 4HBT) gives identical arrays, bonds and chain_info before and after.
  • tests/io (not slow, no internet): no status change over 816 tests, plus the new test passing. The failures on both sides need the PDB/CCD mirrors, which were not available here.
  • ruff 0.8.3 format and check clean.

Additional Notes

- add_missing_atoms_for_chain() looked residues up by res_id alone, so a PDB chain that repeats a number under insertion codes (1PPB chain L: 1H, 1G, ..., 1) collided and the default parse raised "Mismatch: residue ID 1 in chain L has name CYS instead of THR"
- Key residues by (res_id, n), n counting earlier residues with the same number; unique numbers (mmCIF label_seq_id) key as (res_id, 0), as before
- Test a PDB chain numbered 1H, 1G, 1F, 1, 2 against the default parse
Copilot AI balanced review requested due to automatic review settings October 3, 2026 04:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@nscorley
nscorley deleted the branch RosettaCommons:release/atomworks-3-0 October 5, 2026 03:42
@nscorley nscorley closed this Oct 5, 2026
@roccomoretti

Copy link
Copy Markdown
Member

(Per the notes on issue #102, this has been addressed by/incorporated in PR #116)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants