chematic-rxn
Reaction SMILES and SMIRKS parser for Rust. Parses chemical transformations (reactants → products) and reaction patterns (transform rules). Pure Rust, RDKit-compatible, WASM-compatible.
Features
- Reaction SMILES parsing: parse reaction equations (e.g.,
CC(C)C>>CC(C)[O]) - SMIRKS parsing: transform patterns for reaction template matching (
run_reactants,run_reactants_strict) - Atom mapping: track which atoms in reactants map to which atoms in products
- Reaction properties: count reactants, products, and agents
- Stereo-selective SMIRKS:
@/@@in reactant templates filter by absolute configuration using permutation-parity comparison (write-order independent — the same enantiomer is matched regardless of how the reactant SMILES was written) - Template-based retrosynthesis (
retro_disconnect): 60 retro-SMIRKS templates across 6 classes:AmideBond— amide, sulfonamide, carbamate, urea, hydrazide, imideEster— ester, thioester, carbonate, anhydride, acetal, lactoneEther— aryl ether (SNAr/Ullmann), Williamson, benzyl, Mitsunobu, silylCNBond— reductive amination, SNAr, Buchwald, N-alkylation, imine reductionCCBond— Suzuki, Heck, Sonogashira, Negishi, Grignard, aldol, Michael, WittigCSBond— thioether, disulfide, borylation, halogenation, phosphonate
- RDKit compatibility: parses RDKit reaction SMILES, produces identical results
- WASM-compatible: zero C/C++ dependencies
Quick Start
use parse_reaction;
// Parse a reaction SMILES
let rxn = parse_reaction
.expect;
println!;
println!;
// Access reactants and products as Molecule objects
for mol in rxn.reactants
API Overview
Parsing
parse_reaction(rxn_smiles: &str) -> Result<Reaction, ParseError>— parse reaction SMILESparse_smirks(pattern: &str) -> Result<ReactionPattern, ParseError>— parse SMIRKS pattern
Retrosynthesis
retro_disconnect(mol, templates, max_results) -> Vec<RetroResult>— apply retro-SMIRKS templatesDEFAULT_TEMPLATES— 60 built-in retro-SMIRKS templates (6 reaction classes)RetroResult—{template_name, reaction_class, precursors, precursor_smiles, max_sa_score}
use ;
use parse;
let mol = parse?; // acetanilide
let results = retro_disconnect;
for r in &results
// amide_secondary: ["CC(=O)O", "Nc1ccccc1"]
Reaction Structure
Reaction— contains reactants, agents, products, and optional atom mappingsMolecule— each reactant/product is a standard MoleculeReactionPattern— SMIRKS pattern for template matching
Properties
let rxn = parse_reaction?;
assert_eq!;
assert_eq!;
assert_eq!;
// Get individual molecules
let mol1 = rxn.reactant.expect;
let prod = rxn.product.expect;
Dependencies
chematic-core— molecular graphchematic-smiles— SMILES parser
References
- Reaction SMILES: https://www.daylight.com/dayhtml/doc/theory/theory.smiles.html#reactions
- SMIRKS: https://www.daylight.com/meetings/emug05/Friedman_SMIRKS.pdf
See Also
chematic— main umbrella cratechematic-smiles— SMILES parserchematic-smarts— substructure matching and reactionschematic-depict— reaction scheme visualization