pgchy_similarity
pgchy_similarity · Chemical structure similarity functions for PostgreSQL using Chython and PL/Python.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 101104 | pgchy_similarity | pgchy_similarity | 1.0 | RAG | MIT | C |
| Relationships | |
|---|---|
| Requires | plpython3u |
Usage
Sources:
pgchy_similarity computes thresholded Tanimoto similarity for molecular fingerprints. The SQL helper smiles_to_fingerprint(text) uses untrusted PL/Python, Chython, and NumPy to build a 2048-bit Morgan fingerprint; is_tanimoto_similar(bytea, bytea, float4) compares two packed fingerprints.
Fingerprint meaning depends on exact Chython/NumPy versions, radius, length, bit order, and packed layout. Pin the Python environment and validate known molecule pairs. A change requires recomputing every stored fingerprint.
Untrusted PL/Python is superuser-controlled and can access the server operating system. The C function interprets a packed bytea layout directly, so reject malformed or wrong-length inputs before native code. Tanimoto thresholding is a screening method, not chemical identity or safety validation. Benchmark false positives/negatives and memory/CPU, and restrict both fingerprint generation and comparison functions to reviewed roles.