Skip to content

feat(processor): Implement Chemical Feature Perception and Rule Engine#4

Merged
TKanX merged 44 commits intomainfrom
feature/3-implement-rule-system-and-topology-pre-analyzer
Oct 5, 2025
Merged

feat(processor): Implement Chemical Feature Perception and Rule Engine#4
TKanX merged 44 commits intomainfrom
feature/3-implement-rule-system-and-topology-pre-analyzer

Conversation

@TKanX
Copy link
Copy Markdown
Member

@TKanX TKanX commented Oct 5, 2025

Summary:

Introduces a complete, self-contained library for DREIDING atom typing. It features a sophisticated, multi-stage chemical feature perception pipeline that annotates a basic molecular graph with advanced properties like hybridization, ring membership, and aromaticity. This annotated graph is then processed by a declarative, priority-based rule engine that assigns DREIDING atom types based on a flexible TOML ruleset. This provides a robust and extensible foundation for molecular topology analysis.

Changes:

  • Implemented Chemical Feature Perception Pipeline:

    • Developed a multi-stage "annotator" (processor::annotate) that enriches a molecular graph with chemical intelligence.
    • Ring Perception: Implemented an algorithm to identify all cycles within the molecular graph.
    • Aromaticity Detection: Developed a rule-based system (Hückel's rule) to perceive aromatic systems in 5- to 7-membered rings.
    • Hybridization Inference: Created a comprehensive logic to infer the hybridization state (SP, SP2, SP3, Resonant) of each atom based on its bonding patterns and aromaticity.
    • Introduced an internal ProcessingGraph data structure to store these rich annotations for the rule engine.
  • Created a Declarative Rule-Based Typing Engine:

    • Implemented a rule engine (rules module) that parses and applies typing rules from a TOML file.
    • Defined a Rule structure with priority and conditions to allow for a flexible and ordered application of typing logic.
    • Conditions can match on a wide range of perceived features, including element, degree, hybridization, is_aromatic, and neighbor properties.
    • Included a comprehensive default DREIDING ruleset (dreiding.rules.toml) covering common organic and inorganic atoms.
  • Established Core Data Models:

    • Defined foundational data structures in the core module, including MolecularGraph for input, and enums for Element, BondOrder, and Hybridization.
    • Implemented a robust, hierarchical error handling system (TyperError, AnnotationError, etc.) to provide clear diagnostics for invalid inputs or rule failures.
  • Added Project Infrastructure:

    • Integrated a new GitHub Actions CI workflow to ensure code quality through automated builds and tests.
    • Updated the .gitignore file to exclude RustRover IDE-specific directories.

…ent handling in infer_single_hybridization function
@TKanX TKanX self-assigned this Oct 5, 2025
Copilot AI review requested due to automatic review settings October 5, 2025 02:43
@TKanX TKanX added the enhancement ✨ New feature or request label Oct 5, 2025
@TKanX TKanX linked an issue Oct 5, 2025 that may be closed by this pull request
27 tasks
Copy link
Copy Markdown
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 chemical feature perception pipeline and rule-based DREIDING atom typing engine. The implementation provides a sophisticated multi-stage molecular analysis system that enriches basic molecular graphs with chemical intelligence including hybridization, ring membership, and aromaticity detection, followed by declarative rule-based atom type assignment.

  • Chemical Feature Perception Pipeline: Multi-stage annotator that detects rings, aromaticity, and infers hybridization states
  • Rule-Based Typing Engine: Declarative priority-based system for applying DREIDING atom typing rules from TOML configuration
  • Comprehensive Data Models: Core structures for molecular graphs, processing graphs, and hierarchical error handling

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/lib.rs Exposes new processor and rules modules
src/core/mod.rs Adds None and Unknown variants to Hybridization enum with Display/FromStr support
src/core/error.rs Extends error hierarchy with AnnotationError and enhanced TyperError
src/core/graph.rs Adds comprehensive test coverage for MolecularGraph functionality
src/processor/mod.rs Module declaration for chemical feature perception components
src/processor/graph.rs ProcessingGraph data structure for enriched molecular representations
src/processor/rings.rs Johnson cycle finder algorithm for ring perception
src/processor/aromaticity.rs Hückel rule-based aromaticity detection for 5-7 membered rings
src/processor/hybridization.rs Comprehensive hybridization inference based on bonding patterns
src/processor/annotate.rs Main orchestration of the chemical feature perception pipeline
src/rules/mod.rs Rule parsing engine with TOML deserialization and validation
src/rules/default.rs Embeds default DREIDING ruleset from external TOML file
resources/dreiding.rules.toml Complete DREIDING atom typing ruleset with priority-based rules
Cargo.toml Adds once_cell dependency for lazy static initialization

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/processor/rings.rs Outdated
Comment thread src/processor/rings.rs
Comment thread Cargo.toml Outdated
@TKanX TKanX merged commit f55995e into main Oct 5, 2025
2 checks passed
@TKanX TKanX deleted the feature/3-implement-rule-system-and-topology-pre-analyzer branch October 5, 2025 03:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement ✨ New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Rule System and Topology Pre-analyzer

2 participants