DreidTyper
DreidTyper is a Rust library that turns a minimal MolecularGraph (atoms + bonds) into a fully typed, DREIDING-compatible topology. The pipeline is deterministic, aggressively validated, and designed for integrators who need trustworthy chemistry without shipping their own perception code.
At a high level the library walks through:
- Perception: six ordered passes (rings → Kekulé expansion → electron bookkeeping → aromaticity → resonance → hybridization) that upgrade raw connectivity into a rich
AnnotatedMolecule. - Typing: an iterative, priority-sorted rule engine that resolves the final DREIDING atom label for every atom.
- Building: a pure graph traversal that emits canonical bonds, angles, torsions, and inversions as a
MolecularTopology.
Features
- Chemically faithful perception: built-in algorithms cover SSSR ring search, strict Kekulé expansion, charge/lone pair templates for heteroatoms, aromaticity categorization (including anti-aromatic detection), resonance propagation, and hybridization inference.
- Deterministic typing engine: TOML rules are sorted by priority and evaluated until a fixed point, making neighbor-dependent rules (e.g.,
H_HB) converge without guesswork. - Engine-agnostic topology: outputs canonicalized bonds, angles, torsions, and inversions ready for any simulator that consumes DREIDING-style terms.
- Extensible ruleset: ship with curated defaults (
resources/default.rules.toml) and load or merge custom rule files at runtime. - Rust-first ergonomics: zero
unsafe, comprehensive unit/integration tests, and precise error variants for validation, perception, and typing failures.
Getting Started
Add the crate to your Cargo.toml:
[]
= "0.5.0"
Run the full pipeline from connectivity to topology:
use ;
let mut graph = new;
let c1 = graph.add_atom;
let c2 = graph.add_atom;
let o = graph.add_atom;
let h_o = graph.add_atom;
let h_atoms: = .map.collect;
graph.add_bond.unwrap;
graph.add_bond.unwrap;
graph.add_bond.unwrap;
for in .into_iter
let topology: MolecularTopology = assign_topology.expect;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Need custom chemistry? Parse a TOML file and extend the default rules:
use ;
// Start with the default DREIDING rules
let mut all_rules = get_default_rules.to_vec;
// Parse and append custom rules from a TOML file
let extra_toml = read_to_string?;
all_rules.extend;
// Run the pipeline with extended rules
let topology = assign_topology_with_rules?;
Documentation
- API Documentation - Comprehensive reference for all public types and functions.
- Architecture Documents - In-depth design and implementation details.
Tech Stack
- Core Language: Rust
- Build System: Cargo
- Rule Format: TOML
License
This project is licensed under the MIT License - see the LICENSE file for details.