MeSH Tree Data

import json
from collections import Counter

MeSH Tree

This MeSH tree data is available at National Library of Medicine (NLM) website. MeSH descriptors are organized in 16 categories: category A for anatomic terms, category B for organisms, C for diseases, D for drugs and chemicals, etc. Each category is further divided into subcategories. Within each subcategory, descriptors are arrayed hierarchically from most general to most specific in up to thirteen hierarchical levels. Because of the branching structure of the hierarchies, these lists are sometimes referred to as "trees". Each MeSH descriptor appears in at least one place in the trees, and may appear in as many additional places as may be appropriate. Those who use MeSH should find the most specific MeSH descriptor that is available to represent each concept of interest.Source

meshtree_file = "./input/mtrees2020.bin" 
Tree = []
id2name = {}
name2id = {}
with open(meshtree_file, "r") as ftree:
    for line in ftree:
        term_tree = line.strip().split(";")
        cur_term = term_tree[0]
        cur_tree = term_tree[1]

        id2name.update({cur_tree:cur_term})                        
        name2id.update({cur_term:cur_tree})
        Tree.append({'id':cur_tree ,'name':cur_term})
CVDTree = []
for name,ID in name2id.items():
    if ID[0:3] == 'C14':
            CVDTree.append({"name": name, "ID":ID})
len(list(CVDTree))
204
CVD = pd.DataFrame(CVDTree)
CVD = CVD.set_index('name')
CVD = CVD.sort_values("ID",ascending =True)
CVD.head(50)
ID
name
Cardiovascular Diseases C14
Cardiovascular Infections C14.260
Syphilis, Cardiovascular C14.260.500
Tuberculosis, Cardiovascular C14.260.750
Heart Diseases C14.280
Carcinoid Heart Disease C14.280.104
Cardiac Conduction System Disease C14.280.123
Pre-Excitation Syndromes C14.280.123.750
Lown-Ganong-Levine Syndrome C14.280.123.750.560
Pre-Excitation, Mahaim-Type C14.280.123.750.770
Cardiac Tamponade C14.280.155
Cardiomyopathies C14.280.238
Cardiomyopathy, Dilated C14.280.238.070
Cardiomyopathy, Restrictive C14.280.238.160
Chagas Cardiomyopathy C14.280.238.190
Endocardial Fibroelastosis C14.280.238.281
Endomyocardial Fibrosis C14.280.238.406
Myocarditis C14.280.238.625
Endocarditis C14.280.282
Endocarditis, Bacterial C14.280.282.407
Endocarditis, Subacute Bacterial C14.280.282.407.407
Endocarditis, Non-Infective C14.280.282.703
Heart Arrest C14.280.383
Out-of-Hospital Cardiac Arrest C14.280.383.610
Heart Failure C14.280.434
Cardio-Renal Syndrome C14.280.434.156
Heart Failure, Diastolic C14.280.434.611
Heart Failure, Systolic C14.280.434.676
Heart Neoplasms C14.280.459
Heart Rupture C14.280.470
Heart Rupture, Post-Infarction C14.280.470.475
Ventricular Septal Rupture C14.280.470.475.900
Heart Valve Diseases C14.280.484
Aortic Valve Insufficiency C14.280.484.095
Cardiomyopathy, Hypertrophic C14.280.484.150.070.160
Heart Valve Prolapse C14.280.484.400
Aortic Valve Prolapse C14.280.484.400.100
Mitral Valve Prolapse C14.280.484.400.500
Tricuspid Valve Prolapse C14.280.484.400.875
Mitral Valve Insufficiency C14.280.484.461
Mitral Valve Stenosis C14.280.484.517
Pulmonary Valve Insufficiency C14.280.484.660
Tricuspid Valve Insufficiency C14.280.484.856
Tricuspid Valve Stenosis C14.280.484.911
Pericardial Effusion C14.280.695
Pericarditis C14.280.720
Pericarditis, Constrictive C14.280.720.595
Pericarditis, Tuberculous C14.280.720.801
Pneumopericardium C14.280.763
Pulmonary Heart Disease C14.280.832
CVD.to_csv("cvd.csv")

View CVD MeSH Tree Online