From 58986747cfcb08a756a9d37388e4f9005715cde5 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Mon, 5 Aug 2024 18:57:28 +0200 Subject: [PATCH 1/7] manually update release docs --- docs/release/index.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/release/index.rst b/docs/release/index.rst index 2007f5566..cfe0dfaff 100644 --- a/docs/release/index.rst +++ b/docs/release/index.rst @@ -10,6 +10,10 @@ Release Notes :maxdepth: 2 :glob: + v2.4_series + v2.3_series + v2.2_series + v2.1_series v2.0_series v1.11_series v1.10_series From c4d832762a63f9cb076b4b376713b08ccf9dd453 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Tue, 6 Aug 2024 14:38:35 +0100 Subject: [PATCH 2/7] _ not i in calcWBtraj proc for loop --- prody/proteins/waterbridges.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/prody/proteins/waterbridges.py b/prody/proteins/waterbridges.py index 141457711..a2f45d00b 100644 --- a/prody/proteins/waterbridges.py +++ b/prody/proteins/waterbridges.py @@ -599,7 +599,7 @@ def analyseFrame(j0, start_frame, frame0, interactions_all): while j0 < traj.numConfs()+start_frame: processes = [] - for i in range(max_proc): + for _ in range(max_proc): frame0 = traj[j0-start_frame] p = mp.Process(target=analyseFrame, args=(j0, start_frame, @@ -644,7 +644,7 @@ def analyseFrame(i, interactions_all): i = start_frame while i < len(atoms.getCoordsets()[start_frame:stop_frame]): processes = [] - for i in range(max_proc): + for _ in range(max_proc): p = mp.Process(target=analyseFrame, args=(i, interactions_all)) p.start() processes.append(p) From ab0f3e46233f54d097142015ae2e896552ecc4ce Mon Sep 17 00:00:00 2001 From: James Krieger Date: Tue, 6 Aug 2024 17:42:58 +0100 Subject: [PATCH 3/7] first try parallel savePDBwbt --- prody/proteins/waterbridges.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/prody/proteins/waterbridges.py b/prody/proteins/waterbridges.py index a2f45d00b..8f2dbf4b7 100644 --- a/prody/proteins/waterbridges.py +++ b/prody/proteins/waterbridges.py @@ -1104,7 +1104,7 @@ def savePDBWaterBridges(bridges, atoms, filename): return writePDB(filename, atomsToSave) -def savePDBWaterBridgesTrajectory(bridgeFrames, atoms, filename, trajectory=None): +def savePDBWaterBridgesTrajectory(bridgeFrames, atoms, filename, trajectory=None, max_proc=1): """Saves one PDB per frame with occupancy and beta on protein atoms and waters forming bridges in frame. :arg bridgeFrames: atomic output from calcWaterBridgesTrajectory @@ -1127,7 +1127,7 @@ def savePDBWaterBridgesTrajectory(bridgeFrames, atoms, filename, trajectory=None atoms = atoms.copy() mofifyBeta(bridgeFrames, atoms) - for frameIndex, frame in enumerate(bridgeFrames): + def saveBridgesFrame(trajectory, atoms, frameIndex, frame): if trajectory: coords = trajectory[frameIndex].getCoords() atoms.setCoords(coords) @@ -1153,6 +1153,26 @@ def savePDBWaterBridgesTrajectory(bridgeFrames, atoms, filename, trajectory=None writePDB(f'{filename}_{frameIndex}.pdb', atomsToSave, csets=frameIndex) + if max_proc == 1: + for frameIndex, frame in enumerate(bridgeFrames): + saveBridgesFrame(trajectory, atoms, frameIndex, frame) + else: + frameIndex = 0 + numFrames = len(bridgeFrames) + while frameIndex < numFrames: + processes = [] + for _ in range(max_proc): + p = mp.Process(target=saveBridgesFrame, args=(trajectory, atoms, frameIndex, + bridgeFrames[frameIndex])) + p.start() + processes.append(p) + + j0 += 1 + if j0 >= numFrames: + break + + for p in processes: + p.join() def getBridgeIndicesString(bridge): return ' '.join(map(lambda a: str(a.getIndex()), bridge.proteins))\ From 57eeddbabc8141a9eb23ec36c2b3a9a3eb453300 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Wed, 7 Aug 2024 11:36:27 +0100 Subject: [PATCH 4/7] bug fix parallel save --- prody/proteins/waterbridges.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/prody/proteins/waterbridges.py b/prody/proteins/waterbridges.py index 8f2dbf4b7..083e797d0 100644 --- a/prody/proteins/waterbridges.py +++ b/prody/proteins/waterbridges.py @@ -1128,6 +1128,7 @@ def savePDBWaterBridgesTrajectory(bridgeFrames, atoms, filename, trajectory=None mofifyBeta(bridgeFrames, atoms) def saveBridgesFrame(trajectory, atoms, frameIndex, frame): + LOGGER.info('Frame: {0}'.format(frameIndex)) if trajectory: coords = trajectory[frameIndex].getCoords() atoms.setCoords(coords) @@ -1167,8 +1168,8 @@ def saveBridgesFrame(trajectory, atoms, frameIndex, frame): p.start() processes.append(p) - j0 += 1 - if j0 >= numFrames: + frameIndex += 1 + if frameIndex >= numFrames: break for p in processes: From e587375335577fc84aa8a78ce648c9a413f7ddb9 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Wed, 7 Aug 2024 14:12:33 +0100 Subject: [PATCH 5/7] restore missing fix --- prody/proteins/waterbridges.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/prody/proteins/waterbridges.py b/prody/proteins/waterbridges.py index 083e797d0..feed5bf6b 100644 --- a/prody/proteins/waterbridges.py +++ b/prody/proteins/waterbridges.py @@ -660,6 +660,11 @@ def analyseFrame(i, interactions_all): else: LOGGER.info('Include trajectory or use multi-model PDB file.') + if return_selection: + if indices is not None: + atoms_copy = atoms_copy[indices] + kwargs['selstr'] = atoms_copy.getSelstr() + if return_selection: return interactions_all, atoms_copy From 6fa53f5f71290bdee51bde91be2a21068a56c506 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Wed, 7 Aug 2024 14:12:51 +0100 Subject: [PATCH 6/7] log common selection --- prody/proteins/waterbridges.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/prody/proteins/waterbridges.py b/prody/proteins/waterbridges.py index feed5bf6b..fd19c85c6 100644 --- a/prody/proteins/waterbridges.py +++ b/prody/proteins/waterbridges.py @@ -530,7 +530,8 @@ def calcWaterBridgesTrajectory(atoms, trajectory, **kwargs): combining selections satifying the criteria in each. :arg return_selection: whether to return the combined common selection - Default is **False** + Default is **False** to keep expected behaviour. + However, this output is required when using selstr. :type return_selection: bool """ start_frame = kwargs.pop('start_frame', 0) @@ -554,7 +555,9 @@ def calcWaterBridgesTrajectory(atoms, trajectory, **kwargs): traj = trajectory[start_frame:stop_frame+1] indices = None + selection = atoms if selstr is not None: + LOGGER.info('Finding common selection') indices = [] for frame0 in traj: atoms_copy = atoms.copy() @@ -568,6 +571,8 @@ def calcWaterBridgesTrajectory(atoms, trajectory, **kwargs): indices = np.unique(indices) + LOGGER.info('Common selection found with {0} atoms and {1} protein chains'.format(selection.numAtoms(), + len(list(selection.protein.getHierView())))) def analyseFrame(j0, start_frame, frame0, interactions_all): LOGGER.info('Frame: {0}'.format(j0)) From fd727cf6c598598df8849c4486a32126322eea93 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Wed, 7 Aug 2024 18:10:18 +0100 Subject: [PATCH 7/7] fix log to common selection --- prody/proteins/waterbridges.py | 1 + 1 file changed, 1 insertion(+) diff --git a/prody/proteins/waterbridges.py b/prody/proteins/waterbridges.py index 9745246ee..500d85ce9 100644 --- a/prody/proteins/waterbridges.py +++ b/prody/proteins/waterbridges.py @@ -570,6 +570,7 @@ def calcWaterBridgesTrajectory(atoms, trajectory, **kwargs): indices.extend(list(selection.getIndices())) indices = np.unique(indices) + selection = atoms_copy[indices] LOGGER.info('Common selection found with {0} atoms and {1} protein chains'.format(selection.numAtoms(), len(list(selection.protein.getHierView()))))