def vmd_load_molecule(coordsfile, filetype="lammpsdata", dcd=None, selection="all", scale=1.0, molid=0, vmd_material="Basic1Pantone", style="CPK 1.000000 0.300000 12.000000 12.000000"): """ """ if not molecule.exists(molid): # load molecule in vmd if dcd is not None: molecule.load(filetype, coordsfile, "dcd", dcd) else: molecule.load(filetype, coordsfile) molrep.modrep(molid, 0, style=style, material=vmd_material, color="Name", sel=selection) #trans.scale(scale) VMD.evaltcl("scale to {}".format(scale))
def load_traj(TOP, TRAJ, beg_frame, end_frame, stride): """ Loads in topology and trajectory into VMD Parameters ---------- TOP: MD Topology TRAJ: MD Trajectory beg_frame: int end_frame: int stride: int Returns ------- trajid: int simulation molid object """ top_file_type = get_file_type(TOP) traj_file_type = get_file_type(TRAJ) trajid = molecule.load(top_file_type, TOP) if TRAJ is not None: molecule.read(trajid, traj_file_type, TRAJ, beg=beg_frame, end=end_frame, skip=stride, waitfor=-1) else: molecule.read(trajid, top_file_type, TOP, beg=beg_frame, end=end_frame, skip=stride, waitfor=-1) return trajid
def load_traj(top_path, traj_path): top_file_type = getFileType(top_path) trajid = molecule.load(top_file_type, top_path) if (traj_path != None): traj_file_type = getFileType(traj_path) molecule.read(trajid, traj_file_type, traj_path, beg=start, end=stop, skip=stride, waitfor=-1)
def getWaterLocations(f, TOP, TRAJ, printNumFrames): print("Start getWaterLocations()") molid = molecule.load(getFileType(TOP), TOP) molecule.read(molid, getFileType(TRAJ), TRAJ, beg=1, end=-1, skip=1, waitfor=-1) n_frames = molecule.numframes(molid) if(printNumFrames): f.write("numFrames:" + str(n_frames) + "\n") grid = create_grid(n_frames) print_file_header(f) waters = atomsel.atomsel('water', molid= molid) # waters = atomsel.atomsel('resname IP3', molid= molid) coords = getAllCoords(molid, n_frames) return grid, waters, coords, n_frames
def load_traj(top_path, traj_path): """ Load trajectory and topology into VMD display """ top_file_type = getFileType(top_path) trajid = molecule.load(top_file_type, top_path) if (traj_path != None): traj_file_type = getFileType(traj_path) molecule.read(trajid, traj_file_type, traj_path, beg=start, end=stop, skip=stride, waitfor=-1)
def load_traj(struct_file_name, traj_file_names): struct_file_name = struct_file_name.replace("_strip_waters", "") top_file_type = getFileType(struct_file_name) print("topo name", struct_file_name) trajid = molecule.load(top_file_type, struct_file_name) for traj_index, traj_file_name in enumerate(traj_file_names): if (traj_index > 0): break traj_file_name = traj_file_name.replace("_strip_waters", "") print("traj name", traj_file_name) traj_file_type = getFileType(traj_file_name) molecule.read(trajid, traj_file_type, traj_file_name, beg=start, end=stop, skip=stride, waitfor=-1) print("Finished Loading Trajectory") molrep.delrep(0, 0) if (display_mode == "-d"): molrep.addrep(0, style='NewRibbons', color='ColorID 8', selection="protein") # molrep.addrep(0, style = 'HBonds 3.0 110', selection = 'protein and not carbon', color = 'Type') molrep.addrep( 0, style='HBonds 3.8 70', selection="(water within 3.5 of protein) or protein and not carbon", color="Type") molrep.set_autoupdate(0, 1, 1) elif (display_mode == "-s"): molrep.addrep(0, style="VDW", selection="name CA", material="Transparent") else: print("Input Format Incorrect") exit(1) animate.goto(0)
def load_top(TOPOLOGY, DISPLAY_MODE): top_file_type = getFileType(TOPOLOGY) trajid = molecule.load(top_file_type, TOPOLOGY) molrep.delrep(0, 0) # molrep.addrep(0, selection= "water within 4 of protein") if (DISPLAY_MODE == "-d"): molrep.addrep(0, style="NewRibbons", color="ColorID 8", material="Transparent", selection="protein") elif (DISPLAY_MODE == "-s"): molrep.addrep(0, style="NewRibbons", color="ColorID 8", material="Transparent", selection="protein") molrep.addrep(0, style="CPK", color="ColorID 8", material="Transparent", selection="name CA")
t0=time() coord_ent.selectIds(sel) t1=time() atomsel.atomsel(sel) t2=time() print "MSYS: %s ms" % ((t1-t0)*1000) print "VMD: %s ms" % ((t2-t1)*1000) return rc if len(sys.argv)<2: DMSROOT='tests/files' path='%s/2f4k.dms' % DMSROOT else: path=sys.argv[1] coord_vmd=molecule.load(path.split('.')[-1], path) coord_ent = msys.Load(path) coord_ent.select('none') compare_atomsel(coord_ent,"protein or water and element O") compare_atomsel(coord_ent,"protein and water or element O") compare_atomsel(coord_ent,"protein or (water and element O)") compare_atomsel(coord_ent,"(protein and water) or element O") compare_atomsel(coord_ent,"ctnumber 1") compare_atomsel(coord_ent,"ctnumber 2") compare_atomsel(coord_ent,"ctnumber 3") compare_atomsel(coord_ent,"ctnumber 4") compare_atomsel(coord_ent,"all") compare_atomsel(coord_ent,"none") compare_atomsel(coord_ent,"index 10 20 30",perf=True)
strout+= (' ' + str(a)) strout+='}' return strout #Add a bunch of toy sphere molecules z0=3.33 #two spheres in x direction for x in np.linspace(5,45,5): #two sphere in y direction for y in np.linspace(5,45,5): for z0 in [3.]: #load the O atom from O.pdb O=load('pdb','O.pdb') #Move the O atom into the right place all=atomsel() all.moveby([x,y,z0]) #Set resid to 0 (for now, doesn't matter, just needs to be something # so that the simulation program isn't unhappy all=atomsel() all.set('resid',0) #So far we have 26 molecfules (1 graphene, 25 O). We need to combine them into one thing #so that we can treat them together. We use topotools to do this combined=evaltcl('::TopoTools::mergemols %s'%list2tcl(molecule.listall()))
def maeToPdb(input_mae_path, output_pdb_file_path): molid = molecule.load('mae', input_mae_path) molecule.write(molid, 'pdb', output_pdb_file_path) print("Finished Conversion for: " + str(input_mae_path))
home) # change the scene VMD.evaltcl("display shadows off") color_display = color.get_colormap("Display") color_display["Background"] = "white" color.set_colormap("Display", color_display) display.set(depthcue=0) # load mol and change its representation # geometry optimized cbz licor_style = "Licorice 0.1 50 50" sel_no_h = "not element H" if molecule.exists(0) != 1: molecule.load("xyz", cbz_gOpt) molrep.modrep(0, 0, sel=sel_no_h, style=licor_style, material="AOChalky", color="ColorID 7") if molecule.exists(1) != 1: #molecule.load("lammpsdata", cbz_gaff2_lmpdat, "dcd", cbz_gaff2_dcd) molecule.load("lammpsdata", cbz_gaff2_lmpdat) molrep.modrep(1, 0, sel=sel_no_h, style=licor_style, material="AOChalky",
def loadTopology(top_file_path): global trajid input_top_file_type = getFileType(top_file_path) trajid = molecule.load(input_top_file_type, top_file_path) return trajid
def load_traj(TOP_PATH): top_file_type = getFileType(TOP_PATH) trajid = molecule.load(top_file_type, TOP_PATH)
self.trj_changes.plotDistance(('(A)ASP-1:CA', '(A)SER-20:CA'), lam=self.lam) def test_matrixPlotChange(self): changes = self.trj_changes.changes(self.lam) v = changes.values()[0] self.trj_changes.matrixPlotChange(v, lam=self.lam) ############################## # Visualizing changes in VMD # ############################## class TestVMDDisplay(unittest.TestCase): def setUp(self): from analyze_changed_distances import WorkdirChanges wkdir_changes = WorkdirChanges('all_pairs') common_changes = wkdir_changes.commonResidueChangesByNumChangeTimes(100) self.changes = wkdir_changes.trajectoryChanges('serial').changesByNumChangeTimes(100, residue_pairs=common_changes) assert len(self.changes) def test_VMDDisplay(self): from analyze_changed_distances import VMDDisplay VMDDisplay(self.changes, window=5, molid=0) if __name__ == '__main__': os.chdir(os.getenv('EXAMPLESDIR', 'examples')) molid = molecule.load('mae', 'TrpCage.mae') VMDevaltcl('mol addfile {TrpCage.dcd} type {dcd} first 0 last -1 step 1 waitfor all 0') cv.set_times(molid, np.loadtxt('TrpCage.times.txt')) unittest.main(verbosity=2)
self.trj_changes.matrixPlotChange(v, lam=self.lam) ############################## # Visualizing changes in VMD # ############################## class TestVMDDisplay(unittest.TestCase): def setUp(self): from analyze_changed_distances import WorkdirChanges wkdir_changes = WorkdirChanges('all_pairs') common_changes = wkdir_changes.commonResidueChangesByNumChangeTimes( 100) self.changes = wkdir_changes.trajectoryChanges( 'serial').changesByNumChangeTimes(100, residue_pairs=common_changes) assert len(self.changes) def test_VMDDisplay(self): from analyze_changed_distances import VMDDisplay VMDDisplay(self.changes, window=5, molid=0) if __name__ == '__main__': os.chdir(os.getenv('EXAMPLESDIR', 'examples')) molid = molecule.load('mae', 'TrpCage.mae') VMDevaltcl( 'mol addfile {TrpCage.dcd} type {dcd} first 0 last -1 step 1 waitfor all 0' ) cv.set_times(molid, np.loadtxt('TrpCage.times.txt')) unittest.main(verbosity=2)
tic = time.clock() if (len(sys.argv) < 4): print "Usage: python wrapAlignAmber.py <topology file> <trajectory file> <out wrapped trajectory file>" sys.exit() #### Read in input topology, trajectory files, outTraj file top_file = sys.argv[1] traj_file = sys.argv[2] out_traj_file = sys.argv[3] if ("-crys" in sys.argv): include_crys = True else: include_crys = False #### load topology and trajectories traj_molid = molecule.load('pdb', top_file) molecule.read(traj_molid, 'netcdf', traj_file, beg=0, end=-1, waitfor=-1) #### align all frames refsel = atomsel("protein", molid=traj_molid, frame=0) for i in range(molecule.numframes(traj_molid)): molecule.set_frame(traj_molid, i) b = atomsel("protein", molid=traj_molid, frame=i) T = b.fit(refsel) atomsel("all", molid=traj_molid, frame=i).move(T) #### Read out file if (include_crys == True): molecule.write(traj_molid, 'dcd', out_traj_file, beg=0, end=-1) else: molecule.write(traj_molid, 'dcd', out_traj_file, beg=1, end=-1)
sys.exit() #### Read in input topology, trajectory files, outTraj file (top_file, traj_dir, traj_file_type, out_traj_file) = (sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4]) createDirectory(out_traj_file) output_directory = os.path.dirname(out_traj_file) #### Copy topology file to output directory # print("cp " + top_file + " " + output_directory) os.system("cp " + top_file + " " + output_directory) print("Subsampling Trajectory: " + traj_dir) #### load topology and trajectories traj_molid = molecule.load(getFileType(top_file), top_file) if (traj_file_type == "nc"): traj_fragments_list = glob.glob(traj_dir + "/Prod_*/Prod_*.nc") elif (traj_file_type == "dcdconvert"): traj_fragments_list = glob.glob(traj_dir + "/Prod_*/Prod_*.dcd") elif (traj_file_type == "dcd"): traj_fragments_list = glob.glob(traj_dir + "/*.dcd") traj_fragments_list.sort(key=natural_keys) for index, traj_fragment_file in enumerate(traj_fragments_list): print("Fragment Index " + str(index) + " : " + traj_fragment_file) molecule.read(traj_molid, getFileType(traj_fragment_file), traj_fragment_file, beg=0, end=-1,