RDKit.rb
Cheminformatics for Ruby, powered by RDKit

Installation
Add this line to your application’s Gemfile:
gem "rdkit-rb"
Getting Started
Create a molecule
mol = RDKit::Molecule.from_smiles("c1ccccc1O")
Get the number of atoms
mol.num_atoms
Get substructure matches
mol.match(RDKit::Molecule.from_smarts("ccO"))
Get fragments
mol.fragments
Generate an SVG
mol.to_svg
Fingerprints
A number of fingerprints are supported.
RDKit
mol.rdkit_fingerprint
Morgan
mol.morgan_fingerprint
Pattern
mol.pattern_fingerprint
Atom pair
mol.atom_pair_fingerprint
Topological torsion
mol.topological_torsion_fingerprint
MACCS
mol.maccs_fingerprint
You can use a library like pgvector-ruby to find similar molecules. See an example.
Updates
Add or remove hydrogen atoms
mol.add_hs!
mol.remove_hs!
Standardize
mol.cleanup!
mol.normalize!
mol.neutralize!
mol.reionize!
mol.canonical_tautomer!
mol.charge_parent!
mol.fragment_parent!
Conversion
SMILES
mol.to_smiles
SMARTS
mol.to_smarts
CXSMILES
mol.to_cxsmiles
CXSMARTS
mol.to_cxsmarts
JSON
mol.to_json
Reactions
Create a reaction
rxn = RDKit::Reaction.from_smarts("[CH3:1][OH:2]>>[CH2:1]=[OH0:2]")
Generate an SVG
rxn.to_svg
History
View the changelog
Contributing
Everyone is encouraged to help improve this project. Here are a few ways you can help:
To get started with development:
git clone https://github.com/ankane/rdkit-ruby.git
cd rdkit-ruby
bundle install
bundle exec rake vendor:all
bundle exec rake test