Skip to content

Commit

Permalink
refactor: proper naming of wrapper scripts for logs
Browse files Browse the repository at this point in the history
  • Loading branch information
ericblanc20 committed Dec 17, 2024
1 parent 3363996 commit ba3ea51
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,10 @@ def get_result_files(self) -> list[str]:
tpl + "purity.txt",
tpl + "segments.txt",
]
for action in ("prepare_hts", "run", "guess_sex"):
for action in ("prepare_hts", "run"):
tpl = "work/{mapper}.ascat.{library_name}/log/{mapper}.ascat.{library_name}."
for ext in ("conda_info.txt", "conda_list.txt", "log", "wrapper"):
for ext in ("conda_info.txt", "conda_list.txt", "log", "R"):
results.append(tpl + f"{action}.{ext}")
tpl = "work/{mapper}.ascat.{library_name}/log/{mapper}.ascat.{library_name}.chr"
for chrom_name in AscatStepPart.chromosome_names:
for ext in ("conda_info.txt", "conda_list.txt", "log", "wrapper"):
results.append(tpl + f"{chrom_name}.build_baf.{ext}")
return results

@dictify
Expand All @@ -188,11 +184,19 @@ def get_log_file(self, action: str):
tpl = "work/{mapper}.ascat.{library_name}/log/{mapper}.ascat.{library_name}.chr{chrom_name}."
else:
tpl = "work/{mapper}.ascat.{library_name}/log/{mapper}.ascat.{library_name}."
for ext in ("conda_info.txt", "conda_list.txt", "log", "wrapper"):
for ext in ("conda_info.txt", "conda_list.txt", "log"):
k = ext.replace(".txt", "")
v = tpl + action + "." + ext
yield k, v
yield k + "_md5", v + ".md5"
if action in ("guess_sex", "build_baf"):
ext = "sh"
else:
ext = "R"
k = "script"
v = tpl + action + "." + ext
yield k, v
yield k + "_md5", v + ".md5"

def get_args(self, action: str):
# Validate action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,16 @@ def test_ascat_step_part_get_log_file(somatic_purity_ploidy_estimate_workflow):
for action in actions:
err_msg = f"Assert error for action '{action}'."
expected = get_expected_log_files_dict(base_out=base_out + action)
expected["wrapper"] = base_out + action + ".wrapper"
expected["wrapper_md5"] = expected["wrapper"] + ".md5"
if action == "guess_sex":
expected["script"] = base_out + action + ".sh"
else:
expected["script"] = base_out + action + ".R"
expected["script_md5"] = expected["script"] + ".md5"
actual = somatic_purity_ploidy_estimate_workflow.get_log_file("ascat", action)
assert actual == expected, err_msg
expected = get_expected_log_files_dict(base_out=base_out + "chr{chrom_name}.build_baf")
expected["wrapper"] = base_out + "chr{chrom_name}.build_baf.wrapper"
expected["wrapper_md5"] = expected["wrapper"] + ".md5"
expected["script"] = base_out + "chr{chrom_name}.build_baf.sh"
expected["script_md5"] = expected["script"] + ".md5"
actual = somatic_purity_ploidy_estimate_workflow.get_log_file("ascat", "build_baf")
assert actual == expected

Expand Down Expand Up @@ -324,10 +327,9 @@ def test_somatic_purity_ploidy_estimate_workflow(somatic_purity_ploidy_estimate_
assert actual == expected

# Check result file construction for ascat
chromosome_names = list(map(str, range(1, 23))) + ["X"]
out_exts = ("goodness_of_fit", "na", "nb", "purity", "ploidy", "segments")
actions = ("guess_sex", "prepare_hts", "run")
log_exts = ("conda_info.txt", "conda_list.txt", "log", "wrapper")
actions = ("prepare_hts", "run")
log_exts = ("conda_info.txt", "conda_list.txt", "log", "R")
mapper = "bwa"
expected = []
for lib in ((1, 1), (2, 1), (2,2)):
Expand All @@ -339,10 +341,6 @@ def test_somatic_purity_ploidy_estimate_workflow(somatic_purity_ploidy_estimate_
for log_ext in log_exts:
expected.append(f"output/{tpl}/log/{tpl}.{action}.{log_ext}")
expected.append(f"output/{tpl}/log/{tpl}.{action}.{log_ext}.md5")
for chrom_name in chromosome_names:
for log_ext in log_exts:
expected.append(f"output/{tpl}/log/{tpl}.chr{chrom_name}.build_baf.{log_ext}")
expected.append(f"output/{tpl}/log/{tpl}.chr{chrom_name}.build_baf.{log_ext}.md5")

expected = set(expected)
actual = set(somatic_purity_ploidy_estimate_workflow.get_result_files())
Expand Down

0 comments on commit ba3ea51

Please sign in to comment.