rdkit-rs
Safe, idiomatic Rust bindings for RDKit, the industry-standard open-source cheminformatics library.
The project ships two crates:
rdkit-sys— Low-level C++ bindings via cxx. Zero-cost wrappers exposing a key subset of RDKit’s C++ API.rdkit— High-level Rust library built onrdkit-sys. No manual memory management, no null pointers. ImplementsDebug,Clone, and idiomatic borrowing so molecules behave like native Rust types.
| Area | What You Can Do |
|---|---|
| Parsing | SMILES, molblocks, SDF files (including gzipped) |
| Normalization | Fragment parent, uncharger, canonical tautomer |
| Fingerprints | Morgan fingerprints, pattern fingerprints |
| Descriptors | Compute all standard RDKit descriptors (exactmw, NumAtoms, CrippenClogP, etc.) |
| Tautomers | Enumerate tautomers, canonicalize |
| Substructure | SMARTS-based substructure and superstructure matching |
| Periodic Table | Element lookups and properties |
Add to your Cargo.toml:
[dependencies]
rdkit = "0.4"
Example:
use rdkit::{Properties, ROMol};
use std::collections::HashMap;
fn main() {
let mol = ROMol::from_smile("c1ccccc1C(=O)NC").unwrap();
let properties = Properties::new();
let computed: HashMap<String, f64> = properties.compute_properties(&mol);
assert_eq!(*computed.get("NumAtoms").unwrap(), 19.0);
}
Browse more examples in the examples directory.
Requires RDKit 2023.09.1 or higher.
macOS:
brew install rdkit
Linux (Ubuntu 24.04+):
Pre-compiled static library tarballs are available for AMD64 and ARM64:
You will also need a C++ compiler (we recommend clang) for building the rdkit-sys bridge code.
We support recent stable Rust versions. The limiting factor is cxx — check the cxx Cargo.toml for the minimum rust-version.