def get_origin_translation(asu_prmtop_file_name, asu_rst7_file_name): rst7 = raf.rst7(asu_rst7_file_name) coords = rst7.Get_Coords() UCbox = rst7.Get_Box() u,invu = raf.CompXfrm(UCbox) masses = raf.prmtop(asu_prmtop_file_name).Get_Masses() com = raf.COM(coords,masses) frac_com = dot(u, com) origin_translation = array([0.5, 0.5, 0.5]) - frac_com return u, origin_translation
def get_origin_translation(asu_prmtop_file_name, asu_rst7_file_name): rst7 = raf.rst7(asu_rst7_file_name) coords = rst7.Get_Coords() UCbox = rst7.Get_Box() u, invu = raf.CompXfrm(UCbox) masses = raf.prmtop(asu_prmtop_file_name).Get_Masses() com = raf.COM(coords, masses) frac_com = dot(u, com) origin_translation = array([0.5, 0.5, 0.5]) - frac_com return u, origin_translation
#! /usr/bin/env python import ReadAmberFiles as raf iprmtop=raf.prmtop('/net/casegroup2/u2/pjanowsk/Case/4lzt/4lzt_ff12SB/4lztSh_new.prmtop') masses=iprmtop.Get_Masses() totalmass=sum(masses) irst7=raf.rst7('/net/casegroup2/u2/pjanowsk/Case/4lzt/4lzt_ff12SB/4lztSh.rst7') box=irst7.Get_Box() volume=raf.Get_volume(box) density= totalmass/volume*10/6.022 print "density: %8.3f g/cm^3" %density
#mass-weighted covariance matrix is already calculated cv=genfromtxt('mwcvmat.dat') l,v=linalg.eig(cv) s=argsort(l)[::-1] #convert eigenvalues to frequencies in cm-1 f=zeros((nmodes)) for i in range(len(l)): if l[i]<0: f[i]= -108.587*sqrt(-0.6/l[i]) elif l[i]>0: f[i]= 108.587*sqrt(0.6/l[i]) else: f[i]=0 l[s] v[:,s] #sort columns #get masses and un-mass weigh the modes m=raf.prmtop("na.prmtop").Get_Masses() m=[[i]*3 for i in m] m=[item for sublist in m for item in sublist] for vec in range(v.shape[1]): v[:,vec]=v[:,vec]/sqrt(m) #calculate rmsf fluctuations along modes CNST=2.776904e-11 #tkbc2*avogadro's CONT=1.591549e+07 #(ang/cm / 2pi) for atom in range(natoms): sum, sumx, sumy, sumz=0,0,0,0 for mode in range(nmodes):
# mass aligns with the experimental center of mass. # # # #======================================================================# parser = argparse.ArgumentParser() parser.add_argument("-p", "--AsuTopology", help="Amber single ASU topology file") parser.add_argument("-pdb", "--AsuPDB", help="Single ASU PDB file") parser.add_argument("-pdbs", "--PdbWithSymmetry", help="PDB file containing SMTRY and CRYST1 records") parser.add_argument("-prop", help="Propagation used to create the supercell. Format: \"x y z\"") args = parser.parse_args() ############################################ # SETUP # ############################################ topo = raf.prmtop(args.AsuTopology) pdb = raf.pdb(args.AsuPDB) masses=topo.Get_Masses() xtal_com=raf.COM(pdb.Get_Coords(),masses) ix=int(args.prop.split()[0]) iy=int(args.prop.split()[1]) iz=int(args.prop.split()[2]) pdbs = raf.pdb(args.PdbWithSymmetry) smtry,tr =pdbs.Get_SMTRY() asymunits=len(smtry) ########################################### # MAIN # ########################################### i=1 #counter for the names of the unitcell trajectories
def GenNM(obj, nmids, mode, inp=None, amp=50., nframes=20, dump_file=False, \ prmtop=None): nmids=[int(i) for i in nmids.split()] amp = float(amp) nframes=int(nframes) mode=int(mode) stored.NMA = {} stored.NMA[obj] = {} if mode==1: if not inp: print "Please specify cpptraj covariance matrix file" return 0 if (not prmtop): print "Please specify prmtop file for proper mass reweighing of vectors." return 0 print "Attempting to read mwcov matrix %s" %inp mwcvmat=genfromtxt(inp) print "Diagonalizing covariance matrix." w,v = linalg.eig(mwcvmat) #sort from largest eigenvvalue to smallest si=argsort(w)[::-1] w=w[si] v=v[:,si] #convert to cm-1 for i in range(len(w)): if w[i]<0: w[i]= -108.587*sqrt(-0.6/w[i]) elif w[i]>0: w[i]= 108.587*sqrt(0.6/w[i]) else: w[i]=0 #get masses and un-mass weigh the modes m=raf.prmtop(prmtop).Get_Masses() m=[[i]*3 for i in m] m=[item for sublist in m for item in sublist] for vec in range(v.shape[1]): v[:,vec]=v[:,vec]/sqrt(m) #store stored.NMA[obj]['w'] = w stored.NMA[obj]['v'] = v elif mode==2: if not inp: print "Please specify evecs frequency/eigenvector file" return 0 print "Attempting to read evecs file %s" %inp stored.NMA[obj]['w'], stored.NMA[obj]['v'] = ReadEvecs(inp) elif mode==3: if not inp: print "Please specify pickled normal mode object" return 0 print "Attempting to read pickle file %s" %inp stored.NMA[obj]=pickle.load( open(inp,"rb")) if dump_file: print "Dumping eigenvalues and modes to pickle file." pickle.dump(stored.NMA[obj], open(dump_file,"wb") ) w = stored.NMA[obj]['w'] v = stored.NMA[obj]['v'] print "%7s%20s%20s" % ('NMID', 'f Hz', 'f cm^-1') for i in range(min(w.size,20)): print "%7d%20.5e\t%20.5f" % (i, w[i]*2.99792458e10, w[i]), if i in nmids: print "*" else: print "" for nmid in nmids: newobj = "%s-nm_%d" % (obj, nmid) cmd.delete(newobj) nm = real(v[:,nmid]) nm *= amp/sqrt((nm**2).sum()) for ifr in range(nframes): cmd.create(newobj, obj, 1, ifr+1) stored.nm = nm*sin(2.*pi*ifr/nframes) cmd.alter_state(ifr+1, newobj, "x,y,z = x+stored.nm[(ID-1)*3], y+stored.nm[(ID-1)*3+1], z+stored.nm[(ID-1)*3+2]")