def _load_final_fe(final_results_dir, ref_ligands, weight_scheme, combining_rule, FF): """ :param final_results_dir: str :param ref_ligands: list of str :param weight_scheme: str :param combining_rule: str :param score_file: str :return final_fes: dict {ref_ligand (str): {ligand (str): fe (float)}} """ final_fes = {} for ref_ligand in ref_ligands: fe_file = os.path.join(final_results_dir, ref_ligand + weight_scheme, combining_rule, FF + ".score") print("Loading file for final fes:", fe_file) fes, _ = load_scores(fe_file, 0, 1, 2, exclude_ligands=[]) fes.pop(ref_ligand) final_fes[ref_ligand] = fes return final_fes
parser.add_argument("--ligands_to_scale_error", type=str, default="") parser.add_argument("--error_scale_factor", type=float, default=1.) args = parser.parse_args() exclude_ligands_from_scatter_plots = args.exclude_ligands_from_scatter_plots.split( ) print("exclude_ligands_from_scatter_plots ", exclude_ligands_from_scatter_plots) print("subtract_self_rbfe ", args.subtract_self_rbfe) print("compare_absolute ", args.compare_absolute) ligands_to_scale_error = args.ligands_to_scale_error.split() yank_scores, yank_stds = load_scores(args.yank_results, 0, 1, 2, []) weighting_schemes_ref_ligands = glob.glob( os.path.join(args.algdock_results_dir, "*", args.averaging_rule, args.algdock_score_file)) weighting_schemes_ref_ligands = [ file_name.split("/")[-3] for file_name in weighting_schemes_ref_ligands ] weighting_schemes = [] for scheme_ligand in weighting_schemes_ref_ligands: for ligand in SIX_YANK_SYSTEMS: if ligand in scheme_ligand: scheme = scheme_ligand.split(ligand)[-1] weighting_schemes.append(scheme)
print("Ref ligands:\n" + "\n".join(ref_ligands)) error_scales = [float(s) for s in args.error_scales.split()] print("error_scales", error_scales) ylims = args.ylims.split() if len(ylims) == 0: ylims = [None for _ in ref_ligands] assert len(ref_ligands) == len(error_scales) == len(ylims), "wrong length" target_ligands = [lig for lig in exper_bfes.keys() if lig not in ref_ligands] print("Target ligands:\n" + "\n".join(target_ligands)) # load yank results yank_bfes, _ = load_scores(args.yank_results, 0, 1, 2, exclude_ligands=[]) # rbfe WITH CV if args.control_variate == "with": algdock_bfes = {} # algdock_bfes[ref_ligand][target_ligand] -> float algdock_errors = {} for ref_ligand in ref_ligands: infile = os.path.join(args.algdock_dir, ref_ligand + args.result_dir_suffix, args.combining_rule, args.rel_bfe_file) print("Loading", infile) bfes, errors = load_scores(infile, 0, 1, 2, exclude_ligands=ref_ligands)
default="convergence_relative_est_1") #parser.add_argument( "--out_prefix", type=str, default = "convergence_relative_not_convert_2_abs_est_1") args = parser.parse_args() sample_sizes = np.array([5] + range(10, 101, 10) + range(150, 551, 50) + [576], dtype=int) #sample_sizes = np.array( range(5, 51, 5) + range(60, 91, 10) + [96], dtype=int) print sample_sizes block_weights, state_weights, single_snap_weights, stru_group_weights_equal_sys, stru_group_weights_ub_weighted = load_mbar_weights( ) yank_interaction_energies = load_interaction_energies( path=args.interaction_energies_dir) yank_fes, yank_fe_stds = load_scores(args.yank_results, 0, 1, 2, args.exclude_ligands) if args.yank_systems == "all": yank_systems = SIX_YANK_SYSTEMS elif args.yank_systems == "actives": yank_systems = FOUR_ACTIVE_YANK_SYSTEMS elif args.yank_systems == "read": yank_systems = [os.path.basename(os.getcwd())] else: raise Exception("Unknown yank systems") if len(yank_systems) > 1: if args.yank_systems != "all": raise Exception("More than one yank systems but not all 6") else: print "Loading " + args.file_to_take_all_ligands
ref_ligands = [ ligand for ligand in single_snap_weights.keys() if ligand != "systems" ] print("ref_ligands:", ref_ligands) target_ligands = YANK_LIGANDS.keys() print("target_ligands:", target_ligands) yank_interaction_energies = load_interaction_energies( path=args.interaction_energies_dir) final_rel_fes = _load_final_fe(args.final_results_dir, ref_ligands, args.weight_scheme, args.combining_rule, args.FF) yank_abs_fes, _ = load_scores(args.yank_results_file, 0, 1, 2, []) for ref_ligand in ref_ligands: print("Processing ref ligand:", ref_ligand) out_dir = ref_ligand if not os.path.isdir(out_dir): os.makedirs(out_dir) out_file_final = open(os.path.join(out_dir, "r_rmse_wrt_final.dat"), "w") out_file_final.write( "# sample_size r r_std rmse rmse_std\n") out_file_yank = open(os.path.join(out_dir, "r_rmse_wrt_yank.dat"), "w") out_file_yank.write( "# sample_size r r_std rmse rmse_std\n")