This repository has been archived by the owner on Jan 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build_risk_scores.py
66 lines (51 loc) · 1.78 KB
/
build_risk_scores.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
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Fri Apr 12 16:03:17 2019
@author: danielbean
"""
import ScoreBuilder as sb
import yaml, json
with open('config.yml') as f:
conf = yaml.load(f)
builder = sb.ScoreBuilder()
tm = sb.TestMapper({}) #empty configuration for test mapper
builder.add_mapper('Test', tm)
#HPO
hpom = sb.HPOMapper(conf['HPO'])
builder.add_mapper('HPO', hpom)
hpo_umls = sb.HPOUMLSMapper(conf['HPO'])
builder.add_mapper('HPO_UMLS', hpo_umls)
#UMLS
umls = sb.UMLSMapper(conf['UMLS'])
builder.add_mapper('UMLS', umls)
#ICD10
icd = sb.ICD10_UMLSMapper(conf['ICD10'])
builder.add_mapper('ICD10_UMLS', icd)
#build the chadsvasc score definition
definition = builder.build('input_files/chadsvasc_definition.csv')
print "CHA2DS2-VASc"
for comp in definition:
print "%s: %s concepts" % (comp, len(definition[comp]['concepts']))
print "\n"
with open('output/chadsvasc.generated.definition.txt','w') as f:
json.dump(definition, f)
#build the hasbled score definition
definition = builder.build('input_files/hasbled_definition.csv', 'input_files/manual terms to delete.csv')
print "HAS-BLED"
for comp in definition:
print "%s: %s concepts" % (comp, len(definition[comp]['concepts']))
print "\n"
with open('output/hasbled.generated.definition.txt','w') as f:
json.dump(definition, f)
#build the frailty score
#this score definition is already granular so we do not do any mapping to child terms
#the ICD10_UMLS mapper only supports depth==0
definition = builder.build('input_files/hfrs_definition.csv')
print "HFRS"
total_concepts = 0
for comp in definition:
total_concepts += len(definition[comp]['concepts'])
print "Mapped to %s concepts" % total_concepts
with open('output/hfrs.generated.definition.txt','w') as f:
json.dump(definition, f)