Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add default parameters for crisprme test functionality #56

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Loading