From 9fa736c8c827468bb05c9f480497ac9c7a503df9 Mon Sep 17 00:00:00 2001 From: karolamik13 Date: Sun, 6 Oct 2024 21:21:43 +0200 Subject: [PATCH 1/6] extension of findClusterCenters() functionality --- prody/proteins/waterbridges.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/prody/proteins/waterbridges.py b/prody/proteins/waterbridges.py index e0f808f34..92b3bbd72 100644 --- a/prody/proteins/waterbridges.py +++ b/prody/proteins/waterbridges.py @@ -1333,8 +1333,14 @@ def findClusterCenters(file_pattern, **kwargs): removeResid = [] removeCoords = [] for ii in range(len(coords_all)): - sel = coords_all.select('water within '+str(distC)+' of center', + if 'water' not in selection.split(): + sel = coords_all.select(str(selection)+' within '+str(distC)+' of center', center=coords_all.getCoords()[ii]) + + if'water' in selection.split(): + sel = coords_all.select('water within '+str(distC)+' of center', + center=coords_all.getCoords()[ii]) + if sel is not None and len(sel) <= int(numC): removeResid.append(coords_all.getResnums()[ii]) removeCoords.append(list(coords_all.getCoords()[ii])) From 63ece76d3119490ffe4a249ac0fcc9d12ab9872a Mon Sep 17 00:00:00 2001 From: karolamik13 Date: Sun, 6 Oct 2024 22:27:51 +0200 Subject: [PATCH 2/6] findClusterCenters() improvement - HOH is added to water selection --- prody/proteins/waterbridges.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prody/proteins/waterbridges.py b/prody/proteins/waterbridges.py index 92b3bbd72..91e21da71 100644 --- a/prody/proteins/waterbridges.py +++ b/prody/proteins/waterbridges.py @@ -1337,7 +1337,7 @@ def findClusterCenters(file_pattern, **kwargs): sel = coords_all.select(str(selection)+' within '+str(distC)+' of center', center=coords_all.getCoords()[ii]) - if'water' in selection.split(): + if 'water' in selection.split() or 'HOH' in selection.split(): sel = coords_all.select('water within '+str(distC)+' of center', center=coords_all.getCoords()[ii]) From ae788f4d0596fd9782195e60da9a80a3f7ff3b47 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Mon, 7 Oct 2024 10:42:58 +0100 Subject: [PATCH 3/6] fix indents --- 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 91e21da71..9e4dc4840 100644 --- a/prody/proteins/waterbridges.py +++ b/prody/proteins/waterbridges.py @@ -1335,11 +1335,11 @@ def findClusterCenters(file_pattern, **kwargs): for ii in range(len(coords_all)): if 'water' not in selection.split(): sel = coords_all.select(str(selection)+' within '+str(distC)+' of center', - center=coords_all.getCoords()[ii]) + center=coords_all.getCoords()[ii]) if 'water' in selection.split() or 'HOH' in selection.split(): sel = coords_all.select('water within '+str(distC)+' of center', - center=coords_all.getCoords()[ii]) + center=coords_all.getCoords()[ii]) if sel is not None and len(sel) <= int(numC): removeResid.append(coords_all.getResnums()[ii]) From 7d5a5668847f516ea75457223b43818f2abde2ba Mon Sep 17 00:00:00 2001 From: James Krieger Date: Mon, 7 Oct 2024 10:49:12 +0100 Subject: [PATCH 4/6] use any water in findClusterCenters --- prody/proteins/waterbridges.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/prody/proteins/waterbridges.py b/prody/proteins/waterbridges.py index 9e4dc4840..5fb15737e 100644 --- a/prody/proteins/waterbridges.py +++ b/prody/proteins/waterbridges.py @@ -31,6 +31,7 @@ def auto(it=count()): from prody import LOGGER, SETTINGS from prody.atomic import Atom, Atomic, AtomGroup +from prody.atomic.flags import DEFAULTS from prody.ensemble import Ensemble from prody.measure import calcAngle, calcDistance from prody.measure.contacts import findNeighbors @@ -1337,7 +1338,7 @@ def findClusterCenters(file_pattern, **kwargs): sel = coords_all.select(str(selection)+' within '+str(distC)+' of center', center=coords_all.getCoords()[ii]) - if 'water' in selection.split() or 'HOH' in selection.split(): + if 'water' in selection.split() or np.any([water in selection.split() for water in DEFAULTS['water']]): sel = coords_all.select('water within '+str(distC)+' of center', center=coords_all.getCoords()[ii]) From 1b7c3cf2ff96b8c93e73638ab914414a4b926e1e Mon Sep 17 00:00:00 2001 From: James Krieger Date: Mon, 7 Oct 2024 10:50:07 +0100 Subject: [PATCH 5/6] reorder to use else for nonwater --- prody/proteins/waterbridges.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/prody/proteins/waterbridges.py b/prody/proteins/waterbridges.py index 5fb15737e..7aa643c9e 100644 --- a/prody/proteins/waterbridges.py +++ b/prody/proteins/waterbridges.py @@ -1334,13 +1334,12 @@ def findClusterCenters(file_pattern, **kwargs): removeResid = [] removeCoords = [] for ii in range(len(coords_all)): - if 'water' not in selection.split(): - sel = coords_all.select(str(selection)+' within '+str(distC)+' of center', - center=coords_all.getCoords()[ii]) - if 'water' in selection.split() or np.any([water in selection.split() for water in DEFAULTS['water']]): sel = coords_all.select('water within '+str(distC)+' of center', center=coords_all.getCoords()[ii]) + else: + sel = coords_all.select(str(selection)+' within '+str(distC)+' of center', + center=coords_all.getCoords()[ii]) if sel is not None and len(sel) <= int(numC): removeResid.append(coords_all.getResnums()[ii]) From d1aaecd0038acfc219cebed46c0fa6efcdec9cc6 Mon Sep 17 00:00:00 2001 From: karolamik13 Date: Mon, 7 Oct 2024 21:36:10 +0200 Subject: [PATCH 6/6] changes to more general selection for oxygen [findClusterCenters()] --- 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 7aa643c9e..095ce63d2 100644 --- a/prody/proteins/waterbridges.py +++ b/prody/proteins/waterbridges.py @@ -1298,7 +1298,7 @@ def findClusterCenters(file_pattern, **kwargs): :type file_pattern: str :arg selection: selection string - by default water and name OH2 is used + by default 'water and name "O.*"' is used :type selection: str :arg distC: distance to other molecules @@ -1318,7 +1318,7 @@ def findClusterCenters(file_pattern, **kwargs): import glob import numpy as np - selection = kwargs.pop('selection', 'water and name OH2') + selection = kwargs.pop('selection', 'water and name "O.*"') distC = kwargs.pop('distC', 0.3) numC = kwargs.pop('numC', 3) filename = kwargs.pop('filename', None)