Skip to content

Commit 573c9a5

Browse files
committed
docs(readme): Add README.md with project description and features
1 parent e9d3305 commit 573c9a5

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# DreidTyper
2+
3+
**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.
4+
5+
At a high level the library walks through:
6+
7+
1. **Perception:** six ordered passes (rings → Kekulé expansion → electron bookkeeping → aromaticity → resonance → hybridization) that upgrade raw connectivity into a rich `AnnotatedMolecule`.
8+
2. **Typing:** an iterative, priority-sorted rule engine that resolves the final DREIDING atom label for every atom.
9+
3. **Building:** a pure graph traversal that emits canonical bonds, angles, and torsions as a `MolecularTopology`.
10+
11+
## Features
12+
13+
- **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.
14+
- **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.
15+
- **Engine-agnostic topology:** outputs canonicalized bonds, angles, proper and improper dihedrals ready for any simulator that consumes DREIDING-style terms.
16+
- **Extensible ruleset:** ship with curated defaults (`resources/default.rules.toml`) and load or merge custom rule files at runtime.
17+
- **Rust-first ergonomics:** zero `unsafe`, comprehensive unit/integration tests, and precise error variants for validation, perception, and typing failures.
18+
19+
## Getting Started
20+
21+
Add the crate to your `Cargo.toml`:
22+
23+
```toml
24+
[dependencies]
25+
dreid-typer = "0.3.0"
26+
```
27+
28+
Run the full pipeline from connectivity to topology:
29+
30+
```rust
31+
use dreid_typer::{assign_topology, Element, GraphBondOrder, MolecularGraph, MolecularTopology};
32+
33+
let mut graph = MolecularGraph::new();
34+
let c1 = graph.add_atom(Element::C);
35+
let c2 = graph.add_atom(Element::C);
36+
let o = graph.add_atom(Element::O);
37+
let h_o = graph.add_atom(Element::H);
38+
let h_atoms: Vec<_> = (0..5).map(|_| graph.add_atom(Element::H)).collect();
39+
40+
graph.add_bond(c1, c2, GraphBondOrder::Single).unwrap();
41+
graph.add_bond(c2, o, GraphBondOrder::Single).unwrap();
42+
graph.add_bond(o, h_o, GraphBondOrder::Single).unwrap();
43+
for (carbon, chunk) in [(c1, &h_atoms[0..3]), (c2, &h_atoms[3..5])].into_iter() {
44+
for &hydrogen in chunk {
45+
graph.add_bond(carbon, hydrogen, GraphBondOrder::Single).unwrap();
46+
}
47+
}
48+
49+
let topology: MolecularTopology = assign_topology(&graph).expect("perception + typing succeed");
50+
51+
assert_eq!(topology.atoms[c1].atom_type, "C_3");
52+
assert_eq!(topology.atoms[c2].atom_type, "C_3");
53+
assert_eq!(topology.atoms[o].atom_type, "O_3");
54+
assert_eq!(topology.atoms[h_o].atom_type, "H_HB");
55+
```
56+
57+
Need custom chemistry? Parse a TOML file and extend the default rules:
58+
59+
```rust
60+
use dreid_typer::{assign_topology_with_rules, rules::{get_default_rules, parse_rules}, MolecularGraph};
61+
62+
// Start with the default DREIDING rules
63+
let mut all_rules = get_default_rules().to_vec();
64+
65+
// Parse and append custom rules from a TOML file
66+
let extra_toml = std::fs::read_to_string("my_metals.rules.toml")?;
67+
all_rules.extend(parse_rules(&extra_toml)?);
68+
69+
// Run the pipeline with extended rules
70+
let topology = assign_topology_with_rules(&graph, &all_rules)?;
71+
```
72+
73+
## Documentation
74+
75+
- [API Documentation](https://docs.rs/dreid-typer) - Comprehensive reference for all public types and functions.
76+
- [Architecture Documents](docs/ARCHITECTURE.md) - In-depth design and implementation details.
77+
78+
## Tech Stack
79+
80+
- **Core Language**: Rust
81+
- **Build System**: Cargo
82+
- **Rule Format**: TOML
83+
84+
## License
85+
86+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

0 commit comments

Comments
 (0)