iframe = 0 while dcd.has_more_data() : data = dcd.read_onestep_np() ########################################################## ### Wrapping the molecule to do bestfit # Find most lateral coordinates max_xyz, min_xyz, L = find_max_min_PBC(data[ID_DOM_INI_FIT:ID_DOM_END_FIT+1]) if L[0] > BOXSIZE or L[1] > BOXSIZE or L[2] > BOXSIZE: print(('Warning: (1) L exceeds BOXSIZE at frame %i' % iframe)) mtx_move = mtx_crd_transform() #mtx_move.reset() mtx_move.translation(0.5*L[0] - max_xyz[0], 0.5*L[1] - max_xyz[1], 0.5*L[2] - max_xyz[2]) mtx_move.do_to_ndarray(data) ########################################################## ### Align to the reference PDB (post, rmsd, ier, rot, center_ref, center_pre) = py_bestfit.bestfit(ref, data.T, ref_idx, pre_idx) data = post.T
# 2 BIOMTx # 3 N row = int(lsp[2][5:]) #print ('row', row) if row != row_pre + 1: print('Error row %i is expected but %i loaded' % (row_pre + 1, row)) sys.exit(2) mtx_id = int(lsp[3]) #print ('id', mtx_id) if row == 1: mtx = mtx_crd_transform() mtx.mtx[row - 1, 0] = float(lsp[4]) mtx.mtx[row - 1, 1] = float(lsp[5]) mtx.mtx[row - 1, 2] = float(lsp[6]) mtx.mtx[row - 1, 3] = float(lsp[7]) if row == 3: matrices[mtx_id] = mtx assembly_units.append(mtx_id) if row == 3: row_pre = 0 else: row_pre = row
#Ste7(189-471)の重心(CAのみで計算)が原点に重なるように並進 com = Coord() n_com = 0 for (i,r) in enumerate(chains[1].residues): if (i+1)>=189 and (i+1)<=471: for a in r.atoms: if a.name.find("CA") != -1: com += a.xyz n_com += 1 if n_com != 283: print("ERROR: n_com = ",n_com) sys.exit(2) com /= n_com trans_com = mtx_crd_transform() trans_com.translation(-com.x, -com.y, -com.z) for c in chains: for r in c.residues: for a in r.atoms: a.xyz.transform(trans_com.mtx) print("重心を原点へ") print("Q:",Q.get_as_tuple()) print("N:",N.get_as_tuple()) ########################################################## #重心を固定したまま、QをZ軸上へ持っていく。 #Qと原点を結ぶ線Lと垂直な、xy平面上の軸を表す単位ベクトルR
header = dcd.get_header() dcd_out.set_header(header) dcd_out.write_header() nmp = header.nmp_real while dcd.has_more_data() : data = dcd.read_onestep() ########################################################## #重心(CAのみで計算)が原点に重なるように並進 com = [0.0] * 3 n_com = ID_DOM_END - ID_DOM_INI + 1 for i in range(ID_DOM_INI, ID_DOM_END+1): com[0] += data[i][0] com[1] += data[i][1] com[2] += data[i][2] com = [-x/float(n_com) for x in com] trans_com = mtx_crd_transform() trans_com.translation(com[0],com[1],com[2]) #for i in xrange(nmp): # data[i][0:3] = trans_com.do_to_array(data[i]) trans_com.do_to_data(data) dcd_out.write_onestep(data) dcd.close() dcd_out.close()