rdkit
Cheminformatics functionality for PostgreSQL.
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
rdkit | 202503.1 | FEAT | BSD 3-Clause | C++ |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 2930 | rdkit | No | Yes | No | Yes | No | Yes | - |
| Related | age hll rum pg_graphql pg_jsonschema jsquery pg_hint_plan hypopg |
|---|
u24 has rdkit for pg17
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PGDG | 202503.1 | 1817161514 | rdkit | - |
| DEB | PGDG | 202503.1 | 1817161514 | postgresql-$v-rdkit | - |
| OS / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
| el8.aarch64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
| el9.x86_64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
| el9.aarch64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
| el10.x86_64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
| el10.aarch64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
| d12.x86_64 | PGDG MISS | PGDG MISS | PGDG 202303.3 d12.x86_64.pg16 : postgresql-16-rdkit postgresql-16-rdkit_202303.3-3.pgdg120+1_amd64.deb
| PGDG 202303.3 d12.x86_64.pg15 : postgresql-15-rdkit postgresql-15-rdkit_202303.3-3.pgdg120+1_amd64.deb
| PGDG 202303.3 d12.x86_64.pg14 : postgresql-14-rdkit postgresql-14-rdkit_202303.3-3.pgdg120+1_amd64.deb
|
| d12.aarch64 | PGDG MISS | PGDG MISS | PGDG 202303.3 d12.aarch64.pg16 : postgresql-16-rdkit postgresql-16-rdkit_202303.3-3.pgdg120+1_arm64.deb
| PGDG 202303.3 d12.aarch64.pg15 : postgresql-15-rdkit postgresql-15-rdkit_202303.3-3.pgdg120+1_arm64.deb
| PGDG 202303.3 d12.aarch64.pg14 : postgresql-14-rdkit postgresql-14-rdkit_202303.3-3.pgdg120+1_arm64.deb
|
| d13.x86_64 | PGDG 202503.1 d13.x86_64.pg18 : postgresql-18-rdkit postgresql-18-rdkit_202503.1-5.pgdg13+1_amd64.deb
| PGDG 202503.1 d13.x86_64.pg17 : postgresql-17-rdkit postgresql-17-rdkit_202503.1-5.pgdg13+1_amd64.deb
| PGDG 202503.1 d13.x86_64.pg16 : postgresql-16-rdkit postgresql-16-rdkit_202503.1-5.pgdg13+1_amd64.deb
| PGDG 202503.1 d13.x86_64.pg15 : postgresql-15-rdkit postgresql-15-rdkit_202503.1-5.pgdg13+1_amd64.deb
| PGDG 202503.1 d13.x86_64.pg14 : postgresql-14-rdkit postgresql-14-rdkit_202503.1-5.pgdg13+1_amd64.deb
|
| d13.aarch64 | PGDG 202503.1 d13.aarch64.pg18 : postgresql-18-rdkit postgresql-18-rdkit_202503.1-5.pgdg13+1_arm64.deb
| PGDG 202503.1 d13.aarch64.pg17 : postgresql-17-rdkit postgresql-17-rdkit_202503.1-5.pgdg13+1_arm64.deb
| PGDG 202503.1 d13.aarch64.pg16 : postgresql-16-rdkit postgresql-16-rdkit_202503.1-5.pgdg13+1_arm64.deb
| PGDG 202503.1 d13.aarch64.pg15 : postgresql-15-rdkit postgresql-15-rdkit_202503.1-5.pgdg13+1_arm64.deb
| PGDG 202503.1 d13.aarch64.pg14 : postgresql-14-rdkit postgresql-14-rdkit_202503.1-5.pgdg13+1_arm64.deb
|
| u22.x86_64 | PGDG MISS | PGDG MISS | PGDG 202303.3 u22.x86_64.pg16 : postgresql-16-rdkit postgresql-16-rdkit_202303.3-3.pgdg22.04+1_amd64.deb
| PGDG 202303.3 u22.x86_64.pg15 : postgresql-15-rdkit postgresql-15-rdkit_202303.3-3.pgdg22.04+1_amd64.deb
| PGDG 202303.3 u22.x86_64.pg14 : postgresql-14-rdkit postgresql-14-rdkit_202303.3-3.pgdg22.04+1_amd64.deb
|
| u22.aarch64 | PGDG MISS | PGDG MISS | PGDG 202303.3 u22.aarch64.pg16 : postgresql-16-rdkit postgresql-16-rdkit_202303.3-3.pgdg22.04+1_arm64.deb
| PGDG 202303.3 u22.aarch64.pg15 : postgresql-15-rdkit postgresql-15-rdkit_202303.3-3.pgdg22.04+1_arm64.deb
| PGDG 202303.3 u22.aarch64.pg14 : postgresql-14-rdkit postgresql-14-rdkit_202303.3-3.pgdg22.04+1_arm64.deb
|
| u24.x86_64 | PGDG 202503.1 u24.x86_64.pg18 : postgresql-18-rdkit postgresql-18-rdkit_202503.1-5.pgdg24.04+1_amd64.deb
| PGDG 202503.1 u24.x86_64.pg17 : postgresql-17-rdkit postgresql-17-rdkit_202503.1-5.pgdg24.04+1_amd64.deb
| PGDG 202503.1 u24.x86_64.pg16 : postgresql-16-rdkit postgresql-16-rdkit_202503.1-5.pgdg24.04+1_amd64.deb
| PGDG 202503.1 u24.x86_64.pg15 : postgresql-15-rdkit postgresql-15-rdkit_202503.1-5.pgdg24.04+1_amd64.deb
| PGDG 202503.1 u24.x86_64.pg14 : postgresql-14-rdkit postgresql-14-rdkit_202503.1-5.pgdg24.04+1_amd64.deb
|
| u24.aarch64 | PGDG 202503.1 u24.aarch64.pg18 : postgresql-18-rdkit postgresql-18-rdkit_202503.1-5.pgdg24.04+1_arm64.deb
| PGDG 202503.1 u24.aarch64.pg17 : postgresql-17-rdkit postgresql-17-rdkit_202503.1-5.pgdg24.04+1_arm64.deb
| PGDG 202503.1 u24.aarch64.pg16 : postgresql-16-rdkit postgresql-16-rdkit_202503.1-5.pgdg24.04+1_arm64.deb
| PGDG 202503.1 u24.aarch64.pg15 : postgresql-15-rdkit postgresql-15-rdkit_202503.1-5.pgdg24.04+1_arm64.deb
| PGDG 202503.1 u24.aarch64.pg14 : postgresql-14-rdkit postgresql-14-rdkit_202503.1-5.pgdg24.04+1_arm64.deb
|
Install
You can install rdkit directly. First, make sure the PGDG repository is added and enabled:
pig repo add pgdg -u # Add PGDG repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install rdkit; # Install for current active PG version
pig ext install -y rdkit -v 18 # PG 18
pig ext install -y rdkit -v 17 # PG 17
pig ext install -y rdkit -v 16 # PG 16
pig ext install -y rdkit -v 15 # PG 15
pig ext install -y rdkit -v 14 # PG 14
apt install -y postgresql-18-rdkit # PG 18
apt install -y postgresql-17-rdkit # PG 17
apt install -y postgresql-16-rdkit # PG 16
apt install -y postgresql-15-rdkit # PG 15
apt install -y postgresql-14-rdkit # PG 14
Create Extension:
CREATE EXTENSION rdkit;
Usage
rdkit: Cheminformatics and molecule toolkit PostgreSQL cartridge
The RDKit PostgreSQL cartridge provides the mol datatype for molecules, fp datatype for fingerprints, substructure and similarity search operations, and GiST index support.
CREATE EXTENSION rdkit;
Data Types
| Type | Description |
|---|---|
mol | Molecular structure (from SMILES, SMARTS, etc.) |
bfp | Bit vector fingerprint |
sfp | Sparse (count) fingerprint |
Molecule Input/Output
-- Create molecule from SMILES
SELECT 'c1ccccc1'::mol;
-- Check if SMILES is valid
SELECT is_valid_smiles('c1ccccc1');
-- Convert molecule to SMILES
SELECT mol_to_smiles('c1ccccc1'::mol);
Substructure Search
-- Substructure match operator
SELECT 'c1ccccc1O'::mol @> 'c1ccccc1'::mol; -- true (phenol contains benzene)
SELECT 'c1ccccc1'::mol <@ 'c1ccccc1O'::mol; -- true
-- Using SMARTS patterns
SELECT 'c1ccccc1O'::mol @> 'c1ccc(O)cc1'::mol;
Similarity Search
-- Tanimoto similarity (returns value between 0 and 1)
SELECT tanimoto_sml(morganbv_fp('c1ccccc1'::mol), morganbv_fp('c1ccccc1O'::mol));
-- Dice similarity
SELECT dice_sml(morganbv_fp('c1ccccc1'::mol), morganbv_fp('c1ccccc1O'::mol));
Fingerprint Functions
-- Morgan fingerprint (bit vector)
SELECT morganbv_fp('c1ccccc1'::mol);
SELECT morganbv_fp('c1ccccc1'::mol, 2); -- radius=2
-- RDKit fingerprint
SELECT rdkit_fp('c1ccccc1'::mol);
-- Topological torsion fingerprint
SELECT torsionbv_fp('c1ccccc1'::mol);
-- Atom pair fingerprint
SELECT atompairbv_fp('c1ccccc1'::mol);
Descriptor Calculations
SELECT mol_amw('c1ccccc1'::mol); -- average molecular weight
SELECT mol_logp('c1ccccc1'::mol); -- LogP
SELECT mol_hba('c1ccccc1O'::mol); -- H-bond acceptors
SELECT mol_hbd('c1ccccc1O'::mol); -- H-bond donors
SELECT mol_numrotatablebonds('c1ccccc1'::mol); -- rotatable bonds
SELECT mol_numatoms('c1ccccc1'::mol); -- number of atoms
SELECT mol_numheavyatoms('c1ccccc1'::mol); -- heavy atoms
SELECT mol_numrings('c1ccccc1'::mol); -- number of rings
GiST Index Support
Create indexes for fast substructure and similarity searches:
-- Substructure search index
CREATE INDEX idx_mol ON molecules USING gist(molecule);
-- Fingerprint similarity index
CREATE INDEX idx_fp ON molecules USING gist(morganbv_fp(molecule));
Query with index support:
-- Substructure search
SELECT * FROM molecules WHERE molecule @> 'c1ccccc1'::mol;
-- Similarity search (with threshold)
SET rdkit.dice_threshold = 0.5;
SELECT * FROM molecules WHERE morganbv_fp(molecule) % morganbv_fp('c1ccccc1O'::mol);
GUC Parameters
| Parameter | Default | Description |
|---|---|---|
rdkit.tanimoto_threshold | 0.5 | Threshold for Tanimoto similarity operator <%> |
rdkit.dice_threshold | 0.5 | Threshold for Dice similarity operator % |
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.