$npx -y skills add QSong-github/DrugClaw --skill drugmechdbQuery the DrugMechDB drug mechanism-of-action database. Use whenever the user asks about drug mechanisms, drug-to-disease paths, biological targets of a drug, or wants to look up any biomedical entity (drug name, protein, disease, DrugBank ID, MESH ID, UniProt ID, GO term, etc.)
| 1 | # DrugMechDB Query Skill |
| 2 | |
| 3 | Search drug mechanism-of-action paths by entity name or ID. Each path is a directed graph: Drug → (intermediates) → Disease, with typed nodes and labeled edges. |
| 4 | |
| 5 | ## Data |
| 6 | |
| 7 | - **Source**: `indication_paths.json` |
| 8 | - **Path**: `resources_metadata/drug_mechanism/DRUGMECHDB/indication_paths.json` |
| 9 | - **Records**: ~4846 mechanism paths, ~32k relationships |
| 10 | |
| 11 | ## Entity auto-detection |
| 12 | |
| 13 | | Input pattern | Detected as | Example | |
| 14 | |---|---|---| |
| 15 | | `DB:DB00619` | DrugBank ID | exact on node/graph IDs | |
| 16 | | `MESH:D015464` | MESH ID | exact on node/graph IDs | |
| 17 | | `UniProt:P00519` | UniProt protein | exact on node IDs | |
| 18 | | `GO:0006915` | GO term | exact on node IDs | |
| 19 | | `CHEBI:*`, `HP:*`, `UBERON:*`, `CL:*`, `reactome:*`, `InterPro:*`, `PR:*`, `taxonomy:*` | respective types | exact on node IDs | |
| 20 | | anything else | free text | substring match on drug/disease/node names | |
| 21 | |
| 22 | ## API |
| 23 | |
| 24 | | Function | Signature | Returns | |
| 25 | |---|---|---| |
| 26 | | `load(path)` | path to JSON | `list[dict]` — full database | |
| 27 | | `build_index(db)` | loaded db | `(by_id, by_name, by_drug, by_disease)` dicts for O(1) lookup | |
| 28 | | `search(db, entity, index=None)` | single query string | `list[dict]` — matching paths | |
| 29 | | `search_batch(db, entities, index=None)` | list of query strings | `dict[str, list[dict]]` | |
| 30 | | `summarize(paths, entity)` | search results | compact multi-line text | |
| 31 | | `to_json(paths)` | search results | list of flat dicts (id, drug, disease, nodes, links) | |
| 32 | |
| 33 | ## Node types (14) |
| 34 | |
| 35 | BiologicalProcess, Cell, CellularComponent, ChemicalSubstance, Disease, Drug, GeneFamily, GrossAnatomicalStructure, MacromolecularComplex, MolecularActivity, OrganismTaxon, Pathway, PhenotypicFeature, Protein |
| 36 | |
| 37 | ## Quick usage |
| 38 | |
| 39 | ```python |
| 40 | import drugmechdb_query as dq |
| 41 | |
| 42 | db = dq.load() # uses default DATA_PATH |
| 43 | idx = dq.build_index(db) # optional, recommended for repeated queries |
| 44 | |
| 45 | # Single query — by name or ID |
| 46 | paths = dq.search(db, "imatinib", idx) |
| 47 | paths = dq.search(db, "UniProt:P00519", idx) |
| 48 | paths = dq.search(db, "MESH:D003920", idx) |
| 49 | print(dq.summarize(paths, "imatinib")) |
| 50 | |
| 51 | # Batch query |
| 52 | results = dq.search_batch(db, ["metformin", "MESH:D003920", "asthma"], idx) |
| 53 | for entity, paths in results.items(): |
| 54 | print(dq.summarize(paths, entity)) |
| 55 | |
| 56 | # JSON export |
| 57 | print(dq.to_json(paths)) |
| 58 | ``` |
| 59 | |
| 60 | ## Output structure per path |
| 61 | |
| 62 | ``` |
| 63 | graph: { _id, drug, disease, drugbank, drug_mesh, disease_mesh } |
| 64 | nodes: [{ id, label, name }, ...] |
| 65 | links: [{ source, target, key }, ...] |
| 66 | ``` |
| 67 | |
| 68 | `key` examples: `decreases activity of`, `causes`, `positively regulates`, `treats`, `increases expression of`, etc. (66 relation types total). |