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

fix: move config access in gcnv/contig_ploidy wrapper to params #508

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
16 changes: 16 additions & 0 deletions snappy_pipeline/workflows/sv_calling_targeted/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ def __init__(self, parent):
# Take shortcut from library to library kit.
self.ngs_library_to_kit = self.parent.ngs_library_to_kit

def get_params(self, action: str):
param_fn = super().get_params(action)

def _get_params(*args, **kwargs):
params = param_fn(*args, **kwargs)
if action == "contig_ploidy":
par_intervals = (
self.config.get("helper_gcnv_model_targeted", {})
.get("gcnv", {})
.get("path_par_intervals", "")
)
params.update({"par_intervals": par_intervals})
return params

return _get_params


class SvCallingTargetedWorkflow(BaseStep):
"""Perform germline targeted sequencing CNV calling"""
Expand Down
17 changes: 17 additions & 0 deletions snappy_pipeline/workflows/sv_calling_wgs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,23 @@ def _build_ngs_library_to_kit(self):
if donor.dna_ngs_library:
yield donor.dna_ngs_library.name, "wgs"

def get_params(self, action: str):
param_fn = super().get_params(action)

def _get_params(*args, **kwargs):
params = param_fn(*args, **kwargs)
if action == "contig_ploidy":
par_intervals = (
self.config.get("helper_gcnv_model_wgs", {})
.get("gcnv", {})
.get("path_par_intervals", "")
)
params.update({"par_intervals": par_intervals})
params.update({"par_intervals": par_intervals})
return params

return _get_params


def escape_dots_dashes(s: str) -> str:
"""Escape dots and dashes with double-underscore constructs."""
Expand Down
5 changes: 2 additions & 3 deletions snappy_wrappers/wrappers/gcnv/contig_ploidy/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@
paths_tsv = " ".join(snakemake.input.tsv)

# Add interval block list for PAR regions if configured.
par_intervals = snakemake.config["step_config"][snakemake.params.step_key]["gcnv"].get(
"path_par_intervals"
)
par_intervals = snakemake.params.get("par_intervals", "")

if par_intervals:
par_args = f"-XL {par_intervals}"
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -644,11 +644,11 @@ def test_gcnv_get_params_ploidy_model(sv_calling_targeted_workflow):
wildcards = Wildcards(fromdict={"library_kit": "Agilent_SureSelect_Human_All_Exon_V6"})
wildcards_fake = Wildcards(fromdict={"library_kit": "__not_a_library_kit__"})
# Test large cohort - model defined in config
expected = {"model": "/path/to/ploidy-model"}
expected = {"model": "/path/to/ploidy-model", "par_intervals": ""}
actual = sv_calling_targeted_workflow.get_params("gcnv", "contig_ploidy")(wildcards)
assert actual == expected
# Test large cohort - model not defined in config
expected = {"model": "__no_ploidy_model_for_library_in_config__"}
expected = {"model": "__no_ploidy_model_for_library_in_config__", "par_intervals": ""}
actual = sv_calling_targeted_workflow.get_params("gcnv", "contig_ploidy")(wildcards_fake)
assert actual == expected

Expand Down
Loading