-
Notifications
You must be signed in to change notification settings - Fork 0
/
resultQuery.py
136 lines (126 loc) · 6.66 KB
/
resultQuery.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import json
import operator
import numpy as ns
'''
RESULT_FILES = ["output/urdmeMiningPartialWindow_4_1000_0_8.json", \
"output/urdmeMiningPartialWindow_4_1000_8_16.json", \
"output/urdmeMiningPartialWindow_4_1000_24_32.json", \
"output/urdmeMiningPartialWindow_4_1000_32_40.json", \
"output/urdmeMiningPartialWindow_4_1000_40_48.json", \
"output/urdmeMiningPartialWindow_4_1000_48_56.json", \
"output/urdmeMiningPartialWindow_4_1000_56_64.json", \
"output/urdmeMiningPartialWindow_4_1000_64_72.json", \
"output/urdmeMiningPartialWindow_4_1000_72_80.json", \
"output/urdmeMiningPartialWindow_4_1000_80_88.json", \
"output/urdmeMiningPartialWindow_4_1000_88_96.json", \
"output/urdmeMiningPartialWindow_4_1000_96_100.json" ]
'''
RESULT_FILES = ["output/urdmeMiningPartialWindow_SE_4_5_0_4.json", \
"output/urdmeMiningPartialWindow_SE_4_5_4_8.json", \
"output/urdmeMiningPartialWindow_SE_4_5_8_12.json", \
"output/urdmeMiningPartialWindow_SE_4_5_12_16.json", \
"output/urdmeMiningPartialWindow_SE_4_5_24_28.json" ]
resultList = []
'''
def filterData(inputData, matching):
result = []
for line in inputData:
if matching in str(line):
result.append(line)
'''
if __name__ == "__main__":
# read result file one by one
for _file in RESULT_FILES:
print(_file)
with open(_file) as _reader:
data = []
for line in _reader:
data.append(json.loads(line))
if len(data) > 1:
print("Unimplement Multiple outer rows query.")
quit()
else:
if len(data[0]) != 1:
for dataSet in data[0]:
content = dataSet
sortedResult = sorted(content, key=lambda x: x['_value'], reverse=True)
print("First")
print(sortedResult[0])
print(sortedResult[1])
print(sortedResult[2])
print(sortedResult[3])
print(sortedResult[4])
print("Last")
print(sortedResult[-5])
print(sortedResult[-4])
print(sortedResult[-3])
print(sortedResult[-2])
print(sortedResult[-1])
# for bandValue in reversed(range(9)):
for bandValue in range(9):
filteredResult = filter(lambda x: True if ('protein_B'+str(bandValue)) in str(x['_key']) else False, content)
sortedFilterResult = sorted(filteredResult, key=lambda x: x['_value'], reverse=True)
print("B" + str(bandValue) + " First")
if len(sortedFilterResult) >= 5:
print(sortedFilterResult[0])
print(sortedFilterResult[1])
print(sortedFilterResult[2])
print(sortedFilterResult[3])
print(sortedFilterResult[4])
print("B" + str(bandValue) + " Last")
print(sortedFilterResult[-5])
print(sortedFilterResult[-4])
print(sortedFilterResult[-3])
print(sortedFilterResult[-2])
print(sortedFilterResult[-1])
elif len(sortedFilterResult) == 0:
print("Empty Result")
continue
else:
for j in range(len(sortedFilterResult)):
print(sortedFilterResult[j])
for j in reversed(range(1,len(sortedFilterResult))):
print(sortedFilterResult[j * -1])
print("Band Set--------")
print("Window Set---------------------")
else:
content = data[0][0]
sortedResult = sorted(content, key=lambda x: x['_value'], reverse=True)
print("First")
print(sortedResult[0])
print(sortedResult[1])
print(sortedResult[2])
print(sortedResult[3])
print(sortedResult[4])
print("Last")
print(sortedResult[-5])
print(sortedResult[-4])
print(sortedResult[-3])
print(sortedResult[-2])
print(sortedResult[-1])
# for bandValue in reversed(range(9)):
for bandValue in range(9):
filteredResult = filter(lambda x: True if ('protein_B'+str(bandValue)) in str(x['_key']) else False, content)
sortedFilterResult = sorted(filteredResult, key=lambda x: x['_value'], reverse=True)
print("B" + str(bandValue) + " First")
if len(sortedFilterResult) >= 5:
print(sortedFilterResult[0])
print(sortedFilterResult[1])
print(sortedFilterResult[2])
print(sortedFilterResult[3])
print(sortedFilterResult[4])
print("B" + str(bandValue) + " Last")
print(sortedFilterResult[-5])
print(sortedFilterResult[-4])
print(sortedFilterResult[-3])
print(sortedFilterResult[-2])
print(sortedFilterResult[-1])
elif len(sortedFilterResult) == 0:
print("Empty Result")
continue
else:
for j in range(len(sortedFilterResult)):
print(sortedFilterResult[j])
for j in reversed(range(1,len(sortedFilterResult))):
print(sortedFilterResult[j * -1])
print('Frame Set-----------------------------------------------------------------------------------')