chematic-core
Core types for chematic: Atom, Bond, Molecule, and Element. Low-level graph representation for all chematic crates. Pure Rust, WASM-compatible.
Features
- Molecule graph: adjacency-list representation with atoms and bonds
- Atom types: element, hybridization, formal charge, aromatic flag, isotope
- Bond types: single, double, triple, aromatic bonds with configurable order
- Element table: periodic table with atomic number, mass, electronegativity, van der Waals radius
- Molecular properties: atom count, bond count, molecular weight, formula
- WASM-compatible: zero C/C++ dependencies
Quick Start
use ;
// Create a molecule manually (or use a parser)
let mut mol = new;
// Add atoms (returns their indices)
let c0 = mol.add_atom; // methane C
let h0 = mol.add_atom;
let h1 = mol.add_atom;
let h2 = mol.add_atom;
let h3 = mol.add_atom;
// Add bonds
mol.add_bond;
mol.add_bond;
mol.add_bond;
mol.add_bond;
// Query the graph
println!; // 5
println!; // 4
println!; // 16.04
// Iterate neighbors
for in mol.neighbors
API Overview
Types
Molecule— molecular graph: atoms, bonds, adjacencyAtom— atomic data: element, charge, hybridization, aromaticity, isotopeBond— bond data: atoms, order, stereochemistry (Up/Down, E/Z)Element— element info: atomic number, mass, vdW radius, electronegativityAtomIdx,BondIdx— newtype wrappers for type safety
Molecular Properties
let mw = mol.molecular_weight;
let formula = mol.formula;
let neighbors = mol.neighbors;
let atom = mol.atom;
let bond = mol.bond;
Element Constants
use Element;
C, // carbon
H, // hydrogen
N, // nitrogen
O, // oxygen
P, // phosphorus
S, // sulfur
Cl, // chlorine
// ...and all others
Dependencies
None (no external dependencies).
See Also
chematic-smiles— SMILES parser (builds Molecules)chematic-smarts— SMARTS matchingchematic— main umbrella crate