Skip to content

Commit

Permalink
add calcConvergenceRMSDs
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmkrieger committed Feb 26, 2021
1 parent eed201b commit 315e7d5
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 3 deletions.
28 changes: 27 additions & 1 deletion prody/dynamics/adaptive.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from prody.atomic import Atomic, AtomMap
from prody.utilities import getCoords, createStringIO, importLA, checkCoords, copy

from prody.measure.transform import calcTransformation, superpose, applyTransformation, calcRMSD
from prody.measure.transform import calcTransformation, superpose, applyTransformation, calcRMSD, getRMSD
from prody.measure.measure import calcDeformVector, calcDistance

from prody.ensemble.ensemble import Ensemble
Expand Down Expand Up @@ -717,6 +717,32 @@ def getRMSDsB(self):

return calcRMSD(self._atomsB, self._confs[:, indices], weights)

def getConvergenceRMSDs(self):
if self._confs is None or self._coords is None:
return None

indices = self._indices
if indices is None:
indices = np.arange(self._confs.shape[1])

weights = self._weights[indices] if self._weights is not None else None

n_confs = self.numConfs()
confsA = self._confs[::2]
if n_confs % 2:
confsB = self._confs[-2::-2]
else:
confsB = self._confs[-1::-2]

n_confsA = len(confsA)
n_confsB = len(confsB)
RMSDs = zeros((n_confsA, n_confsB))
for i in range(n_confsA):
for j in range(n_confsB):
RMSDs[i, j] = getRMSD(confsA[i, indices], confsB[j, indices], weights)

return RMSDs

def _generate(self, confs, **kwargs):

LOGGER.info('Sampling conformers in generation %d ...' % self._cycle)
Expand Down
30 changes: 28 additions & 2 deletions prody/dynamics/comd.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from prody.proteins.pdbfile import parsePDB, writePDBStream, parsePDBStream
from prody.measure.transform import calcRMSD, calcTransformation, superpose, applyTransformation
from prody.measure.measure import buildDistMatrix, calcDeformVector, calcDistance
from prody.measure.transform import calcRMSD, calcTransformation, getRMSD, applyTransformation
from prody.measure.measure import buildDistMatrix, calcDeformVector
from prody.ensemble.ensemble import Ensemble
from prody.utilities import createStringIO, importLA, checkCoords, copy

Expand Down Expand Up @@ -537,6 +537,32 @@ def getRMSDsB(self):

return calcRMSD(self._atomsB, self._confs[:, indices], weights)

def getConvergenceRMSDs(self):
if self._confs is None or self._coords is None:
return None

indices = self._indices
if indices is None:
indices = np.arange(self._confs.shape[1])

weights = self._weights[indices] if self._weights is not None else None

n_confs = self.numConfs()
confsA = self._confs[::2]
if n_confs % 2:
confsB = self._confs[-2::-2]
else:
confsB = self._confs[-1::-2]

n_confsA = len(confsA)
n_confsB = len(confsB)
RMSDs = zeros((n_confsA, n_confsB))
for i in range(n_confsA):
for j in range(n_confsB):
RMSDs[i, j] = getRMSD(confsA[i, indices], confsB[j, indices], weights)

return RMSDs

def run(self, cutoff=15., n_modes=20, gamma=1., n_confs=50, rmsd=1.0,
n_gens=5, solvent='imp', sim=False, force_field=None, temp=303.15,
t_steps_i=1000, t_steps_g=7500,
Expand Down

0 comments on commit 315e7d5

Please sign in to comment.