@@ -85,7 +85,7 @@ def reprocess(self, nproc=1):
85
85
except KeyboardInterrupt :
86
86
pass
87
87
88
- def get_taus (self ):
88
+ def get_taus (self , nproc = 1 ):
89
89
r"""Get :math:`\tau` and 95\% confidence interval bounds for the slowest
90
90
process for each residue.
91
91
@@ -96,10 +96,14 @@ def get_taus(self):
96
96
"""
97
97
from basicrta .util import get_bars
98
98
99
+ dirs = np .array (glob (f'basicrta-{ self .cutoff } /?[0-9]*' ))
100
+ sorted_inds = (np .array ([int (adir .split ('/' )[- 1 ][1 :]) for adir in dirs ])
101
+ .argsort ())
102
+ dirs = dirs [sorted_inds ]
99
103
with (Pool (nproc , initializer = tqdm .set_lock ,
100
104
initargs = (Lock (),)) as p ):
101
105
try :
102
- for _ in tqdm (p .istarmap (self ._single_residue , inarr ),
106
+ for _ in tqdm (p .imap (self ._single_residue , dirs ),
103
107
total = len (dirs ), position = 0 ,
104
108
desc = 'overall progress' ):
105
109
pass
@@ -109,15 +113,7 @@ def get_taus(self):
109
113
taus = []
110
114
for res in tqdm (self .residues , total = len (self .residues )):
111
115
taus .append (res .tau )
112
- #if self.residues[res] is None:
113
- # result = [0, 0, 0]
114
- #else:
115
- # try:
116
- # gib = Gibbs().load(self.residues[res])
117
- # result = gib.estimate_tau()
118
- # except AttributeError:
119
- # result = [0, 0, 0]
120
- #taus.append(result)
116
+
121
117
taus = np .array (taus )
122
118
bars = get_bars (taus )
123
119
setattr (self , 'taus' , taus [:, 1 ])
@@ -132,7 +128,9 @@ def write_data(self, fname='tausout'):
132
128
:param fname: Filename to save data to.
133
129
:type fname: str, optional
134
130
"""
135
- taus , bars = self .get_taus ()
131
+ if self .taus is None :
132
+ taus , bars = self .get_taus ()
133
+
136
134
keys = self .residues .keys ()
137
135
residues = np .array ([int (res [1 :]) for res in keys ])
138
136
data = np .stack ((residues , taus , bars [0 ], bars [1 ]))
@@ -148,7 +146,9 @@ def plot_protein(self, **kwargs):
148
146
if len (self .residues ) == 0 :
149
147
print ('run `collect_residues` then rerun' )
150
148
151
- taus , bars = self .get_taus ()
149
+ if self .taus is None :
150
+ self .get_taus ()
151
+
152
152
residues = list (self .residues .keys ())
153
153
residues = [res .split ('/' )[- 1 ] for res in residues ]
154
154
@@ -163,7 +163,9 @@ def b_color_structure(self, structure):
163
163
r"""Add :math:`\tau` to b-factors in the specified structure. Saves
164
164
structure with b-factors to `tau_bcolored.pdb`.
165
165
"""
166
- taus , bars = self .get_taus ()
166
+ if self .taus is None :
167
+ taus , bars = self .get_taus ()
168
+
167
169
cis = bars [1 ]+ bars [0 ]
168
170
errs = taus / cis
169
171
errs [errs != errs ] = 0
0 commit comments