Skip to content

Commit

Permalink
better memory
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmkrieger committed Sep 16, 2024
1 parent 9639506 commit 13a2e7d
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions prody/proteins/waterbridges.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,8 @@ def calcWaterBridgesTrajectory(atoms, trajectory, **kwargs):
expand_selection = kwargs.pop('expand_selection', False)
return_selection = kwargs.pop('return_selection', False)

interactions_all_regular = []

if trajectory is not None:
if isinstance(trajectory, Atomic):
trajectory = Ensemble(trajectory)
Expand Down Expand Up @@ -614,12 +616,11 @@ def analyseFrame(j0, start_frame, frame0, interactions_all):
analyseFrame(j0, start_frame, frame0, interactions_all)
else:
with mp.Manager() as manager:
interactions_all = manager.list()
for j0, frame0 in enumerate(traj, start=start_frame):
interactions_all.append([])

j0 = start_frame
while j0 < traj.numConfs()+start_frame:
interactions_all = manager.list()
for _ in range(max_proc):
interactions_all.append([])

processes = []
for _ in range(max_proc):
Expand All @@ -638,7 +639,7 @@ def analyseFrame(j0, start_frame, frame0, interactions_all):
for p in processes:
p.join()

interactions_all = interactions_all[:]
interactions_all_regular.extend(interactions_all[:])

# trajectory._nfi = nfi

Expand All @@ -654,18 +655,17 @@ def analyseFrame(i, interactions_all):
interactions_all[i] = interactions

if max_proc == 1:
interactions_all = []
for i in range(len(atoms.getCoordsets()[start_frame:stop_frame])):
interactions_all.append([])
analyseFrame(i, interactions_all)
interactions_all_regular.append([])
analyseFrame(i, interactions_all_regular)
else:
with mp.Manager() as manager:
interactions_all = manager.list()
for i in range(len(atoms.getCoordsets()[start_frame:stop_frame])):
interactions_all.append([])

i = start_frame
while i < len(atoms.getCoordsets()[start_frame:stop_frame]):
interactions_all = manager.list()
for _ in range(max_proc):
interactions_all.append([])

processes = []
for _ in range(max_proc):
p = mp.Process(target=analyseFrame, args=(i, interactions_all))
Expand All @@ -679,7 +679,7 @@ def analyseFrame(i, interactions_all):
for p in processes:
p.join()

interactions_all = interactions_all[:]
interactions_all_regular.extend(interactions_all[:])
else:
LOGGER.info('Include trajectory or use multi-model PDB file.')

Expand Down

0 comments on commit 13a2e7d

Please sign in to comment.