Conversation
2 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes bond index corruption when converting a dreid-forge::System to a bio-forge::Topology if System::atoms are not contiguous by residue/chain (since bio-forge re-flattens atoms in chain→residue order).
Changes:
- Track original atom indices while grouping atoms into residues/chains during
to_bio_topology. - Build an
old_to_newmapping based on the final traversal order and remapBondatom indices accordingly. - Add a regression test covering interleaved (non-contiguous) atoms across chains/residues.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary:
Resolved an issue in the
to_bio_topologyconversion function whereBondindices became corrupted if the inputSystem::atomsarray was not strictly ordered by residue. Becausebio-forgeregroups atoms into a hierarchical chain-residue structure, the flat atom indices change during conversion. This fix introduces an index remapping mechanism that translates the original atom indices to the new flat indices expected by thebio-forgetopology, ensuring correct bond connectivity regardless of the initial atom ordering (e.g., when structures are constructed programmatically by tools likedreid-pack).Changes:
Implemented Bond Index Remapping:
to_bio_topologyinsrc/io/util.rsto track the original indices of atoms as they are grouped into residues via aresidue_membersmap.old_to_newmapping vector that sequentially assigns new flat indices based on the final chain and residue traversal order.bf::Bondconstruction loop to use the remapped indices (old_to_new[bond.i]andold_to_new[bond.j]) instead of the raw input indices.Added Regression Testing:
to_bio_topology_remaps_bonds_for_non_contiguous_atomsunit test.Systemwith interleaved atoms from different chains/residues correctly translates its bonds into the expectedbio-forgeflat indices without losing connectivity.