diff --git a/crisprme.py b/crisprme.py index d902067..2a26a26 100755 --- a/crisprme.py +++ b/crisprme.py @@ -1148,24 +1148,34 @@ def complete_test_crisprme(): "Diversity Project (HGDP). The default dataset is 1000 Genomes.\n" "--debug, debug mode\n" ) - if "--chrom" in input_args: + chrom = "all" + if "--chrom" in input_args: # individual chrom to test try: chrom = input_args[input_args.index("--chrom") + 1] + if chrom.startswith("--"): + sys.stderr.write("Please input some parameter for flag --chrom\n") + sys.exit(1) except IndexError: sys.stderr.write("Please input some parameter for flag --chrom\n") sys.exit(1) - if "--vcf" in input_args: + vcf_dataset = "1000G" + if "--vcf_dataset" in input_args: # specified variant dataset try: - vcf = input_args[input_args.index("--vcf") + 1] + vcf_dataset = input_args[input_args.index("--vcf_dataset") + 1] + if vcf_dataset.startswith("--"): + sys.stderr.write("Please input some parameter for flag --vcf_dataset\n") + sys.exit(1) except IndexError: - sys.stderr.write("Please input some parameter for flag --vcf\n") + sys.stderr.write("Please input some parameter for flag --vcf_dataset\n") sys.exit(1) - debug = "--debug" in input_args + debug = "--debug" in input_args # run local or via conda/Docker # begin crisprme test script_test = os.path.join( script_path.replace("PostProcess", "src"), "crisprme_test.py" + ) # the script is located within src -- TODO: start migration to src + code = subprocess.call( + f"python {script_test} {chrom} {vcf_dataset} {debug}", shell=True ) - code = subprocess.call(f"python {script_test} {chrom} {vcf} {debug}", shell=True) if code != 0: raise OSError( "\nCRISPRme test failed! See Results/crisprme-test-out/log_error.txt for details\n" diff --git a/src/crisprme_test.py b/src/crisprme_test.py index 668fcd0..53ad777 100644 --- a/src/crisprme_test.py +++ b/src/crisprme_test.py @@ -344,6 +344,21 @@ def write_samplesids_list(dataset: str) -> str: def run_crisprme_test(chrom: str, dataset: str, debug: bool) -> None: + """ + Run CRISPRme test on specified chromosome and dataset. + + Args: + chrom (str): The chromosome to run the test on. + dataset (str): The dataset to use for the test. + debug (bool): Flag to enable debug mode. + + Returns: + None + + Raises: + None + """ + check_crisprme_directory_tree(os.getcwd()) # check crisprme directory tree download_genome_data(chrom, CRISPRME_DIRS[0]) # download genome data download_vcf_data(chrom, CRISPRME_DIRS[3], dataset) # download vcf data @@ -365,5 +380,11 @@ def run_crisprme_test(chrom: str, dataset: str, debug: bool) -> None: subprocess.call(crisprme_cmd, shell=True) # run crisprme test +def main(): + chrom, dataset, debug = sys.argv[1:] # read commandline args + debug = debug == "True" + run_crisprme_test(chrom, dataset, debug) # run crisprme test + + if __name__ == "__main__": - run_crisprme_test("chr22", "1000G", True) + main()