$npx -y skills add QSong-github/DrugClaw --skill drugbankQuery a locally downloaded DrugBank database. Use whenever the user asks about drug information, drug targets, drug-drug interactions, drug categories, or wants to look up any entity (DrugBank ID, drug name, CAS number, synonym) in DrugBank.
| 1 | # DrugBank Local Query Skill |
| 2 | |
| 3 | Search local DrugBank data by any entity. Auto-detects query type: |
| 4 | |
| 5 | | Input Pattern | Detected As | Match Logic | |
| 6 | |---|---|---| |
| 7 | | `DB00945` | DrugBank ID | exact on `drugbank_id` | |
| 8 | | anything else | free text | substring on `name`, `synonyms`, `cas_number` | |
| 9 | |
| 10 | ## Data |
| 11 | |
| 12 | - **Base dir**: `resources_metadata/drug_knowledgebase/DrugBank/` |
| 13 | - **Files**: |
| 14 | - `full database.xml` — rich fields: description, targets, interactions, categories, synonyms, groups |
| 15 | - `drugbank vocabulary.csv` — lightweight: DrugBank ID, name, CAS, synonyms |
| 16 | - **Auto-select**: prefers XML if present, falls back to vocabulary CSV |
| 17 | |
| 18 | ## API |
| 19 | |
| 20 | | Function | Input | Returns | |
| 21 | |---|---|---| |
| 22 | | `load(path)` | file path (XML or TSV/CSV, auto-detected) | `list[dict]` | |
| 23 | | `search(data, entity)` | single entity string | `list[dict]` | |
| 24 | | `search_batch(data, entities)` | list or comma-separated string | `dict[str, list[dict]]` | |
| 25 | | `summarize(hits, entity)` | hit list + label | compact text | |
| 26 | | `to_json(hits)` | hit list | JSON string | |
| 27 | |
| 28 | ## Usage |
| 29 | |
| 30 | ```python |
| 31 | from 07_DrugBank import load, search, search_batch, summarize, to_json |
| 32 | |
| 33 | data = load() # auto-selects XML or CSV |
| 34 | |
| 35 | # single query |
| 36 | hits = search(data, "aspirin") |
| 37 | print(summarize(hits, "aspirin")) |
| 38 | |
| 39 | # batch query |
| 40 | results = search_batch(data, ["metformin", "DB00316", "ibuprofen"]) |
| 41 | for entity, hits in results.items(): |
| 42 | print(summarize(hits, entity)) |
| 43 | |
| 44 | # JSON output |
| 45 | print(to_json(hits[:1])) |
| 46 | ``` |
| 47 | |
| 48 | See `if __name__ == "__main__"` block in `07_DrugBank.py` for runnable examples. |