def calc_deshaw_centroid_alpha_cartesian(ptlist=None): """ Calc RMSD from list of trajectories """ if ptlist is None: pts = deshaw.loadpts(skip=100, filt=deshaw.FILTER['alpha']) else: pts = ptlist # sums = np.zeros(shape=(5, 58, 3)) # cnts = [0 for i in range(5)] groupby = [[] for i in range(5)] label = deshaw.loadlabels_aslist() for idx, pt in enumerate(pts): # idx = math.floor(i/10) try: state = label[idx] if state == label[idx-2] == label[idx-1] == label[idx+1] == label[idx+2]: # sums[state] += pt # cnts[state] += 1 groupby[state].append(pt) except IndexError as err: pass # ignore idx errors due to tail end of DEShaw data # cent = [sums[i] / cnts[i] for i in range(5)] cent = np.zeros(shape=(5, 58,3)) for i in range(5): cent[i] = ndimage.measurements.center_of_mass(np.array(groupby[i])) return np.array(cent)
def calc_deshaw_centroid_alpha_cartesian(ptlist=None): """ Calc RMSD from list of trajectories """ if ptlist is None: pts = deshaw.loadpts(skip=100, filt=deshaw.FILTER['alpha']) else: pts = ptlist # sums = np.zeros(shape=(5, 58, 3)) # cnts = [0 for i in range(5)] groupby = [[] for i in range(5)] label = deshaw.loadlabels_aslist() for idx, pt in enumerate(pts): # idx = math.floor(i/10) try: state = label[idx] if state == label[idx - 2] == label[idx - 1] == label[ idx + 1] == label[idx + 2]: # sums[state] += pt # cnts[state] += 1 groupby[state].append(pt) except IndexError as err: pass # ignore idx errors due to tail end of DEShaw data # cent = [sums[i] / cnts[i] for i in range(5)] cent = np.zeros(shape=(5, 58, 3)) for i in range(5): cent[i] = ndimage.measurements.center_of_mass(np.array(groupby[i])) return np.array(cent)
cent = np.load(home+'/ddc/bpti-alpha-cart-centroid-well.npy') r.delete('label:hist') for size in ['sm', 'md', 'lg']: r.delete('label:hist:%s'%size) raw_obs = [] st = dt.datetime.now() SM = 0.25 MD = .5 LG = 1 theta = {'sm':.25, 'md':.5, 'lg':1.} raw_obs = {'sm':[], 'md':[], 'lg':[]} missing = 0 points = deshaw.loadpts(skip=1000, filt=deshaw.FILTER['alpha']) rmsd = [] for num, pt in enumerate(points): # rmsd.append(np.array([np.sum([LA.norm(pt[a] - C[a]) for a in range(58)]) for C in cent])) rmsd.append(np.array([LA.norm(pt - C) for C in cent])) prox = [np.argsort(i) for i in rmsd] pipe = r.pipeline() for i, rm in enumerate(rmsd): A = prox[i][0] B = prox[i][1] for size in ['sm', 'md', 'lg']: if (rm[B] - rm[A]) > theta[size]: raw_obs[size].append((A, A)) else: raw_obs[size].append((A, B))