def extract_frames_from_trajectory(options): #create a temporary directory to run the model cmsfile=os.path.abspath(options.cmsfile) trjfile=os.path.abspath(options.trjfile) tmp_folder = "/tmp/extractmd_%s/" % (os.getpid()) if not os.path.exists(tmp_folder) : os.mkdir(tmp_folder) os.chdir(tmp_folder) asl_expr = options.asl basename=os.path.basename(trjfile).split('_trj')[0] csim = create_simulation(cmsfile, trjfile) # hardcode basename basename = 'solute-%s' % basename frames='::5' total_frame = csim.total_frame slice_list = _parse_frames(frames) frames = get_indices(slice_list, total_frame) # only extract PDBs extract_func = extract_pdb for i in frames: filename = "%s/%s_%05d.%s"%(tmp_folder, basename, i, 'pdb') extract_func(csim, i, filename, asl = asl_expr ) print "wrote %s pdbfiles" % i print "trajectories are in analysis/ directory" return tmp_folder, basename
def __init__(self, input_cmsname, input_trjname, clustercenter_file): """ Data members """ self.cmsname = input_cmsname self.dsim = create_simulation(input_cmsname, input_trjname) self._indexGenerator() self.hsa_data = self._initializeHSADict(clustercenter_file) self.box = self._initializePBC()
def __init__(self, input_cmsname, input_trjname, clustercenter_file): """ Data members """ self.cmsname = input_cmsname self.dsim = create_simulation(input_cmsname, input_trjname) self._indexGenerator() self.hsa_data = self._initializeHSADict(clustercenter_file) self.box = self._initializePBC()
def __init__(self, start_frame, n_frame, input_cmsname, input_trjname, center, resolution, dimensions): """ Data members """ self.cmsname = input_cmsname self.dsim = create_simulation(input_cmsname, input_trjname) self.start_frame = start_frame self.n_frame = n_frame self._indexGenerator() self._initializeGrid(center, resolution, dimensions) self.voxeldata, self.voxeldict = self._initializeVoxelDict() self.chg, self.vdw = self._getNonbondedParams() self.box = self._initializePBC()
def __init__(self, start_frame, n_frame, input_cmsname, input_trjname, center, resolution, dimensions): """ Data members """ self.cmsname = input_cmsname self.dsim = create_simulation(input_cmsname, input_trjname) self.start_frame = start_frame self.n_frame = n_frame self._indexGenerator() self._initializeGrid(center, resolution, dimensions) self.voxeldata, self.voxeldict = self._initializeVoxelDict() self.chg, self.vdw = self._getNonbondedParams() self.box = self._initializePBC()
for l in ene_data[10:]: #print l float_converted_data = [float(x) for x in l.strip("\n").split()[1:]] traj_data[l.strip("\n").split()[0]] = float_converted_data vol_list = [] print "Calculating distribution of volumes from the trajectory excluding first %.1f picosecond" % options.exclude_region for k in traj_data.keys(): #print k, traj_data[k][7] if float(k) > options.exclude_region: vol_list.append(traj_data[k][7]) mean_vol = np.mean(np.asarray(vol_list)) sd_vol = np.std(np.asarray(vol_list)) print "Mean system volume is %.2f with fluctuations %.3f" % (mean_vol, sd_vol) chemical_time_of_frame = 0 "WARNING: Current version of the script assumes that both energies and coordinates are stored at the same time interval." min_diff = 999999999 for k in traj_data.keys(): #print k, traj_data[k][7] if float(k) > options.exclude_region: frame_vol = traj_data[k][7] if abs(frame_vol - mean_vol) < min_diff: min_diff = abs(frame_vol - mean_vol) #print k, int((float(k)/1002)*1000), frame_vol, min_diff chemical_time_of_frame = int((float(k) / 1002) * 1000) print "The frame corresponding to mean volume %i, writing into a cms file ..." % chemical_time_of_frame dsim = create_simulation(options.cms_file, options.trj) dsim.cst.writeCms("test_mean_vol_config.cms", dsim.getFrame(chemical_time_of_frame))
print "Reading data from ene file..." for l in ene_data[10:]: #print l float_converted_data = [float(x) for x in l.strip("\n").split()[1:]] traj_data[l.strip("\n").split()[0]] = float_converted_data vol_list = [] print "Calculating distribution of volumes from the trajectory excluding first %.1f picosecond" % options.exclude_region for k in traj_data.keys(): #print k, traj_data[k][7] if float(k) > options.exclude_region: vol_list.append(traj_data[k][7]) mean_vol = np.mean(np.asarray(vol_list)) sd_vol = np.std(np.asarray(vol_list)) print "Mean system volume is %.2f with fluctuations %.3f" % (mean_vol, sd_vol) chemical_time_of_frame = 0 "WARNING: Current version of the script assumes that both energies and coordinates are stored at the same time interval." min_diff = 999999999 for k in traj_data.keys(): #print k, traj_data[k][7] if float(k) > options.exclude_region: frame_vol = traj_data[k][7] if abs(frame_vol - mean_vol) < min_diff: min_diff = abs(frame_vol - mean_vol) #print k, int((float(k)/1002)*1000), frame_vol, min_diff chemical_time_of_frame = int((float(k)/1002)*1000) print "The frame corresponding to mean volume %i, writing into a cms file ..." % chemical_time_of_frame dsim = create_simulation(options.cms_file, options.trj) dsim.cst.writeCms("test_mean_vol_config.cms", dsim.getFrame(chemical_time_of_frame))
mean_frame_index = 0 for k in traj_data.keys(): #print k, traj_data[k][7] if float(k) > 400: frame_vol = traj_data[k][7] if (frame_vol - mean_vol)**2 < min_diff: min_diff = abs(frame_vol - mean_vol) #print k, float(k)/1000, frame_vol, min_diff mean_frame_time = k mean_frame_index = int(float(k)) mean_frame_vol = frame_vol mean_cms_name = "mean_vol_config.cms" print "Frame %i has the closest volume (%f) to the mean." % (mean_frame_index, mean_frame_vol) print "Writing frame %i to %s." % (mean_frame_index, mean_cms_name) dsim = create_simulation(sys.argv[2], sys.argv[3]) dsim.cst.writeCms(mean_cms_name, dsim.getFrame(mean_frame_index)) """ comp_cts = [] for ffst in dsim.cst.ffsts: comp_cts.append(copy.copy(ffst.parent_structure)) oxygen_atids = self._water_oxygen_atoms[0:self._nwater] atids = self._getCombinedAtids(oxygen_atids) new_ct = mm.mmct_ct_duplicate(dsim.cst.handle) full_ct = Structure(new_ct, True ) full_ct = full_ct.extract(atids, copy_props=True)
sys.exit(1) asl_expr = None if options.asl: asl_expr = options.asl elif options.asl_file: try: asl_expr = ''.join(open(options.asl_file).readlines()) asl_expr = asl_expr.strip() except Exception, e: print "Fail to parse ASL from %s: %s"%(options.asl_file, e) sys.exit(1) cmsfile = args[0] trjfile = args[1] csim = create_simulation(cmsfile, trjfile) basename = options.basename if not basename: base_filename = os.path.basename(cmsfile) t = base_filename.split('.') if len(t) >= 2: basename = '.'.join(t[:-1]) else: # cmsfile does not contain suffix basename = base_filename total_frame = csim.total_frame if options.frames == None: frames = range(total_frame) else:
sys.exit(1) asl_expr = None if options.asl: asl_expr = options.asl elif options.asl_file: try: asl_expr = ''.join(open(options.asl_file).readlines()) asl_expr = asl_expr.strip() except Exception, e: print "Fail to parse ASL from %s: %s" % (options.asl_file, e) sys.exit(1) cmsfile = args[0] trjfile = args[1] csim = create_simulation(cmsfile, trjfile) basename = options.basename if not basename: base_filename = os.path.basename(cmsfile) t = base_filename.split('.') if len(t) >= 2: basename = '.'.join(t[:-1]) else: # cmsfile does not contain suffix basename = base_filename total_frame = csim.total_frame if options.frames == None: frames = range(total_frame) else: