parser.add_argument("-o", "--output", help="output file name", default='resp_charges.txt') args = parser.parse_args() if args.save_resp_to is None: save_resp_to = "resp_temp_dir-dont_remove/" else: save_resp_to = args.save_resp_to + "/" if os.path.exists(args.output): raise FileExistsError("Output file exists: " + args.output) if os.path.exists(save_resp_to): raise FileExistsError("Output directory exists: " + save_resp_to) molecule = run_resp(args.respin_location, save_resp_to, resp_type='two_stage', esp_fn=args.esp_filename) if args.save_resp_to is None: shutil.rmtree(save_resp_to) print("\nThe molecule with RESP charges is:") for atom in molecule: atom.print_with_charge('resp') charges.dump_charges_to_qout(molecule, "resp", args.output)
raise FileExistsError("Output file exists: " + args.output) if os.path.exists(save_resp_to): raise FileExistsError("Output directory exists: " + save_resp_to) input_type = charges_parser.input_type(args.input_charge_type) respin1, respin2 = _get_input_files(args.respin_location, respin1_fn="", respin2_fn="") # Note: the molecule is taken from one of the respin files... molecule = _read_respin(respin1)[-1] # ... but this will throw an error if the molecule in log is not the same one charges._get_charges(args.input_charge_type, args.input_charge_file, input_type, molecule) if args.dump_raw: charges.dump_charges_to_qout(molecule, args.input_charge_type, args.dump_raw) import sys sys.exit(0) if args.esp_file is not None: try: averaged_molecule = run_resp( args.respin_location, save_resp_to, resp_type='unrest', check_ivary=True, esp_fn=args.esp_file) except Exception as e: shutil.rmtree(save_resp_to) raise e if args.save_resp_to is None: shutil.rmtree(save_resp_to) else: averaged_charges, ivary_list = equivalence(
"if all charges are to be scaled.", metavar="SAVE_RESP_TO") parser.add_argument("-o", "--output", help="output file name", default='resp_charges.txt') args = parser.parse_args() if args.save_resp_to is None: save_resp_to = "resp_temp_dir-dont_remove/" else: save_resp_to = args.save_resp_to + "/" if os.path.exists(args.output): raise FileExistsError("Output file exists: " + args.output) if os.path.exists(save_resp_to): raise FileExistsError("Output directory exists: " + save_resp_to) molecule = run_resp(args.respin_location, save_resp_to, resp_type='two_stage', esp_fn=args.esp_filename) if args.save_resp_to is None: shutil.rmtree(save_resp_to) print("\nThe molecule with RESP charges is:") for atom in molecule: atom.print_with_charge('resp') charges.dump_charges_to_qout(molecule, "resp", args.output)
except Exception as e: shutil.rmtree(save_resp_to) raise e print("\nOptimizing fit quality...") if args.scale_all: regular_args = (start_charges, molecule, esp_file.field) reg_min_ratio, reg_min_ratio_rrms, compr_charges = minimize_ratio( 'regular', ratio_values, result, regular_args) else: func_args = (start_charges, esp_file.field, args.respin_location, min_resp_calc_dir, args.esp_filename, True) try: min_ratio, min_ratio_rrms, compr_charges = minimize_ratio( 'heavy', ratio_values, result, func_args) except Exception as e: shutil.rmtree(save_resp_to) raise e shutil.rmtree(min_resp_calc_dir) if not args.scale_all and args.save_resp_to is None: shutil.rmtree(save_resp_to) # TODO: plotting requires information about other charges. This would make this # script much bigger or require input from other scripts. charges._update_molecule_with_charges(molecule, compr_charges, "compr") for atom in molecule: atom.print_with_charge("compr") charges.dump_charges_to_qout(molecule, "compr", args.output)
if os.path.exists(save_resp_to): raise FileExistsError("Output directory exists: " + save_resp_to) input_type = charges_parser.input_type(args.input_charge_type) respin1, respin2 = _get_input_files(args.respin_location, respin1_fn="", respin2_fn="") # Note: the molecule is taken from one of the respin files... molecule = _read_respin(respin1)[-1] # ... but this will throw an error if the molecule in log is not the same one charges._get_charges(args.input_charge_type, args.input_charge_file, input_type, molecule) if args.dump_raw: charges.dump_charges_to_qout(molecule, args.input_charge_type, args.dump_raw) import sys sys.exit(0) if args.esp_file is not None: try: averaged_molecule = run_resp(args.respin_location, save_resp_to, resp_type='unrest', check_ivary=True, esp_fn=args.esp_file) except Exception as e: shutil.rmtree(save_resp_to) raise e if args.save_resp_to is None: shutil.rmtree(save_resp_to)