def calcDistMatrix(coordsets): from pyRMSD.matrixHandler import MatrixHandler matrix = MatrixHandler().createMatrix(coordsets,'NOSUP_SERIAL_CALCULATOR') return matrix.get_data()
# # def _rmsd_pair(conf1, conf2): # return np.array([]) # Compute distance matrix without centering import numpy as np N = len(confs) # This does not work in the scipy.cluster.Z() function for some reason #dist_matrix = [0. if j>=k else np.sqrt(np.sum((confs[j][self.molecule.heavy_atoms,:]-confs[k][self.molecule.heavy_atoms,:])**2)/self.molecule.nhatoms) for j in range(N) for k in range(N)] #dist_matrix = np.reshape(np.array(dist_matrix), (N,N)) #dist_matrix += np.transpose(dist_matrix) #flat_dist_matrix = np.array([np.sqrt(np.sum((confs[j]-confs[k])**2)/self.molecule.nhatoms) for j in range(N) for k in range(j+1,N)]) # Hierarchical Clustering import scipy.cluster Z = scipy.cluster.hierarchy.complete(rmsd_matrix.get_data()) # #nclusters = [] #rmv = [] #for dcutoff in [0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7]: # assignments = np.array(scipy.cluster.hierarchy.fcluster(Z, dcutoff, criterion='distance')) # nc = len(set(assignments)) # GBSA_cluster_variances = [] # for n in range(nc): # GBSA_n = GBSA_energy[assignments==n] # if len(GBSA_n)>1: # GBSA_cluster_variances.append(np.var(GBSA_n)) # if len(GBSA_cluster_variances)>0: # rmv.append(np.sqrt(np.mean(GBSA_cluster_variances))) # else: # rmv.append(0.)