@@ -28,36 +28,38 @@ class ProcessProtein(object):
28
28
:type cutoff: float
29
29
"""
30
30
31
- def __init__ (self , niter , prot , cutoff , gskip ):
31
+ def __init__ (self , niter , prot , cutoff , gskip , taus = None , bars = None ):
32
32
self .residues = {}
33
33
self .niter = niter
34
34
self .prot = prot
35
35
self .cutoff = cutoff
36
36
self .gskip = gskip
37
+ self .taus = taus
38
+ self .bars = bars
37
39
38
40
def __getitem__ (self , item ):
39
41
return getattr (self , item )
40
42
41
43
def _single_residue (self , adir , process = False ):
42
44
if os .path .exists (f'{ adir } /gibbs_{ self .niter } .pkl' ):
45
+ result = f'{ adir } /gibbs_{ self .niter } .pkl'
43
46
try :
44
47
result = f'{ adir } /gibbs_{ self .niter } .pkl'
45
48
g = Gibbs ().load (result )
46
49
if process :
47
50
g .gskip = self .gskip
48
51
g .process_gibbs ()
52
+ tau = g .estimate_tau ()
49
53
except ValueError :
50
54
result = None
55
+ tau = [0 , 0 , 0 ]
51
56
else :
52
- print (f'results for { adir } do not exist' )
53
57
result = None
54
- return result
58
+ tau = [ 0 , 0 , 0 ]
55
59
56
- def _single_result (self , adir ):
57
- result = self ._single_residue (adir )
58
60
residue = adir .split ('/' )[- 1 ]
59
- self .residues [ residue ] = result
60
-
61
+ setattr ( self .residues , 'f{ residue}' , result )
62
+ setattr ( self . residues . residue , 'tau' , tau )
61
63
62
64
def reprocess (self , nproc = 1 ):
63
65
"""Rerun processing and clustering on :class:`Gibbs` data.
@@ -83,30 +85,6 @@ def reprocess(self, nproc=1):
83
85
except KeyboardInterrupt :
84
86
pass
85
87
86
- def collect_results (self , nproc = 1 ):
87
- """Collect names of results for each residue in the `basicrta-{cutoff}`
88
- directory in a dictionary stored in :attr:`ProcessProtein.results`.
89
- """
90
- from glob import glob
91
-
92
- dirs = np .array (glob (f'basicrta-{ self .cutoff } /?[0-9]*' ))
93
- sorted_inds = (np .array ([int (adir .split ('/' )[- 1 ][1 :]) for adir in dirs ])
94
- .argsort ())
95
- dirs = dirs [sorted_inds ]
96
- with (Pool (nproc , initializer = tqdm .set_lock ,
97
- initargs = (Lock (),)) as p ):
98
- try :
99
- for _ in tqdm (p .imap (self ._single_result , dirs ),
100
- total = len (dirs ), position = 0 ,
101
- desc = 'overall progress' ):
102
- pass
103
- #for adir in tqdm(dirs, desc='collecting results'):
104
- # result = self._single_residue(adir)
105
- # residue = adir.split('/')[-1]
106
- # self.residues[residue] = result
107
- except KeyboardInterrupt :
108
- pass
109
-
110
88
def get_taus (self ):
111
89
r"""Get :math:`\tau` and 95\% confidence interval bounds for the slowest
112
90
process for each residue.
@@ -120,17 +98,20 @@ def get_taus(self):
120
98
121
99
taus = []
122
100
for res in tqdm (self .residues , total = len (self .residues )):
123
- if self .residues [res ] is None :
124
- result = [0 , 0 , 0 ]
125
- else :
126
- try :
127
- gib = Gibbs ().load (self .residues [res ])
128
- result = gib .estimate_tau ()
129
- except AttributeError :
130
- result = [0 , 0 , 0 ]
131
- taus .append (result )
101
+ taus .append (res .tau )
102
+ #if self.residues[res] is None:
103
+ # result = [0, 0, 0]
104
+ #else:
105
+ # try:
106
+ # gib = Gibbs().load(self.residues[res])
107
+ # result = gib.estimate_tau()
108
+ # except AttributeError:
109
+ # result = [0, 0, 0]
110
+ #taus.append(result)
132
111
taus = np .array (taus )
133
112
bars = get_bars (taus )
113
+ setattr (self , 'taus' , taus [:, 1 ])
114
+ setattr (self , 'bars' , bars )
134
115
return taus [:, 1 ], bars
135
116
136
117
def write_data (self , fname = 'tausout' ):
0 commit comments