Mercurial > repos > agpetit > calculate_diameter
changeset 12:066606280457 draft
"planemo upload for repository https://github.com/mesocentre-clermont-auvergne/aubi_piaf commit 39e6c57933401793343e38ebe55ad3cc52a3112d"
author | agpetit |
---|---|
date | Tue, 21 Jun 2022 13:39:23 +0000 |
parents | a4097272ade0 |
children | f5064c93f7ab |
files | calculate_diameter.xml calculate_pore_diameter_aqp.py test-data/.PIP2.1_test.xtc_offsets.npz test-data/.XIP3.1_5_frames.xtc_offsets.npz |
diffstat | 4 files changed, 67 insertions(+), 51 deletions(-) [+] |
line wrap: on
line diff
--- 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 @@ <requirement type="package" version="2.1.0">mdanalysis</requirement> </requirements> <command detect_errors="exit_code"><![CDATA[ + ln -s '$gro_file' '$gro_file.element_identifier' && + ln -s '$xtc_file' '$xtc_file.element_identifier' && python '$__tool_directory__/calculate_pore_diameter_aqp.py' --arr_one '$arr1' --arr_second '$arr2' - --gro_file '$gro_file' - --xtc_file '$xtc_file' + --gro_file '$gro_file.element_identifier' + --xtc_file '$xtc_file.element_identifier' --gro_file_ext '$gro_file.ext' --xtc_file_ext '$xtc_file.ext' --output '$table'
--- a/calculate_pore_diameter_aqp.py Tue Jun 14 13:26:07 2022 +0000 +++ b/calculate_pore_diameter_aqp.py Tue Jun 21 13:39:23 2022 +0000 @@ -71,16 +71,16 @@ help="""Information messages to stderr""", ) parser.add_argument( - "-gro", "--gro_file", type=str, nargs=1, help="""My input .gro file""" + "-gro", "--gro_file", type=str, help="""My input .gro file""" ) parser.add_argument( - "-xtc", "--xtc_file", type=str, nargs=1, help="""My input .xtc file""" + "-xtc", "--xtc_file", type=str, help="""My input .xtc file""" ) parser.add_argument( - "--gro_file_ext", type=str, nargs=1, help="""My input .gro file""" + "--gro_file_ext", type=str, help="""My input .gro file""" ) parser.add_argument( - "--xtc_file_ext", type=str, nargs=1, help="""My input .xtc file""" + "--xtc_file_ext", type=str, help="""My input .xtc file""" ) parser.add_argument( "-w", "--work_directory", type=str, default="./", @@ -89,7 +89,7 @@ parser.add_argument( "-od", "--output_directory", - default="stdout", + default="out/", type=str, nargs=1, help="""It's output Directory""", @@ -125,7 +125,9 @@ help="""3-letter pattern of the 4 amino acids of second ArR on HE""", ) parser.add_argument("-o", "--output", help="""Output for files""") - parser.add_argument("-log", "--log_output", help="""Output for files""") + parser.add_argument("-log", "--log_output", + default="log/calculate_pore_diameter_aqp.log", + help="""Output for files""") return parser.parse_args() @@ -982,43 +984,59 @@ if __name__ == "__main__": args = parse_arguments() - out_file_name = "test" - file_name_log = out_file_name + ".log" if args.verbose: - if args.log_output: - 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, - ) + if len(os.path.dirname(args.log_output)) > 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)