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_atomsGet substructure matches
mol.match(RDKit::Molecule.from_smarts("ccO"))Get fragments
mol.fragmentsGenerate an SVG
mol.to_svgFingerprints
A number of fingerprints are supported.
RDKit
mol.rdkit_fingerprintMorgan
mol.morgan_fingerprintPattern
mol.pattern_fingerprintAtom pair
mol.atom_pair_fingerprintTopological torsion
mol.topological_torsion_fingerprintMACCS
mol.maccs_fingerprintYou 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_smilesSMARTS
mol.to_smartsCXSMILES
mol.to_cxsmilesCXSMARTS
mol.to_cxsmartsJSON
mol.to_jsonReactions
Create a reaction
rxn = RDKit::Reaction.from_smarts("[CH3:1][OH:2]>>[CH2:1]=[OH0:2]")Generate an SVG
rxn.to_svgHistory
View the changelog
Contributing
Everyone is encouraged to help improve this project. Here are a few ways you can help:
- Report bugs
- Fix bugs and submit pull requests
- Write, clarify, or fix documentation
- Suggest or add new features
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