From 8bbbbd19355a028bb2b3502c6748545b580ebe0d Mon Sep 17 00:00:00 2001 From: James Date: Tue, 20 Aug 2024 10:13:23 -0400 Subject: [PATCH] main function now supplies parameters to client running function so that it can be reused --- profile_dists/main.py | 46 ++++++++++++++++++++++------------------ profile_dists/version.py | 2 +- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/profile_dists/main.py b/profile_dists/main.py index eb93cf8..dae9db7 100755 --- a/profile_dists/main.py +++ b/profile_dists/main.py @@ -77,25 +77,24 @@ class CustomFormatter(ArgumentDefaultsHelpFormatter, RawDescriptionHelpFormatter return parser.parse_args() -def main(): - cmd_args = parse_args() - query_profile = cmd_args.query - ref_profile = cmd_args.ref - outdir = cmd_args.outdir - outfmt = cmd_args.outfmt - file_type = cmd_args.file_type - dist_method = cmd_args.distm - missing_threshold = cmd_args.missing_thresh - allele_mapping_file = cmd_args.mapping_file - force = cmd_args.force - match_threshold = cmd_args.match_threshold - sample_qual_thresh = cmd_args.sample_qual_thresh - skip = cmd_args.skip - count_missing_sites = cmd_args.count_missing - max_mem = cmd_args.max_mem - batch_size = cmd_args.batch_size - num_cpus = cmd_args.cpus - columns = cmd_args.columns +def run_profile_dists(params): + query_profile = params['query'] + ref_profile = params['ref'] + outdir = params['outdir'] + outfmt = params['outfmt'] + file_type = params['file_type'] + dist_method = params['distm'] + missing_threshold = params['missing_thresh'] + allele_mapping_file = params['mapping_file'] + force = params['force'] + match_threshold = params['match_threshold'] + sample_qual_thresh = params['sample_qual_thresh'] + skip = params['skip'] + count_missing_sites = params['count_missing'] + max_mem = params['max_mem'] + batch_size = params['batch_size'] + num_cpus = params['cpus'] + columns = params['columns'] @@ -109,7 +108,7 @@ def main(): run_data = RUN_DATA run_data['analysis_start_time'] = datetime.now().strftime("%d/%m/%Y %H:%M:%S") - run_data['parameters'] = vars(cmd_args) + run_data['parameters'] = params input_files = [query_profile,ref_profile,allele_mapping_file] for f in input_files: @@ -205,7 +204,6 @@ def main(): rcols_to_remove = set(rdf.columns.values.tolist()) - set(columns) - # remove columns run_data['loci_removed'] = list(qcols_to_remove) @@ -376,6 +374,12 @@ def main(): os.remove(dist_matrix_file) sys.stdout.flush() + pass + + +def main(): + cmd_args = parse_args() + run_profile_dists(vars(cmd_args)) # call main function if __name__ == '__main__': diff --git a/profile_dists/version.py b/profile_dists/version.py index cd7ca49..a6221b3 100644 --- a/profile_dists/version.py +++ b/profile_dists/version.py @@ -1 +1 @@ -__version__ = '1.0.1' +__version__ = '1.0.2'