-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathDISMIR_cal_risk.py
More file actions
28 lines (22 loc) · 956 Bytes
/
DISMIR_cal_risk.py
File metadata and controls
28 lines (22 loc) · 956 Bytes
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
import numpy as np
import os
def file_name(file_dir):
for root, dirs, files in os.walk(file_dir):
return files
if __name__ == '__main__':
store_dir = '/data/jqli/HCC/12_22_test_program/store_dir/' # directory where the predicted d-scores are stored
output = open('/data/jqli/HCC/12_22_test_program/value_result.txt', 'w') # file to store predicted risk
files = file_name(store_dir)
# cal risk by maximize posterior probability
gaps = np.linspace(0, 1, 1001)
score = np.vstack((gaps, 1 - gaps))
score = score.T
for file in files:
likelihood_1 = np.loadtxt(store_dir + file)
likelihood_2 = 1 - likelihood_1
likelihood = np.vstack((likelihood_1, likelihood_2))
val = np.log10(np.dot(score, likelihood))
sum = np.sum(val, axis=1)
result = gaps[np.argmax(sum)]
output.write(file + '\t' + str(result) + '\n')
output.close()