def getRMSDs(self, pairwise=False): """Returns root mean square deviations (RMSDs) for selected atoms. Conformations can be aligned using one of :meth:`superpose` or :meth:`iterpose` methods prior to RMSD calculation. :arg pairwise: if **True** then it will return pairwise RMSDs as an n-by-n matrix. n is the number of conformations. :type pairwise: bool """ if self._confs is None or self._coords is None: return None indices = self._indices if indices is None: indices = arange(self._confs.shape[1]) weights = self._weights[indices] if self._weights is not None else None if pairwise: n_confs = self.numConfs() RMSDs = zeros((n_confs, n_confs)) for i in range(n_confs): for j in range(n_confs): RMSDs[i, j] = getRMSD(self._confs[i, indices], self._confs[j, indices], weights) else: RMSDs = getRMSD(self._coords[indices], self._confs[:, indices], weights) return RMSDs
def getRMSDs(self, pairwise=False): """Returns root mean square deviations (RMSDs) for selected atoms. Conformations can be aligned using one of :meth:`superpose` or :meth:`iterpose` methods prior to RMSD calculation. :arg pairwise: if **True** then it will return pairwise RMSDs as an n-by-n matrix. n is the number of conformations. :type pairwise: bool """ if self._confs is None or self._coords is None: return None indices = self._indices if indices is None: indices = arange(self._confs.shape[1]) weights = self._weights[indices] if self._weights is not None else None if pairwise: n_confs = self.numConfs() RMSDs = zeros((n_confs, n_confs)) for i in range(n_confs): for j in range(i+1, n_confs): RMSDs[i, j] = RMSDs[j, i] = getRMSD(self._confs[i, indices], self._confs[j, indices], weights) else: RMSDs = getRMSD(self._coords[indices], self._confs[:, indices], weights) return RMSDs
def getRMSDs(self, pairwise=False): """Calculate and return root mean square deviations (RMSDs). Note that you might need to align the conformations using :meth:`superpose` or :meth:`iterpose` before calculating RMSDs. :arg pairwise: if **True** then it will return pairwise RMSDs as an n-by-n matrix. n is the number of conformations. :type pairwise: bool """ 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 if pairwise: n_confs = self.numConfs() RMSDs = np.zeros((n_confs, n_confs)) for i in range(n_confs): for j in range(i+1, n_confs): if weights is None: w = None else: wi = weights[i]; wj = weights[j] w = wi * wj RMSDs[i, j] = RMSDs[j, i] = getRMSD(self._confs[i, indices], self._confs[j, indices], w) else: RMSDs = getRMSD(self._coords[indices], self._confs[:, indices], weights) return RMSDs
def getRMSD(self): """Returns RMSD from the ensemble reference coordinates. RMSD is calculated for (selected) atoms.""" ensemble = self._ensemble indices = ensemble._indices if indices is None: return getRMSD(ensemble._coords, ensemble._confs[self._index], self.getWeights())[0] else: return getRMSD(ensemble._coords[indices], ensemble._confs[self._index, indices], self.getWeights())[0]
def getRMSDs(self): """Calculate and return root mean square deviations (RMSDs). Note that you might need to align the conformations using :meth:`superpose` or :meth:`iterpose` before calculating RMSDs.""" if self._confs is None or self._coords is None: return None indices = self._indices if indices is None: return getRMSD(self._coords, self._confs, self._weights) else: return getRMSD(self._coords[indices], self._confs[:, indices], self._weights[:, indices])
def getRMSD(self): """Return RMSD from the ensemble reference coordinates. RMSD is calculated for (selected) atoms.""" ensemble = self._ensemble indices = ensemble._indices if indices is None: return getRMSD(ensemble._coords, ensemble._confs[self._index], self.getWeights())[0] else: return getRMSD(ensemble._coords[indices], ensemble._confs[self._index, indices], self.getWeights())[0]
def getRMSD(self): """Returns RMSD from the trajectory reference coordinates. If weights for the trajectory are set, weighted RMSD will be returned.""" indices = self._traj._indices traj = self._traj coords = self._getCoords() if indices is None: return getRMSD(coords, traj._coords, traj._weights) else: if traj._weights is None: return getRMSD(coords, traj._coords[indices]) else: return getRMSD(coords, traj._coords[indices], traj._weights[indices])
def getRMSD(self): """Return RMSD from the trajectory reference coordinates. If weights for the trajectory are set, weighted RMSD will be returned.""" indices = self._traj._indices traj = self._traj coords = self._getCoords() if indices is None: return getRMSD(coords, traj._coords, traj._weights) else: if traj._weights is None: return getRMSD(coords, traj._coords[indices]) else: return getRMSD(coords, traj._coords[indices], traj._weights[indices])
def getRMSDs(self): """Returns root mean square deviations (RMSDs) for selected atoms. Conformations can be aligned using one of :meth:`superpose` or :meth:`iterpose` methods prior to RMSD calculation.""" if self._confs is None or self._coords is None: return None if self._indices is None: return getRMSD(self._coords, self._confs, self._weights) else: indices = self._indices if self._weights is None: return getRMSD(self._coords[indices], self._confs[:, indices]) else: return getRMSD(self._coords[indices], self._confs[:, indices], self._weights[indices])
def iterpose(self, rmsd=0.0001, quiet=False): """Iteratively superpose the ensemble until convergence. Initially, all conformations are aligned with the reference coordinates. Then mean coordinates are calculated, and are set as the new reference coordinates. This is repeated until reference coordinates do not change. This is determined by the value of RMSD between the new and old reference coordinates. Note that at the end of the iterative procedure the reference coordinate set will be average of conformations in the ensemble. :arg rmsd: change in reference coordinates to determine convergence, default is 0.0001 Å RMSD :type rmsd: float""" if self._coords is None: raise AttributeError('coordinates are not set, use `setCoords`') if self._confs is None or len(self._confs) == 0: raise AttributeError('conformations are not set, use' '`addCoordset`') LOGGER.info('Starting iterative superposition:') LOGGER.timeit('_prody_ensemble') rmsdif = 1 step = 0 weights = self._weights length = len(self) if weights is not None: if weights.ndim == 3: weightsum = weights.sum(axis=0) weightsum[weightsum == 0.] = 1. # add pseudocount to avoid nan else: weightsum = length while rmsdif > rmsd: self._superpose(quiet=quiet) if weights is None: newxyz = self._confs.sum(0) / length else: newxyz = (self._confs * weights).sum(0) / weightsum rmsdif = getRMSD(self._coords, newxyz) self._coords = newxyz step += 1 LOGGER.info('Step #{0}: RMSD difference = {1:.4e}'.format( step, rmsdif)) LOGGER.report('Iterative superposition completed in %.2fs.', '_prody_ensemble')
def iterpose(self, rmsd=0.0001): """Iteratively superpose the ensemble until convergence. Initially, all conformations are aligned with the reference coordinates. Then mean coordinates are calculated, and are set as the new reference coordinates. This is repeated until reference coordinates do not change. This is determined by the value of RMSD between the new and old reference coordinates. Note that at the end of the iterative procedure the reference coordinate set will be average of conformations in the ensemble. :arg rmsd: change in reference coordinates to determine convergence, default is 0.0001 Å RMSD :type rmsd: float""" if self._coords is None: raise AttributeError('coordinates are not set, use `setCoords`') if self._confs is None or len(self._confs) == 0: raise AttributeError('conformations are not set, use' '`addCoordset`') LOGGER.info('Starting iterative superposition:') LOGGER.timeit('_prody_ensemble') rmsdif = 1 step = 0 weights = self._weights if weights is not None and weights.ndim == 3: weightsum = weights.sum(axis=0) length = len(self) while rmsdif > rmsd: self._superpose() if weights is None: newxyz = self._confs.sum(0) / length else: newxyz = (self._confs * weights).sum(0) / weightsum rmsdif = getRMSD(self._coords, newxyz) self._coords = newxyz step += 1 LOGGER.info('Step #{0}: RMSD difference = {1:.4e}' .format(step, rmsdif)) LOGGER.report('Iterative superposition completed in %.2fs.', '_prody_ensemble')