This repository was archived by the owner on Mar 10, 2026. It is now read-only.
Conversation
…dating residue_id type
…atom storage to AtomId
…nagement and performance
…g creation, atom and residue removal
…safety in MolecularSystem
…ystem usage in BgfFile read_from method
18 tasks
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the core data models to use slotmap for stable, generational IDs and integrates the previous builder functionality directly into MolecularSystem, while updating the BGF parser/writer and improving I/O performance.
- Replace
Vec/usizeindexing with typedAtomId,ResidueId, andChainIdviaslotmap - Remove
MolecularSystemBuilder, move entity-addition methods intoMolecularSystem - Update BGF parser/writer to work with the new mutable API and use
BufWriter
Reviewed Changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/scream-core/src/core/models/ids.rs | Introduce AtomId, ResidueId, ChainId via slotmap |
| crates/scream-core/src/core/models/topology.rs | Update Bond to use AtomId, add contains method |
| crates/scream-core/src/core/models/residue.rs | Change Residue to track AtomIds, update mapping |
| crates/scream-core/src/core/models/chain.rs | Change Chain to track ResidueIds, remove old maps |
| crates/scream-core/src/core/models/system.rs | Migrate MolecularSystem to slotmap storage, add mutators |
| crates/scream-core/src/core/models/mod.rs | Remove builder module, add ids |
| crates/scream-core/src/core/io/traits.rs | Switch to BufWriter for write performance |
| crates/scream-core/src/core/io/bgf.rs | Fully refactor BGF parser/writer for new model API |
| crates/scream-core/Cargo.toml | Add slotmap dependency |
Comments suppressed due to low confidence (2)
crates/scream-core/src/core/models/residue.rs:9
- The comment says "Indices of atoms" but this field now holds
AtomIds, not raw indices. Please update the comment to "IDs of atoms belonging to this residue".
pub(crate) atoms: Vec<AtomId>, // Indices of atoms belonging to this residue
crates/scream-core/src/core/models/chain.rs:73
- After refactoring to
ResidueId, existing tests for parsing and display of otherChainTypevariants have been removed. Consider adding back tests for DNA, RNA, Ligand, and Other variants to maintain coverage of all parsing/display branches.
mod tests {
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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:
Executes a major refactoring of the core data models within
scream-core, replacing the previousVec-based storage andusizeindexing withslotmap. This provides stable, generational IDs (AtomId,ResidueId,ChainId), which guarantees that references remain valid even after additions or deletions of other entities. This change fundamentally enables safe mutability, introducing methods to add and remove entities directly from theMolecularSystem. Consequently, the separateMolecularSystemBuilderhas been removed, and its functionality is now integrated intoMolecularSystemitself, leading to a more robust, performant, and ergonomic API.Changes:
Stable ID Generation with
slotmap:slotmapcrate to manageAtom,Residue, andChaincollections, replacing the fragileVec/usizeindex system.AtomId,ResidueId, andChainIdin a newids.rsmodule.Data Structure and API Refactoring:
MolecularSystemto useSlotMapfor primary data storage, flattening the hierarchy for direct access to all entities.add_atom_to_residue,add_bond,remove_atom, andremove_residue.MolecularSystemBuilderand integrated its construction logic directly intoMolecularSystem's public methods (add_chain,add_residue, etc.).Atom,Residue,Chain, andBondmodels to use the new stable IDs, simplifying their structure.Performance Enhancements:
bond_adjacencySecondaryMaptoMolecularSystemfor efficient, cached lookups of an atom's bonded neighbors.BufWriter, improving write performance.BGF Parser/Writer Update:
BgfFileparser and writer (core::io::bgf) to work with the newslotmap-based data models and mutable API.CONECTrecords.