$npx -y skills add QSong-github/DrugClaw --skill sematyp> Drug-Disease Association Knowledge Graph from literature mining + TTD > Category: Drug-centric | Type: KG | Subcategory: Drug-Disease Associations > Access: Local files (downloaded from GitHub)
| 1 | # 66 · SemaTyP |
| 2 | |
| 3 | > Drug-Disease Association Knowledge Graph from literature mining + TTD |
| 4 | > **Category:** Drug-centric | **Type:** KG | **Subcategory:** Drug-Disease Associations |
| 5 | > **Access:** Local files (downloaded from GitHub) |
| 6 | |
| 7 | | Resource | URL | |
| 8 | |----------|-----| |
| 9 | | GitHub | https://github.com/ShengtianSang/SemaTyP | |
| 10 | | Paper | https://link.springer.com/article/10.1186/s12859-018-2167-5 | |
| 11 | |
| 12 | --- |
| 13 | |
| 14 | ## What it provides |
| 15 | |
| 16 | SemaTyP combines two data sources into a knowledge graph for drug discovery / repositioning: |
| 17 | |
| 18 | - **SemMedDB predications** (`data/SemmedDB/predications.txt`): subject–predicate–object triples with UMLS semantic types, extracted from PubMed abstracts (full version: ~39M triples). |
| 19 | - **TTD curated associations** (`data/TTD/`): drug-disease and target-disease links from Therapeutic Target Database (2016), with ICD-9/ICD-10 codes. |
| 20 | - **Processed associations** (`data/processed/`): pre-computed drug→disease, disease→drug, disease→target mappings. |
| 21 | |
| 22 | ### Data schema |
| 23 | |
| 24 | | File | Format | Columns | |
| 25 | |------|--------|---------| |
| 26 | | `data/SemmedDB/predications.txt` | TSV | subject, object, context, predicate, subj_semtype, obj_semtype | |
| 27 | | `data/TTD/drug-disease_TTD2016.txt` | TSV | TTDDRUGID, drug_name, indication, ICD9, ICD10 | |
| 28 | | `data/TTD/target-disease_TTD2016.txt` | TSV | target_id, target_name, disease, ICD9, ICD10 | |
| 29 | | `data/processed/drug_disease` | TSV | drug, disease, ... | |
| 30 | | `data/processed/disease_drug` | TSV | disease, drug, ... | |
| 31 | | `data/processed/disease_targets` | TSV | disease, target, ... | |
| 32 | |
| 33 | --- |
| 34 | |
| 35 | ## Setup |
| 36 | |
| 37 | Data must be downloaded locally first: |
| 38 | |
| 39 | ```bash |
| 40 | git clone https://github.com/ShengtianSang/SemaTyP.git |
| 41 | ``` |
| 42 | |
| 43 | Then set the data path (default points to your HiPerGator location): |
| 44 | |
| 45 | ```python |
| 46 | # Option 1: environment variable |
| 47 | export SEMATYP_DATA_DIR="/path/to/SemaTyP-main" |
| 48 | |
| 49 | # Option 2: edit DATA_DIR in 66_SemaTyP.py directly |
| 50 | ``` |
| 51 | |
| 52 | **Note:** The GitHub repo only contains a 100-line sample of `predications.txt`. The full 39M-triple file must be downloaded separately per the repo README. |
| 53 | |
| 54 | --- |
| 55 | |
| 56 | ## Quick start |
| 57 | |
| 58 | ```python |
| 59 | from 66_SemaTyP import query |
| 60 | |
| 61 | # Single entity (drug, disease, target, or any biomedical concept) |
| 62 | results = query("aspirin") |
| 63 | |
| 64 | # Multiple entities |
| 65 | results = query(["metformin", "diabetes", "CYP2D6"]) |
| 66 | |
| 67 | # Specific data source only |
| 68 | results = query("imatinib", fields="predications", pred_limit=10) |
| 69 | results = query("Schizophrenia", fields="ttd") |
| 70 | results = query("cancer", fields="processed") |
| 71 | ``` |
| 72 | |
| 73 | --- |
| 74 | |
| 75 | ## `query()` interface |
| 76 | |
| 77 | ``` |
| 78 | query(entities, fields="all", pred_limit=50) -> list[dict] |
| 79 | ``` |
| 80 | |
| 81 | | Parameter | Type | Description | |
| 82 | |-----------|------|-------------| |
| 83 | | `entities` | `str \| list[str]` | Entity name(s), case-insensitive | |
| 84 | | `fields` | `str` | `"all"` — everything; `"predications"` / `"ttd"` / `"processed"` | |
| 85 | | `pred_limit` | `int` | Max predication triples per entity (default 50) | |
| 86 | |
| 87 | ### Return structure (`fields="all"`) |
| 88 | |
| 89 | ```json |
| 90 | [ |
| 91 | { |
| 92 | "query": "aspirin", |
| 93 | "predications": [ |
| 94 | {"subject": "aspirin", "object": "pain", "predicate": "TREATS", |
| 95 | "context": "...", "subj_type": "phsu", "obj_type": "sosy"} |
| 96 | ], |
| 97 | "predication_count": 42, |
| 98 | "ttd_drug_disease": [ |
| 99 | {"ttdid": "DAP000XXX", "drug": "Aspirin", "disease": "Pain", |
| 100 | "icd9": "...", "icd10": "..."} |
| 101 | ], |
| 102 | "ttd_target_disease": [], |
| 103 | "processed_drug_disease": [...], |
| 104 | "processed_disease_drug": [...], |
| 105 | "processed_disease_targets": [...] |
| 106 | } |
| 107 | ] |
| 108 | ``` |
| 109 | |
| 110 | --- |
| 111 | |
| 112 | ## Lower-level functions |
| 113 | |
| 114 | | Function | Input | Output | Description | |
| 115 | |----------|-------|--------|-------------| |
| 116 | | `get_predications(entity, limit=50)` | entity name | `list[dict]` | SemMedDB KG triples | |
| 117 | | `get_ttd_drug_disease(entity)` | drug or disease | `list[dict]` | TTD drug-disease associations | |
| 118 | | `get_ttd_target_disease(entity)` | target or disease | `list[dict]` | TTD target-disease associations | |
| 119 | | `get_processed_drug_disease(entity)` | entity name | `list[dict]` | Processed drug→disease | |
| 120 | | `get_processed_disease_drug(entity)` | entity name | `list[dict]` | Processed disease→drug | |
| 121 | | `get_processed_disease_targets(entity)` | entity name | `list[dict]` | Processed disease→target | |
| 122 | |
| 123 | --- |
| 124 | |
| 125 | ## Notes |
| 126 | |
| 127 | - All lookups are **case-insensitive** (indexed by lowercased entity names). |
| 128 | - Data is **lazy-loaded**: first `query()` call triggers a one-time index build (may take seconds for large predications file). |
| 129 | - UMLS semantic type codes in predications: `phsu` = pharmaceutical substance, `dsyn` = disease/syndrome, `gngm` = gene/genome, `sosy` = sign/symptom, `podg` = patient/group, etc. |
| 130 | - The GitHub sample `predications.txt` has only 100 lines; for full coverage, download the complete file per the repo README instructions. |