Skip to content

Commit

Permalink
UMLS Source Vocabularies (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
phlobo authored Dec 6, 2023
1 parent 0533891 commit c1b5a49
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
8 changes: 8 additions & 0 deletions examples/conf/meddra_german.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: meddra_german

dict:
custom:
umls_meta_path: ${oc.env:UMLS_HOME}/2023AA/META
sabs:
- MDR
- MDRGER
25 changes: 25 additions & 0 deletions examples/dicts/umls_source.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from tqdm.auto import tqdm
from xmen.umls import read_umls_file_headers


def get_concept_details(cfg):
mrconso = "MRCONSO.RRF"
concept_details = {}
meta_path = cfg.dict.custom.umls_meta_path
sabs = cfg.dict.custom.sabs

headers = read_umls_file_headers(meta_path, mrconso)

with open(f"{meta_path}/{mrconso}") as fin:
for line in tqdm(fin.readlines()):
splits = line.strip().split("|")
assert len(headers) == len(splits)
concept = dict(zip(headers, splits))
if concept["SAB"] in sabs:
sid = concept["SDUI"]
name = concept["STR"]
if sid in concept_details:
concept_details[sid]["aliases"].append(name)
else:
concept_details[sid] = {"concept_id": sid, "canonical_name": name, "types": [], "aliases": []}
return concept_details

0 comments on commit c1b5a49

Please sign in to comment.