def test_accuracy(self): confs = align_array(np.vstack(map(np.array, (struct_1, struct_2))), 'axis') conf_obj = Conformations(confs, 'axis', 7) rmsds = conf_obj.rmsds_to_reference(conf_obj, 0) self.assertAlmostEqual(rmsds[0], 0) self.assertAlmostEqual(rmsds[1], 0.719106, places=6)
def test_zeros(self): return confs = align_array(np.zeros((2, 3, 8)), 'axis') conf_obj = Conformations(confs, 'axis', 8) rmsds = conf_obj.rmsds_to_reference(conf_obj, 1) self.assertEqual(rmsds[0], 0) self.assertEqual(rmsds[1], 0)
def test_data_type(self): f32_structure = align_array(np.array(struct_1), 'axis') f64_structure = np.empty(f32_structure.shape, dtype=np.float64) f64_structure[:, :, :] = f32_structure self.assertRaises(IRMSD.FloatPrecisionError, Conformations, f64_structure, 'axis', 7)
def test_simple_structure(self): return confs = align_array(np.zeros((2, 3, 8)), 'axis') confs[1,:,0] += 1 conf_obj = Conformations(confs, 'axis', 2) rmsds = conf_obj.rmsds_to_reference(conf_obj, 1) self.assertAlmostEqual(rmsds[0], sqrt(3.0/4)) self.assertEqual(rmsds[1], 0)
conformation = data_frame.reshape((data_frame.shape[0] / n, n, dim + 1)) del data_frame #shuffle conformation conformation = np.take(conformation, np.random.permutation(conformation.shape[0]), axis=0, out=conformation) #keep only m sample conformation = conformation[:m] #keep only k sample in order to keep k distance conformation_part = conformation[:k] #create conformation object confs = align_array(conformation[:, :, 1:], 'atom') conf_obj = Conformations(confs, 'atom', 10) confs_part = align_array(conformation_part[:, :, 1:], 'atom') conf_obj_part = Conformations(confs, 'atom', 10) del conformation_part del confs del confs_part fout = open(folder + "output_1", 'w') for i in range(m): # we compute the rmsd between conformation i and all other confomations rmsds = conf_obj_part.rmsds_to_reference(conf_obj, i) line = str(conformation[i, 0, 0]) + "," # we add key for each line #rmsds_sorted=sorted(rmsds)
for atom in range(n): for coord in range(dim): conformation[m*n*coord+m*atom+li]=float(key_value1[atom+1][3+coord*7:9+coord*7]) #data.append(float(key_value1[atom+1][3+coord*7:9+coord*7])) li+=1 # we convert data into numpy array conformation=np.array(conformation) #we reshape the one dimensional array into 100000 x 3 x 10 conformation=conformation.reshape((len(conformation)/3/n,3,n)) # we create conformation array confs = align_array(conformation, 'axis') # we create conformation object conf_obj = Conformations(confs, 'axis', 10) #for each conformation for i in range(conformation.shape[0]): #data_frame.shape[0]/n rmsd_dic={} # we compute the rmsd between conformation i and all other confomations rmsds = conf_obj.rmsds_to_reference(conf_obj,i) # we sort the conformation rmsds_sorted=sorted(rmsds) #we keep only the k nearest conformation for l in range(k): rmsd_dic[l]=rmsds_sorted[l]