-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrun_textcube.py
75 lines (55 loc) · 1.75 KB
/
run_textcube.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import json
import sys
import time
from caseolap.textcube import *
'''
input data directories
'''
input_file_meshtree = "./input/mtrees2018.bin"
input_file_mesh2pmid = "./data/mesh2pmid.json"
input_file_root_cat = './input/categories.txt'
input_file_textcube_config = './config/textcube_config.json'
'''
output data directories
'''
output_file_textcube_pmid2cell = './data/textcube_pmid2cell.json'
output_file_textcube_cell2pmid = './data/textcube_cell2pmid.json'
output_file_textcube_stat = './data/textcube_stat.txt'
outputfile_MeSHterms_percat = './data/meshterms_per_cat.json'
logFilePath = "./log/textcube_log.txt"
'''
Start Construction of Text - Cube
'''
if __name__ == '__main__':
logfile = open(logFilePath, "w")
with open(input_file_textcube_config, "r") as f_config:
cell_names = json.load(f_config)
print("there are ", len(cell_names), "cells in the text cube!")
"""
This class build TextCube
"""
TC = TextCube(cell_names)
"""
Collect all decendent MeSH terms for each categories
"""
TC.descendent_MeSH(input_file_root_cat,\
input_file_meshtree,\
outputfile_MeSHterms_percat,\
logfile)
"""
Collect all PMID falling under cells of TextCube
"""
TC.cell2pmids_mapping(input_file_mesh2pmid,\
output_file_textcube_cell2pmid,\
logfile)
"""
Collect all categories assigned to each PMIDS
"""
TC.pmid2cell_mapping(output_file_textcube_pmid2cell,\
logfile)
"""
Collect statistics of Textcube
"""
TC.cell_statistics(output_file_textcube_stat,\
logfile)
logfile.close()