$npx -y skills add QSong-github/DrugClaw --skill ttdQuery the Therapeutic Target Database (TTD) for drug-target-disease interaction data. Use this skill when the user asks about therapeutic targets, drugs, diseases, or their relationships — including target-drug mappings, clinical status of drugs, disease indications, UniProt/gene
| 1 | # TTD — Therapeutic Target Database |
| 2 | |
| 3 | **Source:** https://ttd.idrblab.cn/ |
| 4 | **Paper:** https://academic.oup.com/nar/article/52/D1/D1465/7275004 |
| 5 | **Data dir:** `resources_metadata/dti/TTD` |
| 6 | |
| 7 | ## Data files (4 required) |
| 8 | |
| 9 | | File | Content | |
| 10 | |------|---------| |
| 11 | | `P1-01-TTD_target_download.txt` | Target info: name, UniProt, gene, type, function, disease indication, pathway | |
| 12 | | `P2-01-TTD_target_drug.txt` | Target ↔ Drug links with clinical status (Approved / Phase I–III / Experimental) | |
| 13 | | `P1-06-Target_disease.txt` | Target ↔ Disease associations | |
| 14 | | `P1-07-Drug_disease.txt` | Drug ↔ Disease associations | |
| 15 | |
| 16 | **File formats:** |
| 17 | - `P1-01`, `P2-01` — block format: blank-line separated records, each line `<ID>\t<KEY>\t<VALUE>` |
| 18 | - `P1-06`, `P1-07` — TSV with header row |
| 19 | |
| 20 | --- |
| 21 | |
| 22 | ## Query API |
| 23 | |
| 24 | ### `query(entities, entity_type="auto", data_dir=DATA_DIR)` |
| 25 | |
| 26 | Returns a **list of dicts**, one per queried entity. |
| 27 | |
| 28 | | Parameter | Type | Description | |
| 29 | |-----------|------|-------------| |
| 30 | | `entities` | `str` or `list[str]` | One or more entity names / IDs | |
| 31 | | `entity_type` | `"auto"` / `"target"` / `"drug"` / `"disease"` | Restrict search; `"auto"` tries target → drug → disease | |
| 32 | | `data_dir` | `str` | Path to TTD data directory | |
| 33 | |
| 34 | ### `query_json(entities, ...)` → `str` |
| 35 | |
| 36 | Same as `query()` but returns a JSON string. Use for LLM consumption. |
| 37 | |
| 38 | --- |
| 39 | |
| 40 | ## Input formats accepted |
| 41 | |
| 42 | | Input | Examples | |
| 43 | |-------|---------| |
| 44 | | Gene / protein name | `"EGFR"`, `"TP53"`, `"BCR-ABL"` | |
| 45 | | Drug name | `"Imatinib"`, `"Gefitinib"`, `"Osimertinib"` | |
| 46 | | Disease name | `"Lung cancer"`, `"Diabetes mellitus"` (partial match supported) | |
| 47 | | TTD Target ID | `"TTDTARGET00001"` | |
| 48 | | TTD Drug ID | `"D0Y4GH"` | |
| 49 | |
| 50 | Matching is **case-insensitive**; disease names support **partial matching**. |
| 51 | |
| 52 | --- |
| 53 | |
| 54 | ## Output structure |
| 55 | |
| 56 | ### Target result |
| 57 | ```json |
| 58 | { |
| 59 | "query": "EGFR", |
| 60 | "entity_type": "target", |
| 61 | "ttd_id": "TTDTARGET00001", |
| 62 | "name": "Epidermal growth factor receptor", |
| 63 | "uniprot": "P00533", |
| 64 | "gene": "EGFR", |
| 65 | "target_type": "Successful target", |
| 66 | "function": "Receptor tyrosine kinase...", |
| 67 | "disease": "Non-small-cell lung cancer [ICD-11: 2C25]", |
| 68 | "pathway": "EGFR signaling pathway", |
| 69 | "drugs": [ |
| 70 | {"drug_id": "D0Y4GH", "drug_name": "Gefitinib", "clinical_status": "Approved"}, |
| 71 | {"drug_id": "D08VGC", "drug_name": "Erlotinib", "clinical_status": "Approved"} |
| 72 | ] |
| 73 | } |
| 74 | ``` |
| 75 | |
| 76 | ### Drug result |
| 77 | ```json |
| 78 | { |
| 79 | "query": "Imatinib", |
| 80 | "entity_type": "drug", |
| 81 | "drug_id": "D0IQX1", |
| 82 | "drug_name": "Imatinib", |
| 83 | "targets": [ |
| 84 | {"ttd_target_id": "TTDTARGET00002", "target_name": "BCR-ABL", |
| 85 | "clinical_status": "Approved", "drug_id": "D0IQX1"} |
| 86 | ], |
| 87 | "diseases": ["Chronic myelogenous leukemia", "Gastrointestinal stromal tumor"] |
| 88 | } |
| 89 | ``` |
| 90 | |
| 91 | ### Disease result |
| 92 | ```json |
| 93 | { |
| 94 | "query": "Lung cancer", |
| 95 | "entity_type": "disease", |
| 96 | "disease_name": "non-small-cell lung cancer", |
| 97 | "targets": [ |
| 98 | {"ttd_target_id": "TTDTARGET00001", "target_name": "EGFR"} |
| 99 | ], |
| 100 | "drugs": ["Gefitinib", "Osimertinib", "Erlotinib"] |
| 101 | } |
| 102 | ``` |
| 103 | |
| 104 | ### Not found |
| 105 | ```json |
| 106 | {"query": "XYZ123", "entity_type": "not_found", "message": "No match found in TTD."} |
| 107 | ``` |
| 108 | |
| 109 | --- |
| 110 | |
| 111 | ## Usage examples |
| 112 | |
| 113 | ```python |
| 114 | from 17_TTD import query, query_json |
| 115 | |
| 116 | # Single entity |
| 117 | results = query("EGFR") |
| 118 | |
| 119 | # Multiple entities (mixed types — auto-detected) |
| 120 | results = query(["EGFR", "Imatinib", "Lung cancer"]) |
| 121 | |
| 122 | # Restrict to drug search only |
| 123 | results = query(["Gefitinib", "Osimertinib"], entity_type="drug") |
| 124 | |
| 125 | # JSON string output (for LLM) |
| 126 | print(query_json("TP53")) |
| 127 | ``` |
| 128 | |
| 129 | CLI (demo runs with EGFR / Imatinib / Lung cancer if no args): |
| 130 | ```bash |
| 131 | python 17_TTD.py EGFR Imatinib "Lung cancer" |
| 132 | python 17_TTD.py TTDTARGET00001 |
| 133 | ``` |
| 134 | |
| 135 | --- |
| 136 | |
| 137 | ## Notes |
| 138 | |
| 139 | - **`entity_type="auto"`** stops at the first match type per entity (target → drug → disease). Use explicit type to resolve ambiguity. |
| 140 | - **`drugs` in target results** lists all TTD-linked drugs; filter `clinical_status == "Approved"` for marketed drugs. |
| 141 | - **Disease partial matching** — `"lung cancer"` will match `"non-small-cell lung cancer"`. The first candidate is returned; use `entity_type="disease"` with a more specific name if needed. |
| 142 | - **Multi-value fields** (e.g. multiple pathways for one target) are returned as lists. |