Repository navigation
Take the ProtOr element from the CCD, not from the atom name - #938
Merged
padix-key merged 3 commits intoSep 16, 2026
Merged
Conversation
`_calculate_protor_radii()` derived an atom's element from the first character of its atom name. That is wrong for two-letter elements and for hydrogen atoms whose name does not start with `H`: - `SE` in `MSE`/`SEC` was read as sulfur, so `vdw_radius_protor()` returned the sulfur ProtOr radius (1.77) for selenium. - Metals named `CU1`, `NI`, `CA1`, ... were read as C/N and received a carbon or nitrogen radius. - A mercury atom named `HG` was counted as a bonded hydrogen of its neighbour, inflating that atom's hydrogen number. - Hydrogen atoms named `1HZ`, `2HE2`, ... were treated as heavy atoms and were not counted as bonded hydrogens. The element is now taken from the `chem_comp_atom` category of the Chemical Component Dictionary, i.e. the same source the bonds already come from.
padix-key
requested changes
Sep 10, 2026
padix-key
left a comment
Member
There was a problem hiding this comment.
Thanks for fixing this oversight 👍. I left a few comments below, otherwise this PR looks good to me!
| if atom_names is None or elements is None: | ||
| return {} | ||
| return { | ||
| str(atom_name): str(element).upper() |
Member
There was a problem hiding this comment.
I think this is the more idiomatic (and likely faster) way to convert a numpy scalar into a native Python value.
Suggested change
| str(atom_name): str(element).upper() | |
| atom_name.item(): element.item().upper() |
Merging this PR will not alter performance
Comparing Footnotes
|
Cache the per-residue calculation, index the element maps directly so a missing atom raises, and convert the numpy scalars with item(). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011M5uTyCU4WcNTsPvGrErDo
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011M5uTyCU4WcNTsPvGrErDo
padix-key
approved these changes
Sep 16, 2026
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.
_calculate_protor_radii()takes an atom's element from the first character of its atom name. Wrong when the element has two letters, or a hydrogen's name does not start withH.On
main@af1c4bb:Across the CCD, 262 atoms in 175 components change: 187 had their own element misread (139 Se, 23 H, rest Cu/Ni/Ca/Cd/Co/Cr/Na/Cl read as C or N); 75 are heavy atoms with a wrong hydrogen count, because a neighbour named
HG/HFcounted as hydrogen or one named1HZ/D1did not.sasa(vdw_radii="ProtOr"), the default, calls this, using its 1.8 fallback whereNoneis now returned.The element now comes from
chem_comp_atom.type_symbol, the same CCD entry the bonds come from.vdw_radius_single()already uses the annotated element; only this path re-derived it.test_protor_radiicannot see it: it runs 1GYA filtered to standard amino acids — all one-letter elements — and only asserts the radius is notNone.tests/structurecollects 4197: 4184 passed / 13 skipped; reverting onlyradii.pyfails exactly the 4 new cases. A naive "two-letter prefix if it is an element" fix instead breaks the existingtest_protor_radii, asCAreads as calcium.Drafted with Claude Opus 5 (
claude-opus-5); every measurement was run.