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

feat(core): Implement Core Molecular Data Models#4

Merged
TKanX merged 24 commits intomainfrom
feature/3-implement-core-domain-models-for-molecular-representation
Jun 28, 2025
Merged

feat(core): Implement Core Molecular Data Models#4
TKanX merged 24 commits intomainfrom
feature/3-implement-core-domain-models-for-molecular-representation

Conversation

@TKanX
Copy link
Member

@TKanX TKanX commented Jun 28, 2025

Summary:

Introduces a comprehensive suite of data models to represent molecular structures within the scream-core crate. It establishes a foundational, hierarchical data layer consisting of MolecularSystem, Chain, Residue, and Atom entities, along with topological information like Bond. A fluent MolecularSystemBuilder is also provided for a safe and intuitive way to construct these complex systems.

Changes:

  • Implemented Hierarchical Data Models:

    • Atom: Created a struct to represent an individual atom, including its Element type, 3D coordinates (using nalgebra::Point3), partial charge, and name.
    • Element: Implemented an exhaustive enum for chemical elements with a robust FromStr parser to handle various symbols and aliases (e.g., "Cl", "D", "2H").
    • Residue: Defined a struct to represent a group of connected atoms, such as an amino acid or a nucleotide.
    • Chain: Implemented a struct to represent a sequence of residues, categorized by ChainType (e.g., Protein, DNA, RNA).
    • MolecularSystem: Introduced the top-level container that aggregates all atoms, chains, and bonds into a single, cohesive system.
  • Defined Molecular Topology:

    • Created a Bond struct to define chemical connectivity between two atoms.
    • Implemented a BondOrder enum (Single, Double, etc.) with a FromStr parser for easy interpretation from various formats.
  • Introduced a Fluent Builder API:

    • Developed MolecularSystemBuilder to provide a step-by-step, fluent interface for constructing a MolecularSystem.
    • The builder enforces a valid construction hierarchy (e.g., an atom must be added to a residue within a chain), preventing invalid states.
  • Added Comprehensive Unit Tests:

    • Each new data model and its associated logic (e.g., parsers, builder) is accompanied by a thorough suite of unit tests.
    • Tests cover data integrity, parsing logic, and builder panic conditions for robust validation.
  • Integrated nalgebra Dependency:

    • Added the nalgebra crate as a core dependency to efficiently handle 3D coordinates and related linear algebra operations.

TKanX and others added 21 commits June 26, 2025 08:14
@TKanX TKanX requested a review from Copilot June 28, 2025 02:22
@TKanX TKanX self-assigned this Jun 28, 2025
@TKanX TKanX added the enhancement ✨ New feature or request label Jun 28, 2025
@TKanX TKanX linked an issue Jun 28, 2025 that may be closed by this pull request
23 tasks
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a comprehensive suite of molecular data models for the scream-core crate, including Atom, Residue, Chain, Bond, and a fluent MolecularSystemBuilder API, along with comprehensive unit tests. Key changes include:

  • The introduction of hierarchical models and their supporting parsers and display implementations.
  • The addition of a fluent builder API to safely construct molecular systems.
  • Integration of the nalgebra dependency to handle 3D coordinates.

Reviewed Changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/scream-core/src/models/topology.rs Implements Bond and BondOrder models with parsing and display traits.
crates/scream-core/src/models/system.rs Introduces the MolecularSystem and builder API for constructing systems.
crates/scream-core/src/models/residue.rs Defines the Residue structure along with atom mapping logic.
crates/scream-core/src/models/chain.rs Implements Chain and ChainType models with parsing and display support.
crates/scream-core/src/models/atom.rs Defines the Atom model and Element enum with robust parsing logic.
crates/scream-core/Cargo.toml Adds the nalgebra dependency to support 3D coordinate operations.
Comments suppressed due to low confidence (1)

crates/scream-core/src/models/system.rs:136

  • Consider adding a check to ensure that an atom serial number is unique before inserting it into atom_serial_map. This would help prevent accidental overwrites if duplicate serials are added.
        self.system.atom_serial_map.insert(serial, atom_idx);

@TKanX TKanX merged commit 189de4b into main Jun 28, 2025
1 check passed
@TKanX TKanX deleted the feature/3-implement-core-domain-models-for-molecular-representation branch June 28, 2025 05:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement ✨ New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Core Domain Models for Molecular Representation

2 participants