Chem
Compute molecular descriptors, fingerprints, similarity, substructure matches and InChI keys from SMILES strings
- Connector software
- Free and open source
- Service credentials
- Not needed
- Query Farm hosting
- Available · $10/month organization minimum
Use with an agent
Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.
npx skills add Query-farm/vgi-skills --skill orchard
Copy this request into your coding agent to get started.
Use https://query.farm/products/orchard/connectors/chem/index.md to help me query Chem with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.
Browse the built-in example molecules by molecular weight.
Example output · captured
- Connector release
- v0.5.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
SELECT name, formula
FROM chem.main.example_molecules()
ORDER BY mol_weight
LIMIT 3;
| name | formula |
|---|---|
| water | H2O |
| ethanol | C2H6O |
| acetic acid | C2H4O2 |
Quick start
Choose where to run Chem, then follow the steps below.
The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.
1. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
2. Attach the connector
Attach with uvx
Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.
ATTACH 'chem' AS chem (
TYPE vgi,
LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-chem-worker'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'chem' AS chem (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-chem:0.5.0'
);
3. Run a query
SELECT name, formula
FROM chem.main.example_molecules()
ORDER BY mol_weight
LIMIT 3;
Run the connector on a server you manage. You operate the service and choose who can connect.
1. Deploy the connector on your server
Follow the connector’s deployment instructions. Use its supported HTTP transport, or launch it remotely over SSH. The connection guide explains both options.
2. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach the connector
For an HTTP deployment, replace the example URL with your endpoint. Add the authentication options your deployment requires. For SSH, use the SSH connection instructions.
ATTACH 'chem' AS chem
(TYPE vgi, LOCATION 'https://your-connector.example.com');
4. Run a query
SELECT name, formula
FROM chem.main.example_molecules()
ORDER BY mol_weight
LIMIT 3;
Query Farm operates Chem for your team. Hosting has a $10 monthly minimum per organization; usage counts toward it. From $2.97 per instance-month ($10 monthly minimum).
1. Create your hosted connector
Open the console, choose your organization and deployment size, and add any service credentials there.
2. Install the vgi extension
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach your deployment
Copy the ATTACH statement from your deployment in the console and run it in DuckDB or Haybarn. Use chem as the catalog alias for the query below.
4. Run a query
SELECT name, formula
FROM chem.main.example_molecules()
ORDER BY mol_weight
LIMIT 3;
Technical details
- Verified connector release
- v0.5.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
- Verified on
- December 1, 2026
Pin a version for production
When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.
Attach with uvx
Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.
ATTACH 'chem' AS chem (
TYPE vgi,
LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-chem-worker'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'chem' AS chem (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-chem:0.5.0'
);
Overview
RDKit cheminformatics for SQL: molecular descriptors, fingerprints, substructure, InChI.

Run molecular descriptors, fingerprints, Tanimoto similarity, SMARTS substructure search and InChI/InChIKey generation directly in DuckDB SQL — computed from SMILES strings by RDKit, the industry-standard open-source cheminformatics toolkit.
The chem catalog turns DuckDB into a cheminformatics engine. Instead of exporting a column of SMILES to Python, looping through RDKit, and joining the results back, you call chemistry functions inline in a query: validate and canonicalize structures, compute physicochemical properties, generate molecular fingerprints, score structural similarity, match SMARTS patterns, and screen for drug-likeness — all on whole tables of compounds at once. It is built for chemists, computational chemists, data scientists and drug-discovery teams who already keep their compound libraries in DuckDB, Parquet or CSV and want molecular analytics without leaving SQL.
Every function is powered by RDKit (BSD-3-Clause), the open-source toolkit that underpins much of modern cheminformatics. RDKit is imported as an unmodified dependency and parses each SMILES (or SMARTS) string into a molecule before computing the requested property. The worker is deliberately robust: a malformed structure never raises or crashes a query — NULL input yields NULL output, and invalid (non-NULL) SMILES yields NULL, false, or no rows depending on the function. RDKit runs fully offline with no network access or model downloads, so results are deterministic and reproducible across runs. See the official RDKit documentation for the underlying algorithms.
What you can compute
The catalog spans the everyday cheminformatics workflow, grouped into navigation sections: structure validity, canonical identity (canonical SMILES plus InChI/InChIKey for deduplication and joins), numeric and count descriptors for property filtering and QSAR, circular fingerprints and Tanimoto similarity for search and clustering, SMARTS substructure matching for structural filters, and Lipinski drug-likeness screening. Everything operates on SMILES strings and runs inline over whole tables, so a column of compounds becomes a column of properties, identifiers, fingerprints or pass/fail flags in a single query.
Getting started
Attach the catalog with ATTACH 'chem' (TYPE vgi, LOCATION 'uv run chem_worker.py'), then call any function inline in a query. Pass a SMILES string to get a molecular formula (C9H8O4 for aspirin), a molecular weight (~180.16 g/mol), an InChIKey, a Tanimoto similarity score, or a Lipinski drug-likeness breakdown -- no export to Python required. New here? Browse the built-in example_molecules() table for ready-to-use SMILES and their pre-computed descriptors, then see each function's own example queries for ready-to-run SQL.
Source and issues: Query-farm/vgi-chem.
Catalog
Everything chem exposes once attached — read straight from the worker's
released build.
main 1 table · 19 functions
RDKit cheminformatics for SQL: descriptors, fingerprints, substructure, InChI.
Schema examples (12)
Check that a SMILES string parses to a real molecule.
SELECT chem.main.is_valid_smiles('CCO');
Canonicalize a SMILES so equivalent spellings compare equal.
SELECT chem.main.canonical_smiles('OCC');
Molecular formula of aspirin in Hill notation.
SELECT chem.main.mol_formula('CC(=O)OC1=CC=CC=C1C(=O)O');
Molecular weight of aspirin, rounded to two decimals.
SELECT ROUND(chem.main.mol_weight('CC(=O)OC1=CC=CC=C1C(=O)O'), 2);
8 more examples
InChIKey structure hash of aspirin for joins and lookup.
SELECT chem.main.inchikey('CC(=O)OC1=CC=CC=C1C(=O)O');
Tanimoto self-similarity is exactly 1.0.
SELECT chem.main.tanimoto('CCO', 'CCO');
Does phenol contain a benzene ring (SMARTS match)?
SELECT chem.main.substructure_match('c1ccccc1O', 'c1ccccc1');
Lipinski rule-of-five breakdown for aspirin, one row per rule.
SELECT rule, value, passes
FROM chem.main.lipinski('CC(=O)OC1=CC=CC=C1C(=O)O')
ORDER BY rule;
Similarity search: the three built-in molecules most similar to salicylic acid (OC(=O)c1ccccc1O) by Tanimoto -- aspirin 0.448, phenol 0.381, paracetamol 0.226
SELECT name,
round(chem.main.tanimoto(smiles, 'OC(=O)c1ccccc1O'), 3) AS similarity
FROM chem.main.example_molecules
ORDER BY similarity DESC, name
LIMIT 3;
Substructure filter over the registry: molecules carrying a carboxylic-acid group (SMARTS [CX3](=O)[OX2H1]) -- acetic acid, aspirin, ibuprofen, penicillin g -- lightest first
SELECT name, formula, round(mol_weight, 2) AS mol_weight
FROM chem.main.example_molecules
WHERE chem.main.substructure_match(smiles, '[CX3](=O)[OX2H1]')
ORDER BY mol_weight;
Identify unfamiliar SMILES spellings by joining on InChIKey to the built-in registry: C(O)C is ethanol, OC(=O)C acetic acid, Oc1ccccc1 phenol; NCCO (ethanolamine) is not in the registry, so its name is NULL
SELECT q.smiles AS query_smiles, m.name
FROM (VALUES ('OC(=O)C'), ('C(O)C'), ('Oc1ccccc1'), ('NCCO')) AS q(smiles)
LEFT JOIN chem.main.example_molecules AS m ON chem.main.inchikey(q.smiles) = chem.main.inchikey(m.smiles)
ORDER BY query_smiles;
All-pairs Tanimoto over the registry: its three most similar pairs -- paracetamol/phenol 0.292, benzene/phenol 0.273, aspirin/phenol 0.25
SELECT a.name AS molecule_a, b.name AS molecule_b,
round(chem.main.tanimoto(a.smiles, b.smiles), 3) AS similarity
FROM chem.main.example_molecules AS a
JOIN chem.main.example_molecules AS b ON a.name < b.name
ORDER BY similarity DESC, molecule_a, molecule_b
LIMIT 3;
example_molecules
Curated registry of well-known molecules with pre-computed descriptors (discovery table).
Browse the built-in molecules from lightest to heaviest.
SELECT name, formula, mol_weight
FROM chem.main.example_molecules
ORDER BY mol_weight;
How many example molecules are drug-like (pass all four Lipinski rules)?
SELECT count(*) AS drug_like
FROM chem.main.example_molecules
WHERE drug_like;
All-pairs Tanimoto over the registry: its three most similar pairs -- paracetamol/phenol 0.292, benzene/phenol 0.273, aspirin/phenol 0.25
SELECT a.name AS molecule_a, b.name AS molecule_b,
round(chem.main.tanimoto(a.smiles, b.smiles), 3) AS similarity
FROM chem.main.example_molecules AS a
JOIN chem.main.example_molecules AS b ON a.name < b.name
ORDER BY similarity DESC, molecule_a, molecule_b
LIMIT 3;
2 more examples
SELECT name, smiles, formula, mol_weight
FROM chem.main.example_molecules()
ORDER BY mol_weight;
SELECT name, logp
FROM chem.main.example_molecules()
WHERE drug_like
ORDER BY logp DESC;
canonical_smiles (smiles VARCHAR)
RDKit canonical SMILES form, or NULL if the input is invalid
Canonicalize ethanol -> 'CCO'
SELECT chem.main.canonical_smiles('OCC');
drug_like (smiles VARCHAR)
True if the molecule passes all four Lipinski rule-of-five criteria, NULL if invalid
Aspirin passes all four Lipinski rules -> true
SELECT chem.main.drug_like('CC(=O)OC1=CC=CC=C1C(=O)O');
exact_mass (smiles VARCHAR)
Monoisotopic (exact) mass, or NULL if invalid
Exact mass of ethanol
SELECT chem.main.exact_mass('CCO');
inchi (smiles VARCHAR)
Standard InChI string, or NULL if invalid
InChI of ethanol
SELECT chem.main.inchi('CCO');
inchikey (smiles VARCHAR)
Standard InChIKey (27-char hashed InChI), or NULL if invalid
InChIKey of aspirin -> 'BSYNRYMUTXBXSQ-UHFFFAOYSA-N'
SELECT chem.main.inchikey('CC(=O)OC1=CC=CC=C1C(=O)O');
Identify unfamiliar SMILES spellings by joining on InChIKey to the built-in registry: C(O)C is ethanol, OC(=O)C acetic acid, Oc1ccccc1 phenol; NCCO (ethanolamine) is not in the registry, so its name is NULL
SELECT q.smiles AS query_smiles, m.name
FROM (VALUES ('OC(=O)C'), ('C(O)C'), ('Oc1ccccc1'), ('NCCO')) AS q(smiles)
LEFT JOIN chem.main.example_molecules AS m ON chem.main.inchikey(q.smiles) = chem.main.inchikey(m.smiles)
ORDER BY query_smiles;
is_valid_smiles (smiles VARCHAR)
True if the SMILES string parses to a valid molecule (false if not, NULL if NULL)
A valid SMILES (ethanol)
SELECT chem.main.is_valid_smiles('CCO');
An invalid SMILES -> false
SELECT chem.main.is_valid_smiles('xyz');
logp (smiles VARCHAR)
Crippen MolLogP (octanol-water partition coefficient estimate), or NULL if invalid
logP of ethanol
SELECT chem.main.logp('CCO');
mol_formula (smiles VARCHAR)
Hill-system molecular formula, e.g. 'C9H8O4', or NULL if invalid
Molecular formula of aspirin
SELECT chem.main.mol_formula('CC(=O)OC1=CC=CC=C1C(=O)O');
mol_weight (smiles VARCHAR)
Average molecular weight in g/mol, or NULL if invalid
Molecular weight of aspirin (~180.16)
SELECT chem.main.mol_weight('CC(=O)OC1=CC=CC=C1C(=O)O');
morgan_fingerprint (smiles VARCHAR, radius BIGINT, nbits BIGINT) +1 overload
Morgan (ECFP-like) fingerprint as a hex bit-string (defaults radius=2, nbits=2048); NULL if invalid
morgan_fingerprint(smiles VARCHAR) → VARCHARmorgan_fingerprint(smiles VARCHAR, radius BIGINT, nbits BIGINT) → VARCHAR
Default Morgan fingerprint of ethanol (radius=2, nbits=2048)
SELECT chem.main.morgan_fingerprint('CCO');
Morgan fingerprint with explicit radius=3 and nbits=1024
SELECT chem.main.morgan_fingerprint('CCO', 3, 1024);
SELECT chem.main.morgan_fingerprint('CCO') AS fp;
1 more example
SELECT chem.main.morgan_fingerprint('CCO', 3, 1024) AS fp;
num_atoms (smiles VARCHAR)
Number of heavy (non-hydrogen) atoms, or NULL if invalid
Heavy-atom count of benzene (6)
SELECT chem.main.num_atoms('c1ccccc1');
num_h_acceptors (smiles VARCHAR)
Number of hydrogen-bond acceptors (Lipinski), or NULL if invalid
H-bond acceptors of ethanol
SELECT chem.main.num_h_acceptors('CCO');
num_h_donors (smiles VARCHAR)
Number of hydrogen-bond donors (Lipinski), or NULL if invalid
H-bond donors of ethanol (1)
SELECT chem.main.num_h_donors('CCO');
num_rings (smiles VARCHAR)
Number of rings (SSSR ring count), or NULL if invalid
Ring count of benzene (1)
SELECT chem.main.num_rings('c1ccccc1');
num_rotatable_bonds (smiles VARCHAR)
Number of rotatable bonds, or NULL if invalid
Rotatable bonds of aspirin
SELECT chem.main.num_rotatable_bonds('CC(=O)OC1=CC=CC=C1C(=O)O');
substructure_match (smiles VARCHAR, smarts VARCHAR)
True if the molecule contains the SMARTS pattern. NULL if the SMILES is invalid OR the SMARTS pattern is invalid.
Phenol contains a benzene ring -> true
SELECT chem.main.substructure_match('c1ccccc1O', 'c1ccccc1');
Substructure filter over the registry: molecules carrying a carboxylic-acid group (SMARTS [CX3](=O)[OX2H1]) -- acetic acid, aspirin, ibuprofen, penicillin g -- lightest first
SELECT name, formula, round(mol_weight, 2) AS mol_weight
FROM chem.main.example_molecules
WHERE chem.main.substructure_match(smiles, '[CX3](=O)[OX2H1]')
ORDER BY mol_weight;
tanimoto (smiles_a VARCHAR, smiles_b VARCHAR, radius BIGINT) +1 overload
Morgan/Tanimoto similarity in [0,1] (radius=2); NULL if either SMILES is invalid
tanimoto(smiles_a VARCHAR, smiles_b VARCHAR) → DOUBLEtanimoto(smiles_a VARCHAR, smiles_b VARCHAR, radius BIGINT) → DOUBLE
Self-similarity is 1.0
SELECT chem.main.tanimoto('CCO', 'CCO');
Similarity search: the three built-in molecules most similar to salicylic acid (OC(=O)c1ccccc1O) by Tanimoto -- aspirin 0.448, phenol 0.381, paracetamol 0.226
SELECT name,
round(chem.main.tanimoto(smiles, 'OC(=O)c1ccccc1O'), 3) AS similarity
FROM chem.main.example_molecules
ORDER BY similarity DESC, name
LIMIT 3;
Tanimoto similarity with radius=2
SELECT chem.main.tanimoto('CCO', 'CCC', 2);
tpsa (smiles VARCHAR)
Topological polar surface area (TPSA) in Angstrom^2, or NULL if invalid
TPSA of aspirin
SELECT chem.main.tpsa('CC(=O)OC1=CC=CC=C1C(=O)O');
lipinski (smiles VARCHAR)
Lipinski rule-of-five breakdown (MW<=500, logP<=5, HBD<=5, HBA<=10), one row per rule
Rule-of-five breakdown for aspirin, one row per rule
SELECT rule, value, passes
FROM chem.main.lipinski('CC(=O)OC1=CC=CC=C1C(=O)O')
ORDER BY rule;
Does aspirin pass all four rules?
SELECT bool_and(passes) AS drug_like
FROM chem.main.lipinski('CC(=O)OC1=CC=CC=C1C(=O)O');
Try these queries
Molecular formula of aspirin.
SELECT chem.main.mol_formula('CC(=O)OC1=CC=CC=C1C(=O)O') AS formula;
Uses mol_formula
Tanimoto self-similarity is exactly 1.0.
SELECT chem.main.tanimoto('CCO', 'CCO') AS sim;
Uses tanimoto
Check that a SMILES string parses to a real molecule.
SELECT chem.main.is_valid_smiles('CCO')
Uses is_valid_smiles
Canonicalize a SMILES so equivalent spellings compare equal.
SELECT chem.main.canonical_smiles('OCC')
Uses canonical_smiles
Molecular weight of aspirin, rounded to two decimals.
SELECT ROUND(chem.main.mol_weight('CC(=O)OC1=CC=CC=C1C(=O)O'), 2)
Uses mol_weight
InChIKey structure hash of aspirin for joins and lookup.
SELECT chem.main.inchikey('CC(=O)OC1=CC=CC=C1C(=O)O')
Uses inchikey
30 more examples in the Catalog, each listed under the table or function it uses.
Questions it can answer
Plain-English questions from the worker's agent test tasks. An AI agent with this catalog attached should answer each one with SQL.
- The SMILES for aspirin is CC(=O)OC1=CC=CC=C1C(=O)O. What is its molecular formula?
- Is the string 'xyz' a valid SMILES molecule? Return a boolean.
- Rewrite the SMILES 'OCC' into its canonical form (it denotes ethanol).
- What is the standard InChI string for ethanol, whose SMILES is CCO?
- Give the InChIKey identifier for aspirin, whose SMILES is CC(=O)OC1=CC=CC=C1C(=O)O.
- Compute the molecular weight of aspirin (SMILES CC(=O)OC1=CC=CC=C1C(=O)O), rounded to two decimal places.
Chem is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.
Related workers
Periodic table
Science & health
The periodic table, isotopes and chemical formula molar masses as offline DuckDB SQL
FHIR
Science & health
Query HL7 FHIR R4 REST servers from SQL: patients, observations, generic search, reads by id, and server capabilities
HL7
Science & health
Split, validate, and pull fields out of HL7 v2.x clinical messages such as ADT and ORU feeds