Conversation
Closed
lohedges
added a commit
that referenced
this pull request
Mar 3, 2026
lohedges
added a commit
that referenced
this pull request
Mar 3, 2026
Backport fix from PR #401 [ci skip]
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.
The AMBER prmtop writer incorrectly applied a / 3 scaling to the per-molecule atom offset when computing global CMAP atom indices. This scaling is correct for bonds, angles and dihedrals (which store indices as 3 × atom_index per the AMBER coordinate-array convention), but CMAP terms use plain 1-based atom numbers and require no such scaling. For the first molecule in the system the offset is zero so the error was silent, which is why the existing single-chain test never caught it. For any subsequent molecule the offset was divided by three, producing atom numbers that landed in the wrong molecule. When the writer then re-parsed its own output to validate it, the consistency check raised "there is a cmap between more than one different molecule". A secondary off-by-one in the reader's indexCMAPs function (1-based atom numbers were used directly to index a 0-based array) was corrected at the same time. The bug was exposed by a GLYCAM glycoprotein topology with three large protein/glycan chains, each carrying backbone CMAP terms. A regression test (test_amber_multichain_cmap) has been added that loads this multi-chain topology, writes it back to prmtop format, and verifies that each chain's CMAP term count is preserved across the roundtrip.
This PR closes #400. (Debugged with help from Claude code.)
develinto this branch before issuing this pull request (e.g. by runninggit pull origin devel): [y]