Install and load
Run these commands in a Haybarn SQL session. The extension is available from the community repository.
INSTALL ducksmiles FROM community;
LOAD ducksmiles FROM community;
Try it in a temporary SQL session with ducksmiles already loaded. Queries run in this tab; examples using files or services need their own setup.
Using upstream DuckDB? Follow the maintainer’s installation instructions.
Usage example
Parse SMILES and get molecular formula
-- Parse SMILES and get molecular formula
SELECT mol_formula('CCO');
-- C2H6O
-- Calculate molecular weight
SELECT round(mol_weight('c1ccccc1'), 2);
-- 78.11
-- Wildman-Crippen LogP and molar refractivity (match RDKit)
SELECT round(logp_crippen('CCO'), 4), round(mol_mr('c1ccccc1'), 3);
-- -0.0014, 26.442
-- QED drug-likeness score (RDKit Chem.QED, weights_mean)
SELECT round(qed('CC(=O)Oc1ccccc1C(=O)O'), 3);
-- 0.550 (aspirin)
-- Drug-likeness rule panels + toxicophore alerts
SELECT lipinski_violations('CC(=O)Oc1ccccc1C(=O)O'),
druglikeness_pass('CC(=O)Oc1ccccc1C(=O)O', 'veber'),
structural_alerts_json('O=Cc1ccccc1');
-- 0, 1, ["aldehyde","aldehyde_any"]
-- Morgan/ECFP fingerprint + similarity between two BLOBs
SELECT round(tanimoto_bit(morgan_fp_bits('CCO'), morgan_fp_bits('CCN')), 4);
-- 0.3333
-- In-silico docking: SMILES ligand vs PDB receptor -> ranked poses (JSON)
SELECT dock('CCO', :receptor_pdb, 1.7,0.2,0.5, 8,8,8, 20, 42);
-- Retrospective virtual-screening enrichment over a docked, labelled library
SELECT roc_auc(list(score), list(is_active)),
enrichment_factor(list(score), list(is_active), 0.01),
bedroc(list(score), list(is_active), 20.0)
FROM docked_library;
-- CPU PCA on a numeric matrix, returning versioned JSON
SELECT chem_pca([[1.0,2.0],[2.0,4.0],[3.0,6.0]], [1.0,0.0]);
-- Convert SMILES to SELFIES (ML-friendly notation)
SELECT smiles_to_selfies('CCO');
Provided by nkwork9999. Not yet verified on Haybarn 2.0.0.
Sample data & setupAbout this extension
Cheminformatics toolkit for DuckDB - analyze molecular structures directly from SQL without leaving your database. Pure Rust implementation with no external chemistry library dependencies (no RDKit required).
435 SQL overloads, including the 156 molecular overloads and 279 CPU analytics functions. Molecular methods cover property extraction, format conversion, structural comparison, fingerprinting, similarity search, drug-likeness / toxicophore filtering, and structure-based virtual screening.
Project overview from the community descriptor.
Documentation and resources
Project and build details
- Repository
- nkwork9999/duckSMILES
- License
- MIT
- Maintainers
- nkwork9999
- Written in
- C++
- Build source
2d4a5201c71c- Build definition
- Community descriptor