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 90dffc6
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 3 deletions.
33 changes: 32 additions & 1 deletion prody/dynamics/adaptive.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@

import time
from numbers import Integral, Number
from decimal import Decimal, ROUND_HALF_UP
import numpy as np

from prody import LOGGER
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 +718,36 @@ 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()
n_confsA = int(Decimal(n_confs/2).to_integral(rounding=ROUND_HALF_UP))

confsA = self._confs[:n_confsA]
if n_confs % 2:
confsB = self._confs[n_confsA:]
else:
confsB = self._confs[n_confsA:]

RMSDs = np.zeros((n_confs-9))
n = 0
for i in range(n_confsA):
for j in range(2):
RMSDs[n] = getRMSD(confsA[i+j], confsB[n_confsA-(i+1)])
n += 1
if i == n_confsA - 1:
break

return RMSDs

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

LOGGER.info('Sampling conformers in generation %d ...' % self._cycle)
Expand Down
35 changes: 33 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 All @@ -14,6 +14,7 @@
from random import random
import os.path
import sys
from decimal import Decimal, ROUND_HALF_UP

from .adaptive import ONEWAY, ALTERNATING, SERIAL, DEFAULT
from .hybrid import Hybrid
Expand Down Expand Up @@ -537,6 +538,36 @@ 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()
n_confsA = int(Decimal(n_confs/2).to_integral(rounding=ROUND_HALF_UP))

confsA = self._confs[:n_confsA]
if n_confs % 2:
confsB = self._confs[n_confsA:]
else:
confsB = self._confs[n_confsA:]

RMSDs = np.zeros((n_confs-9))
n = 0
for i in range(n_confsA):
for j in range(2):
RMSDs[n] = getRMSD(confsA[i+j], confsB[n_confsA-(i+1)])
n += 1
if i == n_confsA - 1:
break

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 90dffc6

Please sign in to comment.