def rd_analysis(): """For scripting purposes this function should be reorganized. Demonstrates workflow replaced by IPython Notebooks. Runs as main. Returns ------- Happy scientists """ curve_files = ['L25K_6p3_rd_600_full_heights.txt', 'L25K_6p3_rd_800_full_heights.txt'] endpt_files = ['l25k_6p3_600_rd_l9=2.txt','l25k_6p3_600_rd_l9=32.txt', 'l25k_6p3_800_rd_l9=2.txt','l25k_6p3_800_rd_l9=15.txt'] # Total R2 relaxation period (ms): CT_B1 = 38.4 CT_B2 = 28.8 # Load data; 2 field strengths, 2 data types (full curves, endpoints): # Full dispersion curve peak intensities: B1curve, B2curve = [nmrfn.parse_rd(f) for f in curve_files] B1curve['index']=B1curve.index # Eliminating triplicate measurement... B1curve = B1curve.drop_duplicates(cols='index') #... B1curve = B1curve.drop('index', axis=1) #...done. # Curve endpoints peak intensities: B1few, B1many, B2few, B2many = [nmrfn.parse_lt(f) for f in endpt_files] # Compute Rex estimates from endpoints data rexB1endpts = est_endpts(B1few, B1many, CT_B1) rexB2endpts = est_endpts(B2few, B2many, CT_B2) # Convert full dispersion curve peak intensities to R2 values B1curveR2 = calc_R2series(B1curve, CT_B1) B2curveR2 = calc_R2series(B2curve, CT_B2) # Using highest-frequency CPMG R2 as intrinsic R2: B1intR2 = B1curveR2.iloc[0,:] B2intR2 = B2curveR2.iloc[0,:] # Compute Rex estimates from fitting the full R2 curves: kex0 = 1e3 Rex0 = 1.0 rexB1fit = fit_curves(B1curveR2, B1intR2, kex0, Rex0) rexB2fit = fit_curves(B2curveR2, B2intR2, kex0, Rex0) rex_output(rexB1fit, rexB2fit, rexB1endpts, rexB2endpts) alpha_output(rexB1fit, rexB2fit, rexB1endpts, rexB2endpts) plot_r2_cpmg(B1curveR2, 'R2_series_600_MHz') plot_r2_cpmg(B2curveR2, 'R2_series_800_MHz')
print('ADDDATA\n', file = f) # Function to print curve information and normalized peak intensity vs freq def guardd_height(s, f): text = \ '''INDEX\t{0} ATOM\t{1} RESIDUE\tpending OBS\tVCPMG\tINTENSITY''' print(text.format(s.name, args.atom), file = f) norm = s.values[0] for o, t in enumerate(s.index.values, start=1): line = '{0}\t{1}\t{2}' print(line.format(o, round(t,2), round(s.iloc[o-1]/norm,3)), file = f) print('ADDDATA\n', file = f) # Actual output procedure out = open(args.fout, 'w') guardd_dataset(args.name,args.ax,args.b0,args.temp,args.CT,args.coh,out) heights = nmrfn.parse_rd(args.rh) if args.outtype == 'r2': r2_vals = calc_R2series(heights, args.CT) for res in r2_vals: guardd_r2(r2_vals[res], out) if args.outtype == 'height': for res in heights: guardd_height(heights[res], out) print('SEQUENCEFILE\t{0}'.format(args.seqlist), file = out) out.close()