def ssDNA_gauss(M,VW, Z,L, frames, rcut=1.0, step=5e4): try: #V = util.pickle_load('V.pkl') P = util.pickle_load('SSDNA.pkl') except: P = M.cord_auto(['K','T']) util.pickle_dump(P,'SSDNA.pkl') gauss_map = [] w = np.array([[1,0,0],[0,1,0],[0,0,1]]) ndna = P.shape[1]/VW.shape[1] print P.shape for k in frames: location = [] print k try: for i in range(VW.shape[1]): #we must rotate about a specific cube reference frame if i in range(20): V = VW[k][i] x_r = points.unit(points.vector1d(V,Z[k][i*6+1],L[k])) y_r = points.unit(points.vector1d(V,Z[k][i*6+2],L[k])) z_r = points.unit(points.vector1d(V,Z[k][i*6+5],L[k])) dd = points.dist(V,Z[k][i*6+5],L[k])[0] v = np.array([x_r,y_r,z_r]) R = points.reference_rotation(v,w) for j in range(ndna): d = points.dist(V,P[k][j+i*ndna],L[k])[0] c_r = points.unit(points.vector1d(V,P[k][j+i*ndna],L[k])) location.append(points.unit(np.dot(R,np.transpose(c_r)))*d) except: print 'something went wrong here' gauss_map.append(location) ######### fid = open('gaussmap_dna.xyz','w') max_gauss = 0 for k in gauss_map: if len(k) > max_gauss: max_gauss = len(k) for k in range(len(gauss_map)): fid.write('%i\n%i\n'%(max_gauss+4,frames[k])) fid.write('E %.2f 0 0\n'%dd) fid.write('E 0 %.2f 0\n'%dd) fid.write('E 0 0 %.2f\n'%dd) fid.write('V 0 0 0\n') for i in gauss_map[k]: fid.write('N %.3f %.3f %.3f\n'%(i[0],i[1],i[2])) for i in range(max_gauss - len(gauss_map[k])): fid.write('N 0 0 0\n') fid.close() ########### fid = open('gaussmap_dna_step.xyz','w') max_gauss = 0 step = 10 for k in gauss_map: if len(k) > max_gauss: max_gauss = len(k) max_gauss = max_gauss*step for s in range(0,len(gauss_map)-step,step): fid.write('%i\n\n'%(max_gauss+4)) fid.write('E 1 0 0\n') fid.write('E 0 1 0\n') fid.write('E 0 0 1\n') fid.write('V 0 0 0\n') count = 4 for k in range(s,s+step): for i in gauss_map[k]: fid.write('N %.3f %.3f %.3f\n'%(i[0],i[1],i[2])) count+=1 for i in range(max_gauss+4 - count): fid.write('N 0 0 0\n') fid.close()
y = float(line.split()[2]) z = float(line.split()[3]) positions.append([x,y,z]) fid.close() #Transform L = np.array([50,50,50]) w = np.array([[1,0,0],[0,1,0],[0,0,1]]) V = np.array([0,0,0]) x_r = points.unit(np.array(orientations[1])) y_r = points.unit(np.array(orientations[2])) z_r = points.unit(np.array(orientations[3])) v = np.array([x_r,y_r,z_r]) print points R = points.reference_rotation(w,v) location = [] for i in range(len(P)): d = points.dist(V,P[i],L)[0] c_r = points.unit(points.vector1d(V,P[i],L)) location.append(points.unit(np.dot(R,np.transpose(c_r)))*d) #write out positions.extend([0,0,0]) fid.open('cube_unit_cell.xyz','w') fid.write('%i \n\n'%(len(positions)*len(location))) for i in range(len(positions)): for j in range(len(location)): x = location[j][0] + positions[i][0] y = location[j][1] + positions[i][1] z = location[j][2] + positions[i][2]
def polymer_gauss(M,VW, Z,L, frames, rcut=1.0, step=5e4): #\brief find the gauss map of polymers surrounding NC try: #V = util.pickle_load('V.pkl') P = util.pickle_load('M.pkl') except: P = M.cord_auto(['M']) util.pickle_dump(P,'M.pkl') A = VW.shape[1]/2 gauss_map = [] w = np.array([[1,0,0],[0,1,0],[0,0,1]]) ndna = P.shape[1]/VW.shape[1] print P.shape for k in frames: location = [] print k try: for i in range(VW.shape[1]): #we must rotate about a specific cube reference frame if i in range(1): V = VW[k][i] x_r = points.unit(points.vector1d(V,Z[k][i*6+1],L[k])) y_r = points.unit(points.vector1d(V,Z[k][i*6+2],L[k])) z_r = points.unit(points.vector1d(V,Z[k][i*6+5],L[k])) v = np.array([x_r,y_r,z_r]) R = points.reference_rotation(v,w) for j in range(1,ndna,2): d = points.dist(V,P[k][j+i*ndna],L[k])[0] c_r = points.unit(points.vector1d(V,P[k][j+i*ndna],L[k])) location.append(points.unit(np.dot(R,np.transpose(c_r)))*d) except: print 'something went wrong here' gauss_map.append(location) ######### #fid = open('gaussmap_polymer.xyz','w') #max_gauss = 0 #for k in gauss_map: # if len(k) > max_gauss: # max_gauss = len(k) #for k in range(len(gauss_map)): # fid.write('%i\n%i\n'%(max_gauss+4,frames[k])) # fid.write('E 1 0 0\n') # fid.write('E 0 1 0\n') # fid.write('E 0 0 1\n') # fid.write('V 0 0 0\n') # for i in gauss_map[k]: # fid.write('N %.3f %.3f %.3f\n'%(i[0],i[1],i[2])) # for i in range(max_gauss - len(gauss_map[k])): # fid.write('N 0 0 0\n') #fid.close() ########### fid = open('gaussmap_polymers_total.xyz','w') max_gauss = 0 for k in gauss_map: if len(k) > max_gauss: max_gauss = len(k) max_gauss = max_gauss*len(gauss_map) fid.write('%i\n\n'%(max_gauss+4)) fid.write('E 1 0 0\n') fid.write('E 0 1 0\n') fid.write('E 0 0 1\n') fid.write('V 0 0 0\n') count = 4 for k in range(len(gauss_map)): for i in gauss_map[k]: fid.write('N %.3f %.3f %.3f\n'%(i[0],i[1],i[2])) count+=1 fid.close()