# HG changeset patch # User agpetit # Date 1655818763 0 # Node ID 066606280457b6430787d611df57fa15b381b5e0 # Parent a4097272ade09c2b0d6eca02263e29fb3b6627c7 "planemo upload for repository https://github.com/mesocentre-clermont-auvergne/aubi_piaf commit 39e6c57933401793343e38ebe55ad3cc52a3112d" diff -r a4097272ade0 -r 066606280457 calculate_diameter.xml --- a/calculate_diameter.xml Tue Jun 14 13:26:07 2022 +0000 +++ b/calculate_diameter.xml Tue Jun 21 13:39:23 2022 +0000 @@ -6,11 +6,13 @@ mdanalysis 1: + log_dir = os.path.dirname(args.log_output) else: - if os.path.isfile(file_name_log): - os.remove(file_name_log) - logging.basicConfig( - filename=file_name_log, - format="%(levelname)s - %(message)s", - level=logging.INFO, - ) + log_dir = "log/" + try: + os.makedirs(log_dir, exist_ok=True) + except OSError: + print("Directory '%s' can not be created") + if os.path.isfile(args.log_output): + os.remove(args.log_output) + logging.basicConfig( + filename=args.log_output, + format="%(levelname)s - %(message)s", + level=logging.INFO, + ) logging.info("verbose mode on") gro_file = '' xtc_file = '' if args.gro_file: - gro_file = os.path.basename(args.gro_file[0]) - else: - logging.critical("A .gro file must be provided") - if args.xtc_file: - xtc_file = os.path.basename(args.xtc_file[0]) + gro_file = os.path.basename(args.gro_file) + if ".gro" not in gro_file: + if args.verbose: + logging.critical("-gro error: input is not .gro file") + print("-gro error: input is not .gro file") + sys.exit(1) else: - logging.critical("A .xtc file must be provided") - if args.work_directory: - work_directory = args.work_directory[0] + if args.verbose: + logging.critical("A .gro file must be provided") + print("A .gro file must be provided") + sys.exit(1) + if args.xtc_file: + xtc_file = os.path.basename(args.xtc_file) + if ".xtc" not in xtc_file: + if args.xtc_file_ext == "xtc": + xtc_file = xtc_file + ".xtc" + else: + if args.verbose: + logging.critical("-xtc error: input is not .xtc file") + print("-xtc error: input is not .xtc file") + sys.exit(1) else: - work_directory = os.path.dirname(args.gro_file[0]) - if not work_directory.endswith("/"): - work_directory += "/" - output_directory = args.output_directory[0] + if args.verbose: + logging.critical("A .xtc file must be provided") + print("A .xtc file must be provided") + sys.exit(1) + if len(os.path.dirname(args.gro_file)) > 1: + work_directory = os.path.dirname(args.gro_file) + else: + work_directory = args.work_directory + if not work_directory.endswith("/"): + work_directory += "/" + output_directory = args.output_directory if args.output: output = args.output else: @@ -1026,31 +1044,27 @@ os.chdir(work_directory) if args.gro_file_ext and args.xtc_file_ext: u = Mda.Universe( - args.gro_file[0], - args.xtc_file[0], - topology_format=args.gro_file_ext[0], - format=args.xtc_file_ext[0], + args.gro_file, + args.xtc_file, + topology_format=args.gro_file_ext, + format=args.xtc_file_ext, ) else: - u = Mda.Universe(args.gro_file[0], args.xtc_file[0]) + u = Mda.Universe(args.gro_file, args.xtc_file) if args.verbose: logging.info("Load universe : " + str(u)) + resid_npa1 = None + resid_npa2 = None + resid_arr1 = None + resid_arr2 = None if args.npa_one: resid_npa1 = args.npa_one[0].split() - else: - resid_npa1 = args.npa_one if args.npa_second: resid_npa2 = args.npa_second[0].split() - else: - resid_npa2 = args.npa_second if args.arr_one: resid_arr1 = args.arr_one[0].split() - else: - resid_arr1 = args.arr_one if args.arr_second: resid_arr2 = args.arr_second[0].split() - else: - resid_arr2 = args.arr_second df_final = create_final_dataframe(resid_arr1, resid_arr2, resid_npa1, resid_npa2, u) if len(output_directory) > 2: @@ -1062,5 +1076,5 @@ if len(output) > 2: df_final.to_csv(output, sep="\t", index=False) else: - file_name_tabular = out_file_name + "PairDist.tabular" + file_name_tabular = "Calculate_pair_dist_aqp.tabular" df_final.to_csv(file_name_tabular, sep="\t", index=False) diff -r a4097272ade0 -r 066606280457 test-data/.PIP2.1_test.xtc_offsets.npz Binary file test-data/.PIP2.1_test.xtc_offsets.npz has changed diff -r a4097272ade0 -r 066606280457 test-data/.XIP3.1_5_frames.xtc_offsets.npz Binary file test-data/.XIP3.1_5_frames.xtc_offsets.npz has changed