def calc_rmsd(struct1, struct2): crds1 = get_coords(struct1) crds2 = get_coords(struct2) assert(crds1.shape[1] == 3) assert(crds1.shape == crds2.shape) rmsd = rmsd_qcp(crds1, crds2) print "RMSD: %.4f" % rmsd
print 'Frames loaded successfully' # concatenate all of the data together into a # single array array xyz = np.concatenate(xyz) print 'Number of frames of data loaded %s' % len(xyz) # compute the full pairwise distance matrix # between all of the observed conformations # using the rmsd_qcp algorithm print 'Computing the pairwise distance matrix' distances = np.empty(len(xyz)*(len(xyz)-1)/2) k = 0 for i in xrange(len(xyz)): for j in xrange(i+1, len(xyz)): distances[k] = rmsd.rmsd_qcp(xyz[j], xyz[j]) k += 1 print 'RMSD computation %s/%s' % (k, len(xyz)*(len(xyz)-1)/2) print 'mean pairwise distance ', np.mean(distances) print 'stddev pairwise distance', np.std(distances) print 'Running hierarchical clustering (UPGMA)...' # run hierarchical clustering on the distance matrix Z = linkage(distances, method='average') # get flat clusters from the linkage matrix corresponding # to states print 'Flattening the clusters...' assignments = fcluster(Z, t=5000, criterion='maxclust')
def calculate_rmsd(xyz1, xyz2, atoms=None): return rmsd.rmsd_qcp(xyz1, xyz2)