PubChem Database
Overview
PubChem is the world's largest freely available chemical database — 119M+ compounds, 322M+
substances, and 295M+ bioactivities per the PubChem 2025 update (Kim et al., NAR 2025). Query chemical structures by name, CID, or SMILES, retrieve molecular
properties, perform similarity and substructure searches, and access bioactivity data using
the PUG-REST API and PubChemPy.
When to Use This Skill
This skill should be used when:
- Searching for chemical compounds by name, structure (SMILES/InChI), or molecular formula
- Retrieving molecular properties (MW, LogP, TPSA, hydrogen bonding descriptors)
- Performing similarity searches to find structurally related compounds
- Conducting substructure searches for specific chemical motifs
- Accessing bioactivity data from screening assays
- Converting between chemical identifier formats (CID, SMILES, InChI)
- Batch processing multiple compounds for drug-likeness screening or property analysis
Does NOT Trigger
| Scenario |
Use Instead |
| Measured binding affinities (Ki, Kd, IC50) of ligands against a protein target, e.g. by UniProt accession |
alterlab-bindingdb |
| Curated bioactivity across assays, medicinal-chemistry series, drug mechanisms |
alterlab-chembl |
| Computing descriptors or fingerprints on your own molecules locally |
alterlab-rdkit |
| Human metabolite concentrations, biofluids, biomarker evidence |
alterlab-hmdb |
| Drug pharmacology, interactions, and approval details |
alterlab-drugbank |
| Purchasable compound libraries for virtual screening |
alterlab-zinc-db |
Hand-off rule. When the request matches a row above, open your answer by naming that skill by its exact id (for example alterlab-chembl) and saying in one line why it fits better, then stop applying this skill's procedure. Name it even when you also need to ask for missing input. If only part of the request is out of scope, name the skill for that part and do only the in-scope part. A brief general pointer is fine; the named skill does the work.
Core Capabilities
PubChem access is organized into nine capability areas. Copy-ready snippets for each live in
references/capabilities.md.
- Chemical structure search — by name, CID, SMILES, InChI, or molecular formula.
- Property retrieval — single, specific-list, or batch molecular properties.
- Similarity search — Tanimoto similarity with threshold/MaxRecords.
- Substructure search — find compounds containing a structural motif.
- Format conversion — CID/SMILES/InChI/InChIKey and structure-file download.
- Structure visualization — 2D PNG images via PubChemPy or direct URL.
- Synonym retrieval — all known names for a compound.
- Bioactivity data access — assay summaries via PUG-REST and helper script.
- Comprehensive annotations — full PUG-View records (properties, drug info, safety, toxicity).
Core Workflow
The canonical entry point resolves an identifier to a compound, then reads properties:
import pubchempy as pcp
compound = pcp.get_compounds('aspirin', 'name')[0]
print(compound.cid, compound.molecular_formula, compound.molecular_weight)
print(compound.smiles, compound.xlogp, compound.tpsa)
Prefer CIDs for repeated queries (more efficient than names/structures). Similarity and
substructure searches run asynchronously and may take 15-30 seconds; PubChemPy polls
automatically. PUG-REST answers HTTP 503 (PUGREST.ServerBusy) both when you exceed the
limits and when PubChem itself is overloaded — read the X-Throttling-Control response
header and back off rather than retrying immediately. See references/best_practices.md
for rate limits and error handling.
Installation Requirements
No install step: run Python through uv, which resolves the packages for that run
(1.0.5 = current SMILES property names; checked 2026-10-23):
uv run --with 'pubchempy>=1.0.5' python props.py # PubChemPy access
uv run --with 'pubchempy>=1.0.5' python scripts/compound_search.py ... # helper script
uv run --with requests python scripts/bioactivity_query.py ... # direct API / bioassays
uv run --with 'pubchempy>=1.0.5' --with pandas python analysis.py # optional pandas
Plain curl against PUG-REST needs nothing (.../compound/name/aspirin/property/MolecularWeight,XLogP,TPSA,HBondDonorCount,HBondAcceptorCount/JSON).
SMILES property naming (PubChem changed this in 2025): the PUG-REST CanonicalSMILES
and IsomericSMILES properties are deprecated. Use SMILES (full SMILES with
stereo/isotope info, replaces IsomericSMILES) and ConnectivitySMILES (connectivity-only,
replaces CanonicalSMILES). In PubChemPy 1.0.5 the matching Compound attributes are
compound.smiles and compound.connectivity_smiles (the old canonical_smiles /
isomeric_smiles attributes still resolve but are deprecated).
Helper Scripts
This skill ships two Python helper scripts under scripts/:
scripts/compound_search.py — search, property retrieval, similarity/substructure search,
synonyms, batch search, and structure download.
scripts/bioactivity_query.py — bioassay summaries, target identification, target-based
compound search, and PUG-View annotations.
Full function inventories and usage are in references/helper_scripts.md.
Reference Index
references/api_reference.md — Complete PUG-REST endpoint docs, full molecular property
list, asynchronous request handling, PubChemPy API, PUG-View API, and official doc links.
references/capabilities.md — Copy-ready code for all nine capability areas.
references/workflows.md — Five end-to-end workflows (identifier conversion, drug-likeness
screening, similar-candidate search, batch property comparison, substructure virtual screening).
references/helper_scripts.md — Function inventory and usage for the two helper scripts.
references/best_practices.md — Rate limits, best practices, error handling, troubleshooting,
and additional resources.
1---2name: alterlab-pubchem3description: Query PubChem via the PUG-REST API and PubChemPy across 119M+ compounds, searching by name, CID, or SMILES and retrieving molecular properties, bioactivity, and similarity/substructure matches. Use when looking up a chemical compound, converting names/SMILES to CIDs, fetching physicochemical properties, or running cheminformatics structure searches. Part of the AlterLab Academic Skills suite.4license: MIT5allowed-tools: Read WebFetch Bash(curl:*) Bash(python:*) Bash(uv run:*)6compatibility: Keyless PubChem PUG-REST API (≤5 requests/s, ≤400/min); PubChemPy >= 1.0.5 optional for Python (no authentication required)7metadata:8 source: https://skillmd.com/skills/alterlab-ieu/alterlab-pubchem9 skill-author: AlterLab10 version: "1.1.0"11 last_updated: "2026-10-23"12---1314# PubChem Database1516## Overview1718PubChem is the world's largest freely available chemical database — 119M+ compounds, 322M+19substances, and 295M+ bioactivities per the PubChem 2025 update (Kim et al., NAR 2025). Query chemical structures by name, CID, or SMILES, retrieve molecular20properties, perform similarity and substructure searches, and access bioactivity data using21the PUG-REST API and PubChemPy.2223## When to Use This Skill2425This skill should be used when:26- Searching for chemical compounds by name, structure (SMILES/InChI), or molecular formula27- Retrieving molecular properties (MW, LogP, TPSA, hydrogen bonding descriptors)28- Performing similarity searches to find structurally related compounds29- Conducting substructure searches for specific chemical motifs30- Accessing bioactivity data from screening assays31- Converting between chemical identifier formats (CID, SMILES, InChI)32- Batch processing multiple compounds for drug-likeness screening or property analysis3334### Does NOT Trigger3536| Scenario | Use Instead |37|----------|-------------|38| Measured binding affinities (Ki, Kd, IC50) of ligands against a protein target, e.g. by UniProt accession | `alterlab-bindingdb` |39| Curated bioactivity across assays, medicinal-chemistry series, drug mechanisms | `alterlab-chembl` |40| Computing descriptors or fingerprints on your own molecules locally | `alterlab-rdkit` |41| Human metabolite concentrations, biofluids, biomarker evidence | `alterlab-hmdb` |42| Drug pharmacology, interactions, and approval details | `alterlab-drugbank` |43| Purchasable compound libraries for virtual screening | `alterlab-zinc-db` |4445**Hand-off rule.** When the request matches a row above, open your answer by naming that skill by its exact id (for example `alterlab-chembl`) and saying in one line why it fits better, then stop applying this skill's procedure. Name it even when you also need to ask for missing input. If only part of the request is out of scope, name the skill for that part and do only the in-scope part. A brief general pointer is fine; the named skill does the work.4647## Core Capabilities4849PubChem access is organized into nine capability areas. Copy-ready snippets for each live in50`references/capabilities.md`.51521. **Chemical structure search** — by name, CID, SMILES, InChI, or molecular formula.532. **Property retrieval** — single, specific-list, or batch molecular properties.543. **Similarity search** — Tanimoto similarity with threshold/MaxRecords.554. **Substructure search** — find compounds containing a structural motif.565. **Format conversion** — CID/SMILES/InChI/InChIKey and structure-file download.576. **Structure visualization** — 2D PNG images via PubChemPy or direct URL.587. **Synonym retrieval** — all known names for a compound.598. **Bioactivity data access** — assay summaries via PUG-REST and helper script.609. **Comprehensive annotations** — full PUG-View records (properties, drug info, safety, toxicity).6162## Core Workflow6364The canonical entry point resolves an identifier to a compound, then reads properties:6566```python67import pubchempy as pcp6869compound = pcp.get_compounds('aspirin', 'name')[0]70print(compound.cid, compound.molecular_formula, compound.molecular_weight)71print(compound.smiles, compound.xlogp, compound.tpsa)72```7374Prefer CIDs for repeated queries (more efficient than names/structures). Similarity and75substructure searches run asynchronously and may take 15-30 seconds; PubChemPy polls76automatically. PUG-REST answers HTTP 503 (`PUGREST.ServerBusy`) both when you exceed the77limits and when PubChem itself is overloaded — read the `X-Throttling-Control` response78header and back off rather than retrying immediately. See `references/best_practices.md`79for rate limits and error handling.8081## Installation Requirements8283No install step: run Python through uv, which resolves the packages for that run84(1.0.5 = current SMILES property names; checked 2026-10-23):8586```bash87uv run --with 'pubchempy>=1.0.5' python props.py # PubChemPy access88uv run --with 'pubchempy>=1.0.5' python scripts/compound_search.py ... # helper script89uv run --with requests python scripts/bioactivity_query.py ... # direct API / bioassays90uv run --with 'pubchempy>=1.0.5' --with pandas python analysis.py # optional pandas91```9293Plain `curl` against PUG-REST needs nothing (`.../compound/name/aspirin/property/MolecularWeight,XLogP,TPSA,HBondDonorCount,HBondAcceptorCount/JSON`).9495**SMILES property naming (PubChem changed this in 2025):** the PUG-REST `CanonicalSMILES`96and `IsomericSMILES` properties are deprecated. Use `SMILES` (full SMILES with97stereo/isotope info, replaces `IsomericSMILES`) and `ConnectivitySMILES` (connectivity-only,98replaces `CanonicalSMILES`). In PubChemPy 1.0.5 the matching Compound attributes are99`compound.smiles` and `compound.connectivity_smiles` (the old `canonical_smiles` /100`isomeric_smiles` attributes still resolve but are deprecated).101102## Helper Scripts103104This skill ships two Python helper scripts under `scripts/`:105106- `scripts/compound_search.py` — search, property retrieval, similarity/substructure search,107 synonyms, batch search, and structure download.108- `scripts/bioactivity_query.py` — bioassay summaries, target identification, target-based109 compound search, and PUG-View annotations.110111Full function inventories and usage are in `references/helper_scripts.md`.112113## Reference Index114115- **`references/api_reference.md`** — Complete PUG-REST endpoint docs, full molecular property116 list, asynchronous request handling, PubChemPy API, PUG-View API, and official doc links.117- **`references/capabilities.md`** — Copy-ready code for all nine capability areas.118- **`references/workflows.md`** — Five end-to-end workflows (identifier conversion, drug-likeness119 screening, similar-candidate search, batch property comparison, substructure virtual screening).120- **`references/helper_scripts.md`** — Function inventory and usage for the two helper scripts.121- **`references/best_practices.md`** — Rate limits, best practices, error handling, troubleshooting,122 and additional resources.