rdkit

rdkit : Cheminformatics functionality for PostgreSQL.

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
2930
rdkit
rdkit
202503.1
FEAT
BSD 3-Clause
C++
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d-r
No
Yes
No
Yes
yes
no
Relationships
See Also
age
hll
rum
pg_graphql
pg_jsonschema
jsquery
pg_hint_plan
hypopg

u24 has rdkit for pg17

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXT
PGDG
202503.1
18
17
16
15
14
rdkit-
DEB
PGDG
202503.1
18
17
16
15
14
postgresql-$v-rdkit-
Linux / PGPG18PG17PG16PG15PG14
el8.x86_64
MISS
MISS
MISS
MISS
MISS
el8.aarch64
MISS
MISS
MISS
MISS
MISS
el9.x86_64
MISS
MISS
MISS
MISS
MISS
el9.aarch64
MISS
MISS
MISS
MISS
MISS
el10.x86_64
MISS
MISS
MISS
MISS
MISS
el10.aarch64
MISS
MISS
MISS
MISS
MISS
d12.x86_64
MISS
MISS
PGDG 202303.3
PGDG 202303.3
PGDG 202303.3
d12.aarch64
MISS
MISS
PGDG 202303.3
PGDG 202303.3
PGDG 202303.3
d13.x86_64
PGDG 202503.1
PGDG 202503.1
PGDG 202503.1
PGDG 202503.1
PGDG 202503.1
d13.aarch64
PGDG 202503.1
PGDG 202503.1
PGDG 202503.1
PGDG 202503.1
PGDG 202503.1
u22.x86_64
MISS
MISS
PGDG 202303.3
PGDG 202303.3
PGDG 202303.3
u22.aarch64
MISS
MISS
PGDG 202303.3
PGDG 202303.3
PGDG 202303.3
u24.x86_64
PGDG 202503.1
PGDG 202503.1
PGDG 202503.1
PGDG 202503.1
PGDG 202503.1
u24.aarch64
PGDG 202503.1
PGDG 202503.1
PGDG 202503.1
PGDG 202503.1
PGDG 202503.1
PackageVersionOSORGSIZEFile URL
postgresql-18-rdkit202503.1d13.x86_64pgdg245.1 KiBpostgresql-18-rdkit_202503.1-5.pgdg13+1_amd64.deb
postgresql-18-rdkit202503.1d13.aarch64pgdg237.6 KiBpostgresql-18-rdkit_202503.1-5.pgdg13+1_arm64.deb
postgresql-18-rdkit202503.1u24.x86_64pgdg243.1 KiBpostgresql-18-rdkit_202503.1-5.pgdg24.04+1_amd64.deb
postgresql-18-rdkit202503.1u24.aarch64pgdg237.1 KiBpostgresql-18-rdkit_202503.1-5.pgdg24.04+1_arm64.deb
PackageVersionOSORGSIZEFile URL
postgresql-17-rdkit202503.1d13.x86_64pgdg245.2 KiBpostgresql-17-rdkit_202503.1-5.pgdg13+1_amd64.deb
postgresql-17-rdkit202503.1d13.aarch64pgdg237.5 KiBpostgresql-17-rdkit_202503.1-5.pgdg13+1_arm64.deb
postgresql-17-rdkit202503.1u24.x86_64pgdg243.1 KiBpostgresql-17-rdkit_202503.1-5.pgdg24.04+1_amd64.deb
postgresql-17-rdkit202503.1u24.aarch64pgdg237.2 KiBpostgresql-17-rdkit_202503.1-5.pgdg24.04+1_arm64.deb
PackageVersionOSORGSIZEFile URL
postgresql-16-rdkit202303.3d12.x86_64pgdg393.5 KiBpostgresql-16-rdkit_202303.3-3.pgdg120+1_amd64.deb
postgresql-16-rdkit202303.3d12.aarch64pgdg384.8 KiBpostgresql-16-rdkit_202303.3-3.pgdg120+1_arm64.deb
postgresql-16-rdkit202503.1d13.x86_64pgdg245.2 KiBpostgresql-16-rdkit_202503.1-5.pgdg13+1_amd64.deb
postgresql-16-rdkit202503.1d13.aarch64pgdg237.5 KiBpostgresql-16-rdkit_202503.1-5.pgdg13+1_arm64.deb
postgresql-16-rdkit202303.3u22.x86_64pgdg395.8 KiBpostgresql-16-rdkit_202303.3-3.pgdg22.04+1_amd64.deb
postgresql-16-rdkit202303.3u22.aarch64pgdg387.1 KiBpostgresql-16-rdkit_202303.3-3.pgdg22.04+1_arm64.deb
postgresql-16-rdkit202503.1u24.x86_64pgdg243.2 KiBpostgresql-16-rdkit_202503.1-5.pgdg24.04+1_amd64.deb
postgresql-16-rdkit202503.1u24.aarch64pgdg237.0 KiBpostgresql-16-rdkit_202503.1-5.pgdg24.04+1_arm64.deb
PackageVersionOSORGSIZEFile URL
postgresql-15-rdkit202303.3d12.x86_64pgdg394.5 KiBpostgresql-15-rdkit_202303.3-3.pgdg120+1_amd64.deb
postgresql-15-rdkit202303.3d12.aarch64pgdg385.2 KiBpostgresql-15-rdkit_202303.3-3.pgdg120+1_arm64.deb
postgresql-15-rdkit202503.1d13.x86_64pgdg245.2 KiBpostgresql-15-rdkit_202503.1-5.pgdg13+1_amd64.deb
postgresql-15-rdkit202503.1d13.aarch64pgdg237.5 KiBpostgresql-15-rdkit_202503.1-5.pgdg13+1_arm64.deb
postgresql-15-rdkit202303.3u22.x86_64pgdg395.8 KiBpostgresql-15-rdkit_202303.3-3.pgdg22.04+1_amd64.deb
postgresql-15-rdkit202303.3u22.aarch64pgdg387.0 KiBpostgresql-15-rdkit_202303.3-3.pgdg22.04+1_arm64.deb
postgresql-15-rdkit202503.1u24.x86_64pgdg243.1 KiBpostgresql-15-rdkit_202503.1-5.pgdg24.04+1_amd64.deb
postgresql-15-rdkit202503.1u24.aarch64pgdg237.0 KiBpostgresql-15-rdkit_202503.1-5.pgdg24.04+1_arm64.deb
PackageVersionOSORGSIZEFile URL
postgresql-14-rdkit202303.3d12.x86_64pgdg394.1 KiBpostgresql-14-rdkit_202303.3-3.pgdg120+1_amd64.deb
postgresql-14-rdkit202303.3d12.aarch64pgdg385.2 KiBpostgresql-14-rdkit_202303.3-3.pgdg120+1_arm64.deb
postgresql-14-rdkit202503.1d13.x86_64pgdg245.2 KiBpostgresql-14-rdkit_202503.1-5.pgdg13+1_amd64.deb
postgresql-14-rdkit202503.1d13.aarch64pgdg237.2 KiBpostgresql-14-rdkit_202503.1-5.pgdg13+1_arm64.deb
postgresql-14-rdkit202303.3u22.x86_64pgdg395.5 KiBpostgresql-14-rdkit_202303.3-3.pgdg22.04+1_amd64.deb
postgresql-14-rdkit202303.3u22.aarch64pgdg387.2 KiBpostgresql-14-rdkit_202303.3-3.pgdg22.04+1_arm64.deb
postgresql-14-rdkit202503.1u24.x86_64pgdg242.9 KiBpostgresql-14-rdkit_202503.1-5.pgdg24.04+1_amd64.deb
postgresql-14-rdkit202503.1u24.aarch64pgdg237.0 KiBpostgresql-14-rdkit_202503.1-5.pgdg24.04+1_arm64.deb

Source

Install

Make sure PGDG repo available:

pig repo add pgdg -u    # add pgdg repo and update cache

Install this extension with pig:

pig install rdkit;		# install via package name, for the active PG version

pig install rdkit -v 18;   # install for PG 18
pig install rdkit -v 17;   # install for PG 17
pig install rdkit -v 16;   # install for PG 16
pig install rdkit -v 15;   # install for PG 15
pig install rdkit -v 14;   # install for PG 14

Create this extension with:

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

TypeDescription
molMolecular structure (from SMILES, SMARTS, etc.)
bfpBit vector fingerprint
sfpSparse (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

ParameterDefaultDescription
rdkit.tanimoto_threshold0.5Threshold for Tanimoto similarity operator <%>
rdkit.dice_threshold0.5Threshold for Dice similarity operator %
Last updated on