Source: https://github.com/aipoch/medical-research-skills
When to Use
- You need to search for chemical compounds by name, CID, SMILES, InChI, or molecular formula.
- You want to retrieve physicochemical properties (e.g., molecular weight, LogP, TPSA, H-bond donors/acceptors).
- You need to perform structure-based searches, such as similarity or substructure queries.
- You want to obtain bioactivity data (e.g., assay summaries, target information) for a given compound.
- You are building an automated cheminformatics or drug discovery workflow that requires programmatic access to PubChem.
Key Features
Flexible compound search by name, CID, SMILES, InChI, or formula.
Property retrieval via PubChem PUG-REST and PubChemPy (e.g., MW, LogP, Canonical SMILES).
Structure search:
- Similarity search
- Substructure search
Bioactivity retrieval linked to PubChem BioAssay records.
Rate-limit aware implementation (respects PubChem’s limit of max 5 requests/sec).
Python function interface for seamless integration into scientific pipelines.
Dependencies
Install the required Python packages:
uv pip install pubchempy requests
pubchempy (version: not pinned)
requests (version: not pinned)
Example Usage
Primary module:
1) Get compound properties
python -c "from scripts.pubchem_ops import get_properties; print(get_properties(query_value='Aspirin', query_type='name'))"
Or in Python:
from scripts.pubchem_ops import get_properties
result = get_properties(query_value="Aspirin", query_type="name")
print(result)
2) Structure search (similarity)
python -c "from scripts.pubchem_ops import structure_search; print(structure_search(query_value='CC(=O)OC1=CC=CC=C1C(=O)O', search_type='similarity'))"
Or in Python:
from scripts.pubchem_ops import structure_search
smiles = "CC(=O)OC1=CC=CC=C1C(=O)O"
result = structure_search(query_value=smiles, search_type="similarity")
print(result)
3) Get bioactivity data
python -c "from scripts.pubchem_ops import get_bioactivity; print(get_bioactivity(cid=2244))"
Or in Python:
from scripts.pubchem_ops import get_bioactivity
result = get_bioactivity(cid=2244)
print(result)
Implementation Details
Primary script: scripts/pubchem_ops.py
Data sources / endpoints:
- Compound & properties:
pubchem.ncbi.nlm.nih.gov/rest/pug
- Bioactivity: PubChem BioAssay endpoints
- Python wrapper:
PubChemPy
Supported operations:
get_properties: retrieve physicochemical properties by name/CID/SMILES/InChI/formula.
structure_search: perform similarity or substructure search.
get_bioactivity: retrieve assay and bioactivity-related data by CID.
Input constraints:
query_type must match supported types (e.g., name, cid, smiles, inchi, formula).
search_type must be similarity or substructure.
Error handling:
- Returns structured error or
None if compound is not found.
- Handles PubChem rate limits (≤ 5 requests/sec).
Troubleshooting considerations:
- Ensure network access to
pubchem.ncbi.nlm.nih.gov.
- Verify query format (e.g., valid SMILES or InChI) if results are empty.
Additional reference:
- API documentation pointers:
references/api_reference.md
1---2name: pubchem-database-skill3description: Programmatic access to the PubChem database (via PUG-REST API and PubChemPy) for searching chemical compounds, retrieving physicochemical properties, performing structure similarity/substructure searches, and obtaining bioactivity data.4license: MIT5---6> **Source**: [https://github.com/aipoch/medical-research-skills](https://github.com/aipoch/medical-research-skills)
7
8## When to Use
9
10* You need to **search for chemical compounds** by name, CID, SMILES, InChI, or molecular formula.
11* You want to **retrieve physicochemical properties** (e.g., molecular weight, LogP, TPSA, H-bond donors/acceptors).
12* You need to **perform structure-based searches**, such as similarity or substructure queries.
13* You want to **obtain bioactivity data** (e.g., assay summaries, target information) for a given compound.
14* You are building an automated cheminformatics or drug discovery workflow that requires **programmatic access to PubChem**.
15
16## Key Features
17
18* **Flexible compound search** by name, CID, SMILES, InChI, or formula.
19* **Property retrieval** via PubChem PUG-REST and PubChemPy (e.g., MW, LogP, Canonical SMILES).
20* **Structure search**:
21
22 * Similarity search
23 * Substructure search
24* **Bioactivity retrieval** linked to PubChem BioAssay records.
25* **Rate-limit aware implementation** (respects PubChem’s limit of max 5 requests/sec).
26* **Python function interface** for seamless integration into scientific pipelines.
27
28## Dependencies
29
30Install the required Python packages:
31
32```bash
33uv pip install pubchempy requests
34```
35
36* `pubchempy` (version: not pinned)
37* `requests` (version: not pinned)
38
39## Example Usage
40
41Primary module:
42
43* `scripts/pubchem_ops.py`
44
45### 1) Get compound properties
46
47```bash
48python -c "from scripts.pubchem_ops import get_properties; print(get_properties(query_value='Aspirin', query_type='name'))"
49```
50
51Or in Python:
52
53```python
54from scripts.pubchem_ops import get_properties
55
56result = get_properties(query_value="Aspirin", query_type="name")
57print(result)
58```
59
60### 2) Structure search (similarity)
61
62```bash
63python -c "from scripts.pubchem_ops import structure_search; print(structure_search(query_value='CC(=O)OC1=CC=CC=C1C(=O)O', search_type='similarity'))"
64```
65
66Or in Python:
67
68```python
69from scripts.pubchem_ops import structure_search
70
71smiles = "CC(=O)OC1=CC=CC=C1C(=O)O"
72result = structure_search(query_value=smiles, search_type="similarity")
73print(result)
74```
75
76### 3) Get bioactivity data
77
78```bash
79python -c "from scripts.pubchem_ops import get_bioactivity; print(get_bioactivity(cid=2244))"
80```
81
82Or in Python:
83
84```python
85from scripts.pubchem_ops import get_bioactivity
86
87result = get_bioactivity(cid=2244)
88print(result)
89```
90
91## Implementation Details
92
93* **Primary script**: `scripts/pubchem_ops.py`
94* **Data sources / endpoints**:
95
96 * Compound & properties: `pubchem.ncbi.nlm.nih.gov/rest/pug`
97 * Bioactivity: PubChem BioAssay endpoints
98 * Python wrapper: `PubChemPy`
99* **Supported operations**:
100
101 * `get_properties`: retrieve physicochemical properties by name/CID/SMILES/InChI/formula.
102 * `structure_search`: perform similarity or substructure search.
103 * `get_bioactivity`: retrieve assay and bioactivity-related data by CID.
104* **Input constraints**:
105
106 * `query_type` must match supported types (e.g., `name`, `cid`, `smiles`, `inchi`, `formula`).
107 * `search_type` must be `similarity` or `substructure`.
108* **Error handling**:
109
110 * Returns structured error or `None` if compound is not found.
111 * Handles PubChem rate limits (≤ 5 requests/sec).
112* **Troubleshooting considerations**:
113
114 * Ensure network access to `pubchem.ncbi.nlm.nih.gov`.
115 * Verify query format (e.g., valid SMILES or InChI) if results are empty.
116* **Additional reference**:
117
118 * API documentation pointers: `references/api_reference.md`
119