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 generateNewTrajectory(top_file_path, traj_file_path, output_traj_file_name): trajid = loadTopology(top_file_path) input_traj_file_type = getFileType(traj_file_path) molecule.read(trajid, input_traj_file_type, traj_file_path, beg=start, end=stop, skip=stride, waitfor=-1) output_traj_file_type = getFileType(output_traj_file_name) selection = atomsel.atomsel(query, molid=trajid) molecule.write(trajid, output_traj_file_type, output_traj_file_name, beg=1, end=-1, selection=selection)
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(self, filename, filetype=None, first=0, last=-1, step=1, waitfor=-1, volsets=[0]): """ Load molecule data from the given file. The filetype will be guessed from the filename extension; this can be overridden by setting the filetype option. first, last, and step control which coordinates frames to load, if any. """ if filetype is None: filetype = self._guessFiletype(filename) if molecule.read(self.id, filetype, filename, first, last, step, waitfor, volsets) < 0: raise IOError, "Unable to load file: %s" % filename return self
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)
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)
ag_vmd.vmd_load_molecule(SYSPREP_LMPDAT, style="Lines 1.000", molid=CURCYCLE) molrep.set_visible(CURCYCLE, 0, False) # add representations for CSEL in SELECTIONS: molrep.addrep(CURCYCLE, style=CSEL["style"], color=CSEL["color"], selection=CSEL["selection"], material=CSEL["material"]) # quenching QUENCH_DCD = QUENCH_DCD_RAW.format(MAINDIR, CURCYCLE) molecule.read(CURCYCLE, "dcd", QUENCH_DCD, beg=0, end=-1, waitfor=-1) # annealing - heating up EQUIL_ANNEAL_DCD = EQUIL_ANNEAL_DCD_RAW.format(MAINDIR, CURCYCLE) molecule.read(CURCYCLE, "dcd", EQUIL_ANNEAL_DCD, beg=0, end=-1, waitfor=-1) # annealing - productive ANNEAL_DIR = "{}/anneal_{}".format(MAINDIR, CURCYCLE) PROD_ANNEAL_DCDS = get_files( "{0}/anneal_{1}/".format(ANNEAL_DIR, CURCYCLE), PROD_ANNEAL_DCD_RAW.format(CURCYCLE))
#### 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, skip=100, waitfor=-1) if (traj_file_type == "dcd"): evaltcl('package require pbctools') evaltcl( 'pbc wrap -compound residue -center com -centersel "protein" -all') #### 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)