-
Notifications
You must be signed in to change notification settings - Fork 0
Implement Modular I/O Framework and BGF File Support #5
Description
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
MolecularFiletrait with generic associated types forMetadataandError. - Specify required methods
read_fromandwrite_toto handle core logic withBufReadandWritetraits. - Implement convenience methods
read_from_pathandwrite_to_pathfor direct file handling. - Define
write_system_tofor format conversion, which writes aMolecularSystemusing default metadata.
- Define a
-
Implement BGF File Format Support (
io/bgf.rs):- Create a
BgfFilestruct to serve as the implementation target for theMolecularFiletrait. - Define a
BgfMetadatastruct to store BGF-specific header information likeBIOGRFversion andFORCEFIELD. - Implement a custom
BgfErrorenum usingthiserrorfor clear and specific parsing errors. - Implement
MolecularFile::read_fromforBgfFile, parsingATOMandCONECTrecords and populating aMolecularSystemvia the builder. - Implement
MolecularFile::write_toforBgfFile, correctly formatting the output to match the BGF specification.
- Create a
-
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
BgfErrorvariants.