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