From 537c15cf3feeede336d1313f0abea6f71a0e79d2 Mon Sep 17 00:00:00 2001 From: MehtapIsik Date: Fri, 14 Jul 2017 14:12:20 -0400 Subject: [PATCH 1/2] Modified quickmodel to output an extra csv file of DeltaG and Kd estimates. --- scripts/quickmodel.py | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/scripts/quickmodel.py b/scripts/quickmodel.py index 7fc3368..37ab1f2 100644 --- a/scripts/quickmodel.py +++ b/scripts/quickmodel.py @@ -33,8 +33,11 @@ def quick_model(inputs, nsamples=1000, nthin=20): Thinning interval ; number of MCMC steps per sample collected """ + [complex_fluorescence, ligand_fluorescence] = parser.get_data_using_inputs(inputs) - [complex_fluorescence, ligand_fluorescence] = parser.get_data_using_inputs(inputs) + # List to store DeltaG and Kd estimates for generating summary csv table. + deltaG_output_summary_list = [] + Kd_output_summary_list = [] for name in complex_fluorescence.keys(): @@ -65,8 +68,8 @@ def quick_model(inputs, nsamples=1000, nthin=20): assay_volume=inputs['assay_volume'], DG_prior='uniform') import datetime - my_datetime = datetime.datetime.now().strftime("%Y-%m-%d %H:%M") - my_datetime_filename = datetime.datetime.now().strftime("%Y-%m-%d %H%M") + my_datetime = datetime.datetime.now().strftime("%Y-%m-%d_%H:%M") + my_datetime_filename = datetime.datetime.now().strftime("%Y-%m-%d_%H%M") nburn = 0 # no longer need burn-in since we do automated equilibration detection niter = nthin*nsamples # former total simulation time @@ -232,9 +235,38 @@ def quick_model(inputs, nsamples=1000, nthin=20): metadata['Lstated'] = metadata['Lstated'].tolist() import json - with open('%s-%s.json'%(name,my_datetime), 'w') as outfile: + with open('%s-%s.json'%(name,my_datetime_filename), 'w') as outfile: json.dump(metadata, outfile, sort_keys = True, indent = 4, ensure_ascii=False) + # Append Delta G and K_d estimates to summary list, for writing out a summary table. + protein_name = name.split("-")[0] + ligand_name = name.split("-")[1] + DeltaG_mean = interval[1] + DeltaG_lower_CI = interval[0] # 95% Credibility intervals + DeltaG_upper_CI = interval[2] + DeltaG_STD = dDeltaG_equil + Kd_mean = Kd_interval[1] + Kd_lower_CI = Kd_interval[0] + Kd_upper_CI = Kd_interval[2] + Kd_STD = dKd + deltaG_output_summary_list.append((protein_name, ligand_name, "DeltaG", DeltaG_mean, DeltaG_lower_CI, + DeltaG_upper_CI, DeltaG_STD, "k_BT")) + Kd_output_summary_list.append((protein_name, ligand_name, "K_d", Kd_mean, Kd_lower_CI, Kd_upper_CI, + Kd_STD, "M")) + + # Save DeltaG and K_d estimates of all analyzed experiments in a summary csv file. + summary_file_name = "%s-delG-and-Kd-summary-%s.csv" % (protein_name, my_datetime_filename) + writer = open(summary_file_name, "w") + # Write column names + writer.write("%s,%s,%s,%s,%s,%s,%s,%s\n"%("Protein", "Ligand", "Parameter", "Mean", "Lower 95% CrI", + "Upper 95% CrI", "STD", "Unit")) + # Write values + for summary_tuple in deltaG_output_summary_list: + writer.write("%s,%s,%s,%.3g,%.3g,%.3g,%.3g,%s\n" %summary_tuple) + for summary_tuple in Kd_output_summary_list: + writer.write("%s,%s,%s,%.3g,%.3g,%.3g,%.3g,%s\n" %summary_tuple) + + def entry_point(): import sys From aaf1170bd2ee64c591335d35c9cf2c50891d1182 Mon Sep 17 00:00:00 2001 From: MehtapIsik Date: Fri, 14 Jul 2017 15:06:40 -0400 Subject: [PATCH 2/2] Corrected mean and median values in csv output of Quickmodel. --- scripts/quickmodel.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/scripts/quickmodel.py b/scripts/quickmodel.py index 37ab1f2..a3693b4 100644 --- a/scripts/quickmodel.py +++ b/scripts/quickmodel.py @@ -241,30 +241,32 @@ def quick_model(inputs, nsamples=1000, nthin=20): # Append Delta G and K_d estimates to summary list, for writing out a summary table. protein_name = name.split("-")[0] ligand_name = name.split("-")[1] - DeltaG_mean = interval[1] + DeltaG_median = interval[1] DeltaG_lower_CI = interval[0] # 95% Credibility intervals DeltaG_upper_CI = interval[2] + DeltaG_mean = DeltaG_equil DeltaG_STD = dDeltaG_equil - Kd_mean = Kd_interval[1] + Kd_median = Kd_interval[1] Kd_lower_CI = Kd_interval[0] Kd_upper_CI = Kd_interval[2] + Kd_mean = Kd Kd_STD = dKd - deltaG_output_summary_list.append((protein_name, ligand_name, "DeltaG", DeltaG_mean, DeltaG_lower_CI, - DeltaG_upper_CI, DeltaG_STD, "k_BT")) - Kd_output_summary_list.append((protein_name, ligand_name, "K_d", Kd_mean, Kd_lower_CI, Kd_upper_CI, - Kd_STD, "M")) + deltaG_output_summary_list.append((protein_name, ligand_name, "DeltaG", DeltaG_median, DeltaG_lower_CI, + DeltaG_upper_CI, DeltaG_mean, DeltaG_STD, "k_BT")) + Kd_output_summary_list.append((protein_name, ligand_name, "K_d", Kd_median, Kd_lower_CI, Kd_upper_CI, + Kd_mean, Kd_STD, "M")) # Save DeltaG and K_d estimates of all analyzed experiments in a summary csv file. summary_file_name = "%s-delG-and-Kd-summary-%s.csv" % (protein_name, my_datetime_filename) writer = open(summary_file_name, "w") # Write column names - writer.write("%s,%s,%s,%s,%s,%s,%s,%s\n"%("Protein", "Ligand", "Parameter", "Mean", "Lower 95% CrI", - "Upper 95% CrI", "STD", "Unit")) + writer.write("%s,%s,%s,%s,%s,%s,%s,%s,%s\n"%("Protein", "Ligand", "Parameter", "Median", "Lower 95% CrI", + "Upper 95% CrI", "Mean", "STD", "Unit")) # Write values for summary_tuple in deltaG_output_summary_list: - writer.write("%s,%s,%s,%.3g,%.3g,%.3g,%.3g,%s\n" %summary_tuple) + writer.write("%s,%s,%s,%.3g,%.3g,%.3g,%.3g,%.3g,%s\n" %summary_tuple) for summary_tuple in Kd_output_summary_list: - writer.write("%s,%s,%s,%.3g,%.3g,%.3g,%.3g,%s\n" %summary_tuple) + writer.write("%s,%s,%s,%.3g,%.3g,%.3g,%.3g,%.3g,%s\n" %summary_tuple) def entry_point():