Conversation
…formal charge parameter
…r atom charge inference
…hate/phosphine oxide groups
… anions involving single-bonded oxygen
…ition for clarity
…dition for clarity
…removing formal charge checks
…reation for clarity
…ddition for clarity
28 tasks
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR implements automatic charge and lone pair perception in the chemical perception engine, simplifying the public API by removing the formal_charge parameter from MolecularGraph::add_atom. The new perception logic uses VSEPR theory and functional group templates to accurately model common chemical structures including zwitterionic amino acids and oxyacid anions.
- Removed
formal_chargeparameter fromMolecularGraph::add_atomAPI - Implemented advanced chemical perception algorithm for automatic charge/lone pair inference
- Updated all test cases and documentation to use the simplified API
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/harness.rs | Removed charge field from AtomBlueprint and updated test atom creation calls |
| tests/cases/nucleic_acids.rs | Updated all nucleic acid test cases to use new API without charge parameters |
| tests/cases/dreiding_paper.rs | Updated Dreiding paper test cases, including expected atom type changes for dimethyl sulfoxide |
| tests/cases/amino_acids.rs | Updated all amino acid zwitterion test cases to use new API |
| src/processor/typer.rs | Updated all test method calls to remove charge parameters |
| src/processor/templates.rs | Updated template predicates to use lone pairs instead of formal charge for pattern matching |
| src/processor/pipeline.rs | Updated test cases to use new atom creation API |
| src/processor/perception.rs | Added comprehensive charge and lone pair perception logic with helper functions |
| src/processor/graph.rs | Removed formal_charge field initialization in ProcessingGraph constructor |
| src/lib.rs | Updated documentation examples to use new API |
| src/core/graph.rs | Removed formal_charge field from AtomNode and updated add_atom method signature |
| src/builder/mod.rs | Updated test code to remove formal_charge field reference |
| docs/01_pipeline.md | Updated documentation to reflect removal of formal_charge field |
| README.md | Updated example code to use new simplified API |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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:
Significantly refactors the chemical perception engine to automatically infer formal charges and lone pair counts directly from the molecular graph. This enhancement simplifies the public API by removing the
formal_chargeparameter fromMolecularGraph::add_atom, making the library more user-friendly and robust. The new perception logic uses a combination of VSEPR theory and an expert system of functional group templates to accurately model common chemical structures, including zwitterionic amino acids, oxyacid anions (e.g., carboxylates, phosphates), and hypervalent species.Changes:
Simplified Public API:
formal_chargeargument fromMolecularGraph::add_atom. Users are no longer required to specify formal charges, as they are now automatically perceived.README.md, doc comments) to reflect the new, simpler API.Implemented Advanced Chemical Perception Logic:
perceive_charge_and_lone_pairs) that runs during the initial processing stage.processor::templates) to correctly handle resonance-stabilized charged groups like carboxylates, phosphates, and nitro groups, ensuring accurate charge and hybridization assignment.Updated Integration Test Suite:
chargeparameter from test case definitions (AtomBlueprint).