Skip to content

Commit

Permalink
Merge pull request #56 from pinellolab/test-commandline
Browse files Browse the repository at this point in the history
add default parameters for crisprme test functionality
  • Loading branch information
ManuelTgn authored Apr 9, 2024
2 parents 6879e73 + a692ee7 commit 7dac804
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
22 changes: 16 additions & 6 deletions crisprme.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
23 changes: 22 additions & 1 deletion src/crisprme_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()

0 comments on commit 7dac804

Please sign in to comment.