Skip to content

Commit

Permalink
allow no parallel processes
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmkrieger committed Aug 2, 2024
1 parent a3cfb22 commit 2358ee6
Showing 1 changed file with 51 additions and 38 deletions.
89 changes: 51 additions & 38 deletions prody/proteins/waterbridges.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,31 +544,38 @@ def analyseFrame(j0, start_frame, frame0, interactions_all):
**kwargs)
interactions_all[j0-start_frame] = interactions

with mp.Manager() as manager:
interactions_all = manager.list()
if max_proc == 1:
interactions_all = []
for j0, frame0 in enumerate(traj, start=start_frame):
interactions_all.append([])
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():
j0 = start_frame
while j0 < traj.numConfs():

processes = []
for i in range(max_proc):
frame0 = traj[j0]
p = mp.Process(target=analyseFrame, args=(j0, start_frame,
frame0,
interactions_all))
p.start()
processes.append(p)
processes = []
for i in range(max_proc):
frame0 = traj[j0]

p = mp.Process(target=analyseFrame, args=(j0, start_frame,
frame0,
interactions_all))
p.start()
processes.append(p)

j0 += 1
if j0 >= traj.numConfs():
break
j0 += 1
if j0 >= traj.numConfs():
break

for p in processes:
p.join()
for p in processes:
p.join()

interactions_all = interactions_all[:]
interactions_all = interactions_all[:]

# trajectory._nfi = nfi

Expand All @@ -583,27 +590,33 @@ def analyseFrame(i, interactions_all):
**kwargs)
interactions_all[i] = interactions

with mp.Manager() as manager:
interactions_all = manager.list()
for i in range(len(atoms.getCoordsets()[start_frame:stop_frame])):
if max_proc == 1:
interactions_all = []
for j0, frame0 in enumerate(traj, start=start_frame):
interactions_all.append([])

i = start_frame
while i < stop_frame:
processes = []
for i in range(max_proc):
p = mp.Process(target=analyseFrame, args=(i, interactions_all))
p.start()
processes.append(p)

i += 1
if i >= stop_frame:
break

for p in processes:
p.join()

interactions_all = interactions_all[:]
analyseFrame(j0, start_frame, frame0, interactions_all)
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 < stop_frame:
processes = []
for i in range(max_proc):
p = mp.Process(target=analyseFrame, args=(i, interactions_all))
p.start()
processes.append(p)

i += 1
if i >= stop_frame:
break

for p in processes:
p.join()

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

Expand Down

0 comments on commit 2358ee6

Please sign in to comment.