Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WatFinder - findClusterCenters() extension #1967

Merged
merged 7 commits into from
Oct 30, 2024
Merged
14 changes: 10 additions & 4 deletions prody/proteins/waterbridges.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1297,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
Expand All @@ -1317,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)
Expand All @@ -1333,8 +1334,13 @@ def findClusterCenters(file_pattern, **kwargs):
removeResid = []
removeCoords = []
for ii in range(len(coords_all)):
sel = coords_all.select('water 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])
removeCoords.append(list(coords_all.getCoords()[ii]))
Expand Down
Loading