rdkit
在PostgreSQL化学领域数据管理功能
概览
| 扩展包名 | 版本 | 分类 | 许可证 | 语言 |
|---|---|---|---|---|
rdkit | 202503.1 | FEAT | BSD 3-Clause | C++ |
| ID | 扩展名 | Bin | Lib | Load | Create | Trust | Reloc | 模式 |
|---|---|---|---|---|---|---|---|---|
| 2930 | rdkit | 否 | 是 | 否 | 是 | 否 | 是 | - |
| 相关扩展 | age hll rum pg_graphql pg_jsonschema jsquery pg_hint_plan hypopg |
|---|
u24 has rdkit for pg17
版本
| 类型 | 仓库 | 版本 | PG 大版本 | 包名 | 依赖 |
|---|---|---|---|---|---|
| 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
|
安装
您可以直接安装 rdkit 扩展包的预置二进制包,首先确保 PGDG 仓库已经添加并启用:
pig repo add pgdg -u # 添加 PGDG 仓库并更新缓存
使用 pig 或者是 apt/yum/dnf 安装扩展:
pig install rdkit; # 当前活跃 PG 版本安装
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 rdkit;
用法
RDKit PostgreSQL 扩展提供了用于分子的 mol 数据类型、用于指纹的 fp 数据类型、子结构和相似性搜索操作,以及 GiST 索引支持。
CREATE EXTENSION rdkit;
数据类型
| 类型 | 描述 |
|---|---|
mol | 分子结构(来自 SMILES、SMARTS 等) |
bfp | 位向量指纹 |
sfp | 稀疏(计数)指纹 |
分子输入/输出
-- 从 SMILES 创建分子
SELECT 'c1ccccc1'::mol;
-- 检查 SMILES 是否有效
SELECT is_valid_smiles('c1ccccc1');
-- 将分子转换为 SMILES
SELECT mol_to_smiles('c1ccccc1'::mol);
子结构搜索
-- 子结构匹配运算符
SELECT 'c1ccccc1O'::mol @> 'c1ccccc1'::mol; -- true(苯酚包含苯环)
SELECT 'c1ccccc1'::mol <@ 'c1ccccc1O'::mol; -- true
-- 使用 SMARTS 模式
SELECT 'c1ccccc1O'::mol @> 'c1ccc(O)cc1'::mol;
相似性搜索
-- Tanimoto 相似度(返回 0 到 1 之间的值)
SELECT tanimoto_sml(morganbv_fp('c1ccccc1'::mol), morganbv_fp('c1ccccc1O'::mol));
-- Dice 相似度
SELECT dice_sml(morganbv_fp('c1ccccc1'::mol), morganbv_fp('c1ccccc1O'::mol));
指纹函数
-- Morgan 指纹(位向量)
SELECT morganbv_fp('c1ccccc1'::mol);
SELECT morganbv_fp('c1ccccc1'::mol, 2); -- radius=2
-- RDKit 指纹
SELECT rdkit_fp('c1ccccc1'::mol);
-- 拓扑扭转指纹
SELECT torsionbv_fp('c1ccccc1'::mol);
-- 原子对指纹
SELECT atompairbv_fp('c1ccccc1'::mol);
描述符计算
SELECT mol_amw('c1ccccc1'::mol); -- 平均分子量
SELECT mol_logp('c1ccccc1'::mol); -- LogP
SELECT mol_hba('c1ccccc1O'::mol); -- 氢键受体
SELECT mol_hbd('c1ccccc1O'::mol); -- 氢键供体
SELECT mol_numrotatablebonds('c1ccccc1'::mol); -- 可旋转键
SELECT mol_numatoms('c1ccccc1'::mol); -- 原子数
SELECT mol_numheavyatoms('c1ccccc1'::mol); -- 重原子数
SELECT mol_numrings('c1ccccc1'::mol); -- 环数
GiST 索引支持
创建索引以加速子结构和相似性搜索:
-- 子结构搜索索引
CREATE INDEX idx_mol ON molecules USING gist(molecule);
-- 指纹相似性索引
CREATE INDEX idx_fp ON molecules USING gist(morganbv_fp(molecule));
使用索引查询:
-- 子结构搜索
SELECT * FROM molecules WHERE molecule @> 'c1ccccc1'::mol;
-- 相似性搜索(带阈值)
SET rdkit.dice_threshold = 0.5;
SELECT * FROM molecules WHERE morganbv_fp(molecule) % morganbv_fp('c1ccccc1O'::mol);
GUC 参数
| 参数 | 默认值 | 描述 |
|---|---|---|
rdkit.tanimoto_threshold | 0.5 | Tanimoto 相似度运算符 <%> 的阈值 |
rdkit.dice_threshold | 0.5 | Dice 相似度运算符 % 的阈值 |