This repository was archived by the owner on Mar 10, 2026. It is now read-only.
Conversation
… unused builder code
…direct access to atoms and chains
…m_by_serial and get_chain_by_id methods
…arSystem instances
…nd improved error handling
…om line formatting
…for atom and connectivity lines
14 tasks
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR implements a modular I/O framework with BGF file support in scream-core and refactors the core data models for better organization and extensibility.
- Introduce
MolecularFiletrait andBgfFilereader/writer with customBgfErrorand metadata. - Refactor
Atom, usebitflagsforAtomFlags, decoupleMolecularSystemBuilderinto its own module, and improve error types usingthiserror. - Update
MolecularSystemAPI by removing internal maps and adding mutable accessors.
Reviewed Changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/core/models/topology.rs |
Added thiserror derive to ParseBondOrderError. |
src/core/models/system.rs |
Removed lookup maps, use iterators for get_atom_by_serial and get_chain_by_id, added *_mut methods. |
src/core/models/builder.rs |
New module for MolecularSystemBuilder, updated add_atom signature. |
src/core/io/traits.rs |
New MolecularFile trait for unified file I/O. |
src/core/io/bgf.rs |
Implemented BGF parsing/writing, error handling, and tests. |
Cargo.toml |
Added bitflags and thiserror dependencies. |
Comments suppressed due to low confidence (1)
crates/scream-core/src/core/io/bgf.rs:138
- Footer lines are emitted before bond connectivity (
CONECT) records, which may not match the expected BGF file structure; consider moving this block to after the connectivity loop.
for line in &metadata.footer_lines {
…or efficient lookups
…ystemBuilder and update build method to include them
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:
Implemented a modular I/O framework within
scream-coreto handle the reading and writing of molecular file formats, with BGF (.bgf) being the first supported format. This work introduces a genericMolecularFiletrait for future expansion. A significant refactoring of the core data models was performed, including a redesignedAtomstruct that usesbitflagsfor state and a more organizedMolecularSystemBuilder. Error handling has also been improved by introducing custom error types withthiserror.Changes:
Implemented Modular I/O Framework:
core::iomodule to house file format handlers.MolecularFiletrait with methods for reading from and writing to readers/writers and file paths, ensuring a consistent API for all supported formats.Added BGF File Support:
BgfFileas the first concrete implementation of theMolecularFiletrait.ATOM,HETATM, andCONECTrecords from a BGF file, correctly identifying chain types (Protein, Water, Ligand) and building aMolecularSystemvia the builder.MolecularSystemback into a valid BGF file format, including atom records and connectivity information.Core Data Model Refactoring:
AtomStruct:Elementenum has been removed.Atomstruct now contains more descriptive topological fields (res_name,res_id,chain_id) and SCREAM-specific parameters (flags,delta,vdw_radius, etc.).AtomFlags:AtomFlagsstruct using thebitflagscrate to efficiently manage boolean atom properties likeIS_FIXED_ROLEandIS_VISIBLE_INTERACTION.MolecularSystemBuilder:core::models::builder) for better code organization.AtomandMolecularSystemstructures.Dependency and Error Handling Improvements:
bitflagsandthiserroras new dependencies toscream-core.BgfErrorenum usingthiserrorfor clearer and more ergonomic error handling during file parsing.ParseChainTypeError) to usethiserror.