$npx -y skills add QSong-github/DrugClaw --skill chebiQuery the ChEBI (Chemical Entities of Biological Interest) database. Use whenever the user asks about small molecule identifiers, chemical ontology roles, molecular formulae, SMILES, InChI, synonyms, or cross-references for biologically relevant chemical compounds via ChEBI.
| 1 | # ChEBI Query Skill |
| 2 | |
| 3 | Search the ChEBI 2.0 REST API by any entity. Auto-detects input type: |
| 4 | |
| 5 | | Input Pattern | Detected As | Action | |
| 6 | |---|---|---| |
| 7 | | `CHEBI:15422` / `chebi:15422` | ChEBI ID (prefixed) | full entity lookup via `/compound/{id}/` | |
| 8 | | `27732` (pure digits ≤7) | ChEBI ID (numeric) | full entity lookup via `/compound/{id}/` | |
| 9 | | anything else | free text | Elasticsearch search via `/es_search/?term=...` | |
| 10 | |
| 11 | ## API |
| 12 | |
| 13 | | Function | Input | Returns | |
| 14 | |---|---|---| |
| 15 | | `search(query, max_results=25)` | single entity string | `list[dict]` | |
| 16 | | `search_batch(queries, max_results=25)` | list of entity strings | `dict[str, list[dict]]` | |
| 17 | | `summarize(results, label)` | result list + label | compact one-line-per-hit text | |
| 18 | | `to_json(results)` | result list | `list[dict]` (JSON-serialisable) | |
| 19 | |
| 20 | Lower-level helpers (called internally): |
| 21 | |
| 22 | | Function | Purpose | |
| 23 | |---|---| |
| 24 | | `search_chebi(query, max_results)` | keyword search via `GET /es_search/?term=...&size=N` | |
| 25 | | `get_entity(chebi_id)` | full entity via `GET /compound/CHEBI:{id}/` | |
| 26 | | `get_entities_batch(chebi_ids)` | batch lookup via `GET /compounds/?chebi_ids=id1,id2,...` | |
| 27 | |
| 28 | `search_batch()` automatically uses the efficient batch endpoint when all |
| 29 | queries are ChEBI IDs; otherwise it iterates with a 0.3 s delay. |
| 30 | |
| 31 | ## Usage |
| 32 | |
| 33 | See `if __name__ == "__main__"` block in `64_ChEBI.py` for runnable examples |
| 34 | covering: single ID lookup, name search, formula search, batch ID search, |
| 35 | mixed batch search, and JSON output. |
| 36 | |
| 37 | ## Key Fields Returned |
| 38 | |
| 39 | **Top-level**: `chebi_accession`, `name`, `ascii_name`, `definition`, `stars` |
| 40 | (curation quality; 3 = fully curated), `secondary_ids`, `is_released`. |
| 41 | |
| 42 | **chemical_data** (nested dict): `formula`, `charge`, `mass`, |
| 43 | `monoisotopic_mass`. |
| 44 | |
| 45 | **default_structure** (nested dict): `smiles`, `standard_inchi`, |
| 46 | `standard_inchi_key`, `wurcs`. |
| 47 | |
| 48 | **names** (nested dict by type): keys like `IUPAC NAME`, `SYNONYM`, |
| 49 | `BRAND NAME`, `UNIPROT NAME`; each value is a list of name objects. |
| 50 | |
| 51 | **ontology_relations**: `incoming_relations` and `outgoing_relations`, each a |
| 52 | list of `{init_id, init_name, relation_type, final_id, final_name}`. |
| 53 | |
| 54 | **database_accessions** (nested dict by type): `CAS`, `MANUAL_X_REF`, |
| 55 | `REGISTRY_NUMBER`, `CITATION`; cross-refs to DrugBank, KEGG, HMDB, PubChem, |
| 56 | PDBeChem, Wikipedia, etc. |
| 57 | |
| 58 | **roles_classification**: list of role dicts with `chebi_accession`, `name`, |
| 59 | `definition`, `biological_role` (bool), `application` (bool), |
| 60 | `chemical_role` (bool). |
| 61 | |
| 62 | ## Data Source |
| 63 | |
| 64 | - **Database**: ChEBI 2.0 (EMBL-EBI), >195,000 molecular entities |
| 65 | - **API base**: `https://www.ebi.ac.uk/chebi/backend/api/public/` |
| 66 | - **Docs**: <https://www.ebi.ac.uk/chebi/backend/api/docs/> |
| 67 | - **License**: CC BY 4.0 |
| 68 | - **Citation**: Bento et al. *Nucleic Acids Res.* 2025, 54(D1), D1768–D1774. |