Skip to content
This repository was archived by the owner on Mar 10, 2026. It is now read-only.
This repository was archived by the owner on Mar 10, 2026. It is now read-only.

Implement Modular I/O Framework and BGF File Support #5

@TKanX

Description

@TKanX

Description:

Establish a flexible and extensible I/O framework within the crates/scream-core/src/core/io/ module. This framework will be responsible for parsing various molecular file formats into the core MolecularSystem model and writing the model back to files. The design must cleanly separate the file I/O logic from the "pure" domain models, allowing for independent development and easy addition of new file formats. The initial implementation will focus on defining a universal MolecularFile trait and providing a concrete implementation for the BGF (Biograf) format, as it directly supports essential data like force field types. This module will serve as the primary bridge between on-disk data and the in-memory representation, enabling the system to interact with external tools and data sources.

Tasks:

  • Design and Implement I/O Trait (io/traits.rs):

    • Define a MolecularFile trait with generic associated types for Metadata and Error.
    • Specify required methods read_from and write_to to handle core logic with BufRead and Write traits.
    • Implement convenience methods read_from_path and write_to_path for direct file handling.
    • Define write_system_to for format conversion, which writes a MolecularSystem using default metadata.
  • Implement BGF File Format Support (io/bgf.rs):

    • Create a BgfFile struct to serve as the implementation target for the MolecularFile trait.
    • Define a BgfMetadata struct to store BGF-specific header information like BIOGRF version and FORCEFIELD.
    • Implement a custom BgfError enum using thiserror for clear and specific parsing errors.
    • Implement MolecularFile::read_from for BgfFile, parsing ATOM and CONECT records and populating a MolecularSystem via the builder.
    • Implement MolecularFile::write_to for BgfFile, correctly formatting the output to match the BGF specification.
  • Write Unit Tests:

    • Write unit tests for parsing individual lines/records of a BGF file.
    • Add tests to verify that parsing failures produce the correct BgfError variants.

Metadata

Metadata

Assignees

Labels

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions