-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilter_util_no_flex.py
91 lines (88 loc) · 3.02 KB
/
filter_util_no_flex.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
from __future__ import division
def import_ptms(ptms_outfile):
chain_id = []
resid = []
resname = []
goto_atom = []
short_name = []
full_name = []
cc = []
d_ref = []
d_mid = []
d_new_in_ref = []
d_new_diff = []
d_far = []
ratio = []
score = []
model_id = []
d_min = []
b_factor = []
imported_ptms = (chain_id, resid, resname, goto_atom, short_name, full_name, cc,
d_ref, d_mid, d_new_in_ref, d_new_diff, d_far, ratio, score, model_id, d_min, b_factor)
with open(ptms_outfile, "r") as out:
for line in out.readlines():
items = line.split()
try:
for array, coerce_lambda in zip(imported_ptms,
(lambda x: x, lambda x: int(x), lambda x: x, lambda x: x, lambda x: x, lambda x: x,
lambda x: float(x), lambda x: float(x), lambda x: float(x), lambda x: float(x),
lambda x: float(x), lambda x: float(x), lambda x: float(x), lambda x: float(x),
lambda x: int(x), lambda x: float(x), lambda x: float(x))):
array.append(coerce_lambda(items.pop(0)))
except ValueError:
raise Exception("line could not be parsed: %s" % line)
return imported_ptms
def import_ptms_with_predictions(ptms_outfile):
chain_id = []
resid = []
resname = []
goto_atom = []
short_name = []
full_name = []
cc = []
d_ref = []
d_mid = []
d_new_in_ref = []
d_new_diff = []
d_far = []
ratio = []
score = []
model_id = []
d_min = []
b_factor = []
predictions = []
probabilities = []
imported_ptms = (chain_id, resid, resname, goto_atom, short_name, full_name, cc,
d_ref, d_mid, d_new_in_ref, d_new_diff, d_far, ratio, score, model_id, d_min, b_factor,
predictions, probabilities)
with open(ptms_outfile, "r") as out:
for line in out.readlines():
items = line.split()
for array, coerce_lambda in zip(imported_ptms,
(lambda x: x, lambda x: int(x), lambda x: x, lambda x: x, lambda x: x, lambda x: x,
lambda x: float(x), lambda x: float(x), lambda x: float(x), lambda x: float(x),
lambda x: float(x), lambda x: float(x), lambda x: float(x), lambda x: float(x),
lambda x: int(x), lambda x: float(x), lambda x: float(x),
lambda x: int(x), lambda x: float(x))):
array.append(coerce_lambda(items.pop(0)))
return imported_ptms
def import_synthetic_ptms(synthetic_ptms_outfile):
chain_id = []
resid = []
resname = []
goto_atom = []
short_name = []
full_name = []
model_id = []
d_min = []
b_factor = []
imported_synthetic_ptms = (chain_id, resid, resname, goto_atom, short_name, full_name,
model_id, d_min, b_factor)
with open(synthetic_ptms_outfile, "r") as out:
for line in out.readlines():
items = line.split()
for array, coerce_lambda in zip(imported_synthetic_ptms,
(lambda x: x, lambda x: int(x), lambda x: x, lambda x: x, lambda x: x, lambda x: x,
lambda x: int(x), lambda x: float(x), lambda x: None if x == 'None' else float(x))):
array.append(coerce_lambda(items.pop(0)))
return imported_synthetic_ptms