chematic-smarts
SMARTS parser, VF2 subgraph isomorphism, and maximum common subgraph (MCS) for Rust. Pure implementation, RDKit-compatible, WASM-compatible.
Features
- SMARTS parsing: full OpenSMARTS syntax (atom/bond logical expressions, recursive SMARTS)
- VF2 matching: fast subgraph isomorphism detection (substructure search)
- Maximum Common Subgraph (MCS): find largest shared structure between two molecules
- Chirality-aware matching: optional R/S and E/Z stereo consideration
- RDKit compatibility: parses RDKit SMARTS, produces identical matches
- WASM-compatible: zero C/C++ dependencies
Quick Start
use parse;
use ;
// Parse a query
let query = parse_smarts.expect;
// Parse a molecule
let mol = parse.expect;
// Find all matches
let matches = find_matches;
println!;
for m in matches
API Overview
SMARTS Matching
find_matches(query: &Molecule, target: &Molecule) -> Vec<AtomMap>— all substructure matchesfind_matches_with_config(query: &Molecule, target: &Molecule, config: &MatchConfig) -> Vec<AtomMap>— with optionshas_match(query: &Molecule, target: &Molecule) -> bool— fast boolean check
Maximum Common Subgraph
mcs(mol1: &Molecule, mol2: &Molecule) -> McsResult— find largest common subgraph- Result includes atom/bond mappings and fragment count
Configuration
use MatchConfig;
let config = MatchConfig ;
let matches = find_matches_with_config;
Dependencies
chematic-core— molecular graphchematic-perception— aromaticity, hybridization
References
- OpenSMARTS spec: https://opensmarts.org/
- VF2 algorithm: https://en.wikipedia.org/wiki/VF2_(algorithm)
- SMARTS tutorial: https://www.daylight.com/dayhtml/doc/theory/theory.smarts.html
See Also
chematic— main umbrella cratechematic-smiles— SMILES parserchematic-fp— fingerprints and similarity