def TS_probabilities(Tdirs,coordfile,contact_args): """ Calculate the TS contact probabilities along some reaction coordinate Parameters ---------- Tdirs : list List of directory names to collect reaction coordinate file from coordfile : str Name of file containing reaction coordinate. contact_args : object Object containing the """ T = Tdirs[0].split("_")[0] coordname = coordfile.split(".")[0] if not os.path.exists("%s_profile/state_bounds.txt" % coordname): # Determine state bounds from 1D profile print "calculating state bounds" coordvst = np.concatenate([np.loadtxt("%s/%s" % (x,coordfile)) for x in Tdirs ]) if not os.path.exists("%s_profile" % coordname): os.mkdir("%s_profile" % coordname) os.chdir("%s_profile" % coordname) mid_bin, Fdata = pmfutil.pmf1D(coordvst,bins=40) xinterp, F = pmfutil.interpolate_profile(mid_bin,Fdata) minidx, maxidx = pmfutil.extrema_from_profile(xinterp,F) min_bounds, max_bounds = pmfutil.state_bounds_from_profile(xinterp,F) min_labels, max_labels = pmfutil.assign_state_labels(min_bounds,max_bounds) pmfutil.save_state_bounds(T,min_bounds,max_bounds,min_labels,max_labels) os.chdir("..") with open("%s_profile/%s_state_bounds.txt" % (coordname,T),"r") as fin: state_bins = np.array([ [float(x.split()[1]),float(x.split()[2])] for x in fin.readlines() if x.split()[0].startswith("TS")]) else: # Load state bounds with open("%s_profile/state_bounds.txt" % coordname,"r") as fin: state_bins = np.array([ [float(x.split()[1]),float(x.split()[2])] for x in fin.readlines() if x.split()[0].startswith("TS")]) # Calculate the contact probability in TS print "calculating TS" contact_args.bins = state_bins bin_edges, qi_vs_Q = simulation.calc.binned_contacts.calculate_binned_contacts_vs_q(contact_args) TS = qi_vs_Q[0,:] return TS
# coordfile = "qtanh.npy" # get directories tempdirs = glob.glob("T_*_1") + glob.glob("T_*_2") + glob.glob("T_*_3") organized_temps = util.get_organized_temps(temperature_dirs=tempdirs) T = organized_temps.keys() T.sort() # determine which temperature is closest to the folding temperature os.chdir(coordname + "_profile") if not (os.path.exists("T_used") and os.path.exists("minima.dat")): dF_min_idx = np.argmin([(float(open("T_{}_stab.dat".format(x)).read())) ** 2 for x in T]) T_used = T[dF_min_idx] mid_bin = np.loadtxt("T_{}_mid_bin.dat".format(T_used)) Fdata = np.loadtxt("T_{}_F.dat".format(T_used)) xinterp, F = pmfutil.interpolate_profile(mid_bin, Fdata) minidx, maxidx = pmfutil.extrema_from_profile(xinterp, F) np.savetxt("minima.dat", xinterp[minidx]) with open("T_used.dat", "w") as fout: fout.write(str(T_used)) U = xinterp[minidx].min() N = xinterp[minidx].max() else: with open("T_used", "r") as fin: T_used = float(fin.read()) minima = np.loadtxt("minima.dat") U = minima.min() N = minima.max() os.chdir("..")