-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathHistProc.lua
161 lines (138 loc) · 3.79 KB
/
HistProc.lua
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
-- Processing histograms and remove outliers
print(" >> This script remove outliers according to histogram data << ")
-- Load input
dofile("DiffGeoStat.lua")
-- Set treshold to be consider outliers
pc = 1.0 -- limit to be consider an outlier, i. e., 1% population
cutoff = math.floor(models*pc/100.0) -- cutoff of total structures
print(" > pc = ", pc, "%")
print(" > Histogram threshold = " .. cutoff, "conformations")
-- create output file ssv
print ("@ > Writing DiffGeoSpec.ssv")
out_file = "DiffGeoSpec.ssv"
local f = assert(io.open(out_file, "w"))
-- create table residue_numbers
local residue_numbers = {}
-- fill table
for k in pairs(hist) do
table.insert(residue_numbers, k)
end
table.sort(residue_numbers)
--
for i = 1, #residue_numbers do
local res, data = residue_numbers[i], hist[residue_numbers[i]]
-- Process curvature --
-- create keys
local keys = {}
-- insert keys
for k in pairs(data.curvature) do
table.insert(keys, k)
end
table.sort(keys)
-- Check left side
local curvature = data.curvature[keys[1]]
local left = curvature.pos
for j = 1, #keys do
local k, curvature = keys[j], data.curvature[keys[j]]
if curvature.value > cutoff then
left = curvature.pos
break
end
end
-- Check right side
local curvature = data.curvature[keys[#keys]]
local right = curvature.pos
for j = #keys, 1, -1 do
local k, curvature = keys[j], data.curvature[keys[j]]
if curvature.value > cutoff then
right = curvature.pos
break
end
end
-- Curvature interval magnitude inside the cutoff values
local curvature_len = right - left
-- Process torsion
local keys = {}
for k in pairs(data.torsion) do
table.insert(keys, k)
end
table.sort(keys)
-- Check left side
local torsion = data.torsion[keys[1]]
local left = torsion.pos
for j = 1, #keys do
local k, torsion = keys[j], data.torsion[keys[j]]
if torsion.value > cutoff then
left = torsion.pos
break
end
end
-- Check right side
local torsion = data.torsion[keys[#keys]]
local right = torsion.pos
for j = #keys, 1, -1 do
local k, torsion = keys[j], data.torsion[keys[j]]
if torsion.value > cutoff then
right = torsion.pos
break
end
end
local torsion_len = right - left
-- Process writhing
local keys = {}
for k in pairs(data.writhing) do
table.insert(keys, k)
end
table.sort(keys)
-- Check left side
local writhing = data.writhing[keys[1]]
local left = writhing.pos
for j = 1, #keys do
local k, writhing = keys[j], data.writhing[keys[j]]
if writhing.value > cutoff then
left = writhing.pos
break
end
end
-- Check right side
local writhing = data.writhing[keys[#keys]]
local right = writhing.pos
for j = #keys, 1, -1 do
local k, writhing = keys[j], data.writhing[keys[j]]
if writhing.value > cutoff then
right = writhing.pos
break
end
end
local writhing_len = right - left
-- Process arc length
local keys = {}
for k in pairs(data.arc_length) do
table.insert(keys, k)
end
table.sort(keys)
-- Check left side
local arc_length = data.arc_length[keys[1]]
local left = arc_length.pos
for j = 1, #keys do
local k, arc_length = keys[j], data.arc_length[keys[j]]
if arc_length.value > cutoff then
left = arc_length.pos
break
end
end
-- Check right side
local arc_length = data.arc_length[keys[#keys]]
local right = arc_length.pos
for j = #keys, 1, -1 do
local k, arc_length = keys[j], data.arc_length[keys[j]]
if arc_length.value > cutoff then
right = arc_length.pos
break
end
end
local arc_length_len = right - left
f:write(string.format("%i %6.3f %6.3f %6.3f %6.3f\n", res, curvature_len, torsion_len, writhing_len, arc_length_len))
end
print(":: DONE ::")
f:close()