Skip to content

Commit

Permalink
molearn bug fixes to avoid recreating dope_score_class in molearn_ana…
Browse files Browse the repository at this point in the history
…lysis
  • Loading branch information
Samuel Musson committed May 15, 2023
1 parent 54f00b8 commit cda9ca3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/molearn/analysis/analyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,3 +466,7 @@ def generate(self, crd):

return s*self.stdval + self.meanval


def __getstate__(self):
return {key:value for key, value in dict(self.__dict__).items() if key not in ['dope_score_class', 'ramachandran_score_class']}

13 changes: 9 additions & 4 deletions src/molearn/scoring/dope_score.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ def get_dope(self, frame, refine=False):
if i+1<frame.shape[0]:
j.x, j.y, j.z = frame[self.fast_atom_order[i], :]
self.fast_mdl.build(build_method='INTERNAL_COORDINATES', initialize_xyz=False)

if refine == 'both':
with ShutUp():
dope_unrefined = self.fast_fs.assess_dope()
self.cg.optimize(self.fast_fs, max_iterations=50)
dope_refined = self.fast_fs.assess_dope()
return dope_unrefined, dope_refined
with ShutUp():
if refine:
self.cg.optimize(self.fast_fs, max_iterations=50)
Expand Down Expand Up @@ -155,7 +160,7 @@ def __init__(self, mol, processes=-1, **kwargs):
processes = min(processes, cpu_count())
else:
processes = cpu_count()
self.processes = processes
self.mol = deepcopy(mol)
score = DOPE_Score
ctx = get_context('spawn')
Expand All @@ -166,11 +171,11 @@ def __init__(self, mol, processes=-1, **kwargs):
self.process_function = process_dope

def __reduce__(self):
return (self.__class__, (self.mol,))
return (self.__class__, (self.mol, processes=self.processes))

def get_score(self, coords, **kwargs):
'''
:param np.array coords: # shape (N, 3) numpy array
'''
#is copy necessary?
return self.pool.apply_async(self.process_function, (coords.copy(), kwargs))
return self.pool.apply_async(self.process_function, (coords.copy(), kwargs))

0 comments on commit cda9ca3

Please sign in to comment.