RDKit-rs
Toggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeBack to homepage

RDKit-rs

License Crates.io

The power and speed of RDKit, the safety of Rust! A combination of low level C++ bindings and useful high level Rust constructs so you can

  • Parse mol/molblocks
  • Normalize
  • Fingerprint
  • Enumerate tautomers/canonicalize

How does it work?

The rdkit-rs project provides two key libraries: rdkit and rdkit-sys. The sys package is a collection of low or zero-cost wrappers exposing a key subset of the RDKit C++ functionality. The rdkit package builds on top of the sys package, hiding pointers and providing idiomatic Rust interfaces (think: Debug and Clone implementations, smart borrowing behavior).

With the rdkit library you will never need to manually free memory or worry about accessing null pointers. You also get all the benefits of an optimizing compiler and will never wait for garbage collection.

Example

in your Cargo.toml:

[dependencies]
rdkit = "*"

If you satisfy the requirements below, the following code should just compile!

use rdkit::{Properties, ROMol};

pub 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 rdkit-rs/rdkit examples

Requirements

We support recent stable Rust versions. The limiting factor is whatever our C++ bindings library, cxx-rs, supports. Check the cxx Cargo.toml to confirm what rust-version is supported.

Requires a recent version of RDKit, tested against 2022.03.1. Supports both static and dynamic linking, preferring static linking. You can use a copy of RDKit installed either from Mac homebrew or Conda Forge. We are working to get Debian packages updated for the most recent RDKit and also including static libraries so we can build portable RDKit applications.

  • brew install rdkit
  • conda install -c conda-forge rdkit==2022.03.1

Ubuntu support is coming soon.

You will also need a compiler for building the sys package’s C++ bridge. We recommend clang for the compilation speed.

Why Rust?

Rust is a powerful systems level programming language, offering a smart static typing system, an integrated build system and package manager, and strong memory safety, among many other benefits. Read more about Rust in the free Rust Book.

Learn More

Javier Pineda, PhD., presented on Cheminee at a Scientist Show And Tell, see the slides

Issues?

Please file an issue on GitHub