Repository navigation
fix(io): match residues that share a number under insertion codes - #107
Closed
daylight-00 wants to merge 1 commit into
Closed
daylight-00 wants to merge 1 commit into
daylight-00 wants to merge 1 commit into
Conversation
- 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
This was referenced Oct 5, 2026
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📋 PR Checklist
make formaton the codebase before submitting the PR (this autoformats the code and lints it).ℹ️ PR Description
What changes were made and why?
add_missing_atoms_for_chain()looked a chain's residues up byres_idalone. A PDB chain can repeat a number under insertion codes (1PPB chain L runs1H, 1G, ... 1A, 1), and both the atom array andchain_info["res_id"]list those residues in file order, so the lookup collided:parse("1PPB.pdb")with the defaultadd_missing_atomsraisedAssertionError: Mismatch: residue ID 1 in chain L has name CYS instead of THR.(res_id, n), withncounting 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.ins_codefrom that residue, so nothing else needed to change.How were the changes tested?
tests/io/test_insertion_codes.py: a PDB chain numbered1H, 1G, 1F, 1, 2parses with the defaults, keeps its five residues in order and gains the missing atoms without coordinates. It fails onrelease/atomworks-3-0with the assertion above.parse("1PPB.pdb"): raises onrelease/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..cifof 1UBQ, 1CBN, 2HHB, 6LZB, 4HBT, 3NEZ, 1KX5, 5T4J, 6QHP and.pdbof 1UBQ, 2HHB, 4HBT) gives identical arrays, bonds andchain_infobefore 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.ruff0.8.3 format and check clean.Additional Notes
production, wherekeep_last_residue()drops the atoms first. That function is gone on this branch, so what remains is the lookup fixed here.chain_infoas is; if carryingins_codethrough it is preferred, I can rework it that way.