def _fitter_worker(self, tasks, coords, subset_coords, masses, subset_masses, rmsdmat, pbar_counter): ''' Fitter RMSD Matrix calculator. See encore.confdistmatrix.RMSDMatrixGenerator._fitter_worker for details. ''' if subset_coords == None: for i,j in trm_indeces(tasks[0],tasks[1]): coords[i] -= average(coords[i], axis=0, weights=masses) coords[j] -= average(coords[j], axis=0, weights=masses) weights = asarray(masses)/mean(masses) rmsdmat[(i+1)*i/2+j] = - rmsd(coords[i],coords[j],weights=weights) pbar_counter.value += 1 else: for i,j in trm_indeces(tasks[0],tasks[1]): #masses = asarray(masses)/mean(masses) summasses = sum(masses) com_i = average(subset_coords[i], axis=0, weights=subset_masses) translated_i = coords[i] - com_i subset1_coords = subset_coords[i] - com_i com_j = average(subset_coords[j], axis=0, weights=subset_masses) translated_j = coords[j] - com_j subset2_coords = subset_coords[j] - com_j rotamat = rotation_matrix(subset1_coords, subset2_coords, subset_masses)[0] rotated_i = transpose(dot(rotamat, transpose(translated_i))) rmsdmat[(i+1)*i/2+j] = MinusRMSD(rotated_i.astype(float64), translated_j.astype(float64), coords[j].shape[0], masses, summasses) pbar_counter.value += 1
def _fitter_worker(self, tasks, coords, subset_coords, masses, subset_masses, rmsdmat, pbar_counter): ''' Fitter RMSD Matrix calculator. See encore.confdistmatrix.RMSDMatrixGenerator._fitter_worker for details. ''' if subset_coords == None: for i, j in trm_indeces(tasks[0], tasks[1]): coords[i] -= average(coords[i], axis=0, weights=masses) coords[j] -= average(coords[j], axis=0, weights=masses) weights = asarray(masses) / mean(masses) rmsdmat[(i + 1) * i / 2 + j] = -rmsd(coords[i], coords[j], weights=weights) pbar_counter.value += 1 else: for i, j in trm_indeces(tasks[0], tasks[1]): #masses = asarray(masses)/mean(masses) summasses = sum(masses) com_i = average(subset_coords[i], axis=0, weights=subset_masses) translated_i = coords[i] - com_i subset1_coords = subset_coords[i] - com_i com_j = average(subset_coords[j], axis=0, weights=subset_masses) translated_j = coords[j] - com_j subset2_coords = subset_coords[j] - com_j rotamat = rotation_matrix(subset1_coords, subset2_coords, subset_masses)[0] rotated_i = transpose(dot(rotamat, transpose(translated_i))) rmsdmat[(i + 1) * i / 2 + j] = MinusRMSD( rotated_i.astype(float64), translated_j.astype(float64), coords[j].shape[0], masses, summasses) pbar_counter.value += 1
def _fitter_worker( self, tasks, coords, subset_coords, masses, subset_masses, rmsdmat, pbar_counter ): # Prototype fitter worker: pairwase align and calculate metric. To be ovverridden in heir classes '''Fitter worker prototype; to be overriden in derived classes ''' if subset_coords == None: for i, j in trm_indeces(tasks[0], tasks[1]): coords[i] -= average(coords[i], axis=0, weights=masses) coords[j] -= average(coords[j], axis=0, weights=masses) pbar_counter.value += 1 pass else: for i, j in trm_indeces(tasks[0], tasks[1]): com_i = average(coords[i], axis=0, weights=masses) translated_i = coords[i] - com_i subset1_coords = subset_coords[i] - com_i com_j = average(coords[j], axis=0, weights=masses) translated_j = coords[j] - com_j subset2_coords = subset_coords[j] - com_j rotamat = rotation_matrix(subset1_coords, subset2_coords, subset_masses)[0] rotated_i = transpose(dot(rotamat, transpose(translated_i))) pbar_counter.value += 1 pass
def _fitter_worker(self, tasks, coords, subset_coords, masses, subset_masses, rmsdmat, pbar_counter): ''' Fitter RMSD Matrix calculator: performs least-square fitting between each pair of structures before calculating the RMSD. **Arguments:** `tasks` : iterator of int of length 2 Given a triangular matrix written in a row-major order, this worker will calculate RMSD values from element tasks[0] to tasks[1]. Since the matrix is triangular. the trm_indeces function automatically calculates the corrisponding i,j matrix indeces. (see the see encore.utils.TriangularMatrix for details). `coords` : numpy.array Array of the ensemble coordinates `subset_coords` : numpy.array or None Array of the coordinates used for fitting `masses` : numpy.array or None Array of atomic masses, having the same order as the coordinates array. If None, coords will be used instead. `subset_masses` : numpy.array Array of atomic masses, having the same order as the subset_coords array `rmsdmat` : encore.utils.TriangularMatrix Memory-shared triangular matrix object `pbar_counter` : multiprocessing.RawValue Thread-safe shared value. This counter is updated at every cycle and used to evaluate the progress of each worker. ''' if subset_coords == None: for i, j in trm_indeces(tasks[0], tasks[1]): coords[i] -= average(coords[i], axis=0, weights=masses) coords[j] -= average(coords[j], axis=0, weights=masses) weights = asarray(masses) / mean(masses) rmsdmat[(i + 1) * i / 2 + j] = rmsd(coords[i], coords[j], weights=weights) pbar_counter.value += 1 else: for i, j in trm_indeces(tasks[0], tasks[1]): summasses = sum(masses) subset_weights = asarray(subset_masses) / mean(subset_masses) com_i = average(subset_coords[i], axis=0, weights=subset_masses) translated_i = coords[i] - com_i subset1_coords = subset_coords[i] - com_i com_j = average(subset_coords[j], axis=0, weights=subset_masses) translated_j = coords[j] - com_j subset2_coords = subset_coords[j] - com_j rotamat = rotation_matrix(subset1_coords, subset2_coords, subset_weights)[0] rotated_i = transpose(dot(rotamat, transpose(translated_i))) rmsdmat[(i + 1) * i / 2 + j] = PureRMSD( rotated_i.astype(float64), translated_j.astype(float64), coords[j].shape[0], masses, summasses) pbar_counter.value += 1
def _fitter_worker(self, tasks, coords, subset_coords, masses, subset_masses, rmsdmat, pbar_counter): ''' Fitter RMSD Matrix calculator: performs least-square fitting between each pair of structures before calculating the RMSD. **Arguments:** `tasks` : iterator of int of length 2 Given a triangular matrix written in a row-major order, this worker will calculate RMSD values from element tasks[0] to tasks[1]. Since the matrix is triangular. the trm_indeces function automatically calculates the corrisponding i,j matrix indeces. (see the see encore.utils.TriangularMatrix for details). `coords` : numpy.array Array of the ensemble coordinates `subset_coords` : numpy.array or None Array of the coordinates used for fitting `masses` : numpy.array or None Array of atomic masses, having the same order as the coordinates array. If None, coords will be used instead. `subset_masses` : numpy.array Array of atomic masses, having the same order as the subset_coords array `rmsdmat` : encore.utils.TriangularMatrix Memory-shared triangular matrix object `pbar_counter` : multiprocessing.RawValue Thread-safe shared value. This counter is updated at every cycle and used to evaluate the progress of each worker. ''' if subset_coords == None: for i,j in trm_indeces(tasks[0],tasks[1]): coords[i] -= average(coords[i], axis=0, weights=masses) coords[j] -= average(coords[j], axis=0, weights=masses) weights = asarray(masses)/mean(masses) rmsdmat[(i+1)*i/2+j] = rmsd(coords[i],coords[j],weights=weights) pbar_counter.value += 1 else: for i,j in trm_indeces(tasks[0],tasks[1]): summasses = sum(masses) subset_weights = asarray(subset_masses)/mean(subset_masses) com_i = average(subset_coords[i], axis=0, weights=subset_masses) translated_i = coords[i] - com_i subset1_coords = subset_coords[i] - com_i com_j = average(subset_coords[j], axis=0, weights=subset_masses) translated_j = coords[j] - com_j subset2_coords = subset_coords[j] - com_j rotamat = rotation_matrix(subset1_coords, subset2_coords, subset_weights)[0] rotated_i = transpose(dot(rotamat, transpose(translated_i))) rmsdmat[(i+1)*i/2+j] = PureRMSD(rotated_i.astype(float64), translated_j.astype(float64), coords[j].shape[0], masses, summasses) pbar_counter.value += 1
def _simple_worker(self, tasks, coords, masses, rmsdmat, pbar_counter): ''' Simple RMSD Matrix calculator. **Arguments:** `tasks` : iterator of int of length 2 Given a triangular matrix, this worker will calculate RMSD values from element tasks[0] to tasks[1]. Since the matrix is triangular, the trm_indeces matrix automatically calculates the corrisponding i,j matrix indices. The matrix is written as an array in a row-major order (see the TriangularMatrix class for details). `coords` : numpy.array Array of the ensemble coordinates `masses` : numpy.array Array of atomic masses, having the same order as the coordinates array `rmsdmat` : encore.utils.TriangularMatrix Memory-shared triangular matrix object `pbar_counter` : multiprocessing.RawValue Thread-safe shared value. This counter is updated at every cycle and used to evaluate the progress of each worker. ''' for i,j in trm_indeces(tasks[0],tasks[1]): #masses = asarray(masses)/mean(masses) summasses = sum(masses) rmsdmat[(i+1)*i/2+j] = PureRMSD(coords[i].astype(float64), coords[j].astype(float64), coords[j].shape[0], masses, summasses) pbar_counter.value += 1
def _simple_worker(self, tasks, coords, masses, rmsdmat, pbar_counter): ''' Simple RMSD Matrix calculator. **Arguments:** `tasks` : iterator of int of length 2 Given a triangular matrix, this worker will calculate RMSD values from element tasks[0] to tasks[1]. Since the matrix is triangular, the trm_indeces matrix automatically calculates the corrisponding i,j matrix indices. The matrix is written as an array in a row-major order (see the TriangularMatrix class for details). `coords` : numpy.array Array of the ensemble coordinates `masses` : numpy.array Array of atomic masses, having the same order as the coordinates array `rmsdmat` : encore.utils.TriangularMatrix Memory-shared triangular matrix object `pbar_counter` : multiprocessing.RawValue Thread-safe shared value. This counter is updated at every cycle and used to evaluate the progress of each worker. ''' for i, j in trm_indeces(tasks[0], tasks[1]): #masses = asarray(masses)/mean(masses) summasses = sum(masses) rmsdmat[(i + 1) * i / 2 + j] = PureRMSD(coords[i].astype(float64), coords[j].astype(float64), coords[j].shape[0], masses, summasses) pbar_counter.value += 1
def _simple_worker(self, tasks, coords, masses, rmsdmat, pbar_counter): ''' Simple RMSD Matrix calculator. See encore.confdistmatrix.RMSDMatrixGenerator._simple_worker for details. ''' for i,j in trm_indeces(tasks[0],tasks[1]): #masses = asarray(masses)/mean(masses) summasses = sum(masses) rmsdmat[(i+1)*i/2+j] = MinusRMSD(coords[i].astype(float64), coords[j].astype(float64), coords[j].shape[0], masses, summasses) pbar_counter.value += 1
def _simple_worker(self, tasks, coords, masses, rmsdmat, pbar_counter): ''' Simple RMSD Matrix calculator. See encore.confdistmatrix.RMSDMatrixGenerator._simple_worker for details. ''' for i, j in trm_indeces(tasks[0], tasks[1]): #masses = asarray(masses)/mean(masses) summasses = sum(masses) rmsdmat[(i + 1) * i / 2 + j] = MinusRMSD(coords[i].astype(float64), coords[j].astype(float64), coords[j].shape[0], masses, summasses) pbar_counter.value += 1
def _fitter_worker(self, tasks, coords, subset_coords, masses, subset_masses, rmsdmat, pbar_counter): # Prototype fitter worker: pairwase align and calculate metric. To be ovverridden in heir classes '''Fitter worker prototype; to be overriden in derived classes ''' if subset_coords == None: for i,j in trm_indeces(tasks[0],tasks[1]): coords[i] -= average(coords[i], axis=0, weights=masses) coords[j] -= average(coords[j], axis=0, weights=masses) pbar_counter.value += 1 pass else: for i,j in trm_indeces(tasks[0],tasks[1]): com_i = average(coords[i], axis=0, weights=masses) translated_i = coords[i] - com_i subset1_coords = subset_coords[i] - com_i com_j = average(coords[j], axis=0, weights=masses) translated_j = coords[j] - com_j subset2_coords = subset_coords[j] - com_j rotamat = rotation_matrix(subset1_coords, subset2_coords, subset_masses)[0] rotated_i = transpose(dot(rotamat, transpose(translated_i))) pbar_counter.value += 1 pass
def _simple_worker(self, tasks, coords, masses, rmsdmat, pbar_counter): '''Simple worker prototype; to be overriden in derived classes ''' for i,j in trm_indeces(tasks[0],tasks[1]): pass
def _simple_worker(self, tasks, coords, masses, rmsdmat, pbar_counter): '''Simple worker prototype; to be overriden in derived classes ''' for i, j in trm_indeces(tasks[0], tasks[1]): pass