Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe committed Dec 30, 2022
1 parent feada7f commit b8e3d38
Show file tree
Hide file tree
Showing 6 changed files with 922 additions and 1,014 deletions.
4 changes: 2 additions & 2 deletions snappy_pipeline/workflows/common/delly.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@


class Delly2StepPart(
ForwardSnakemakeFilesMixin,
ForwardResourceUsageMixin,
SvCallingGetResultFilesMixin,
SvCallingGetLogFileMixin,
ForwardSnakemakeFilesMixin,
ForwardResourceUsageMixin,
BaseStepPart,
):
"""Perform SV calling on exomes using Delly2"""
Expand Down
8 changes: 4 additions & 4 deletions snappy_pipeline/workflows/common/manta.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@


class MantaStepPart(
SvCallingGetLogFileMixin,
SvCallingGetResultFilesMixin,
ForwardSnakemakeFilesMixin,
ForwardResourceUsageMixin,
SvCallingGetResultFilesMixin,
SvCallingGetLogFileMixin,
BaseStepPart,
):
"""Perform SV calling on exomes using Manta"""
Expand Down Expand Up @@ -56,13 +56,13 @@ def _get_input_files_run(self, wildcards):

@dictify
def _get_output_files_run(self):
infix = "{mapper}.delly2.{library_name}"
infix = "{mapper}.manta.{library_name}"
work_files = {
"vcf": f"work/{infix}/out/{infix}.vcf.gz",
"vcf_md5": f"work/{infix}/out/{infix}.vcf.gz.md5",
"vcf_tbi": f"work/{infix}/out/{infix}.vcf.gz.tbi",
"vcf_tbi_md5": f"work/{infix}/out/{infix}.vcf.gz.tbi.md5",
}
yield from augment_work_dir_with_output_links(
work_files, self.get_log_file("merge_genotypes").values()
work_files, self.get_log_file().values()
).items()
13 changes: 9 additions & 4 deletions snappy_pipeline/workflows/common/sv_calling.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Code shared by steps in ``sv_calling_{targeted,wgs}``"""

import typing

from snakemake.io import expand

from snappy_pipeline.utils import DictQuery, dictify, flatten, listify
Expand All @@ -15,6 +17,9 @@ def get_result_files(self):
The implementation will return a list of all paths with prefix ``output/` that are
returned by ``self.get_output_files()`` for all actions in ``self.actions``.
"""
if self.name not in DictQuery(self.w_config).get(f"step_config/{self.parent.name}/tools"):
return # tool not enabled, no result files

ngs_mapping_config = DictQuery(self.w_config).get("step_config/ngs_mapping")
for mapper in ngs_mapping_config["tools"]["dna"]:
# Get list of result path templates.
Expand All @@ -39,13 +44,13 @@ class SvCallingGetLogFileMixin:
"""Mixin that provides ``get_log_files()`` for SV calling steps"""

@dictify
def get_log_file(self, action):
def get_log_file(self, action: typing.Optional[str] = None):
"""Return dict of log files in the "log" directory"""
_ = action
if action != "merge_genotypes":
infix = f"delly2_{action}"
if action and action != self.actions[-1]:
infix = f"{self.name}_{action}"
else:
infix = "delly2"
infix = self.name
prefix = f"work/{{mapper}}.{infix}.{{library_name}}/log/{{mapper}}.{infix}.{{library_name}}.sv_calling"
key_ext = (
("log", ".log"),
Expand Down
4 changes: 2 additions & 2 deletions snappy_pipeline/workflows/sv_calling_wgs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,10 @@ def get_ped_members(self, wildcards):


class MeltStepPart(
ForwardSnakemakeFilesMixin,
ForwardResourceUsageMixin,
SvCallingGetResultFilesMixin,
SvCallingGetLogFileMixin,
ForwardSnakemakeFilesMixin,
ForwardResourceUsageMixin,
BaseStepPart,
):
"""MEI calling using MELT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def minimal_config():
sv_calling_targeted:
tools:
- delly2
- manta
- gcnv
path_target_interval_list_mapping:
- pattern: "Agilent SureSelect Human All Exon V6.*"
Expand Down Expand Up @@ -313,18 +315,6 @@ def test_target_seq_cnv_calling_workflow_all_donors(
assert donor.dna_ngs_library.name in expected, msg


def test_target_seq_cnv_calling_workflow_all_background_donors(
sv_calling_targeted_workflow, sv_calling_targeted_workflow_large_cohort_background
):
"""Tests SvCallingTargetedWorkflow.all_background_donors()"""
# Test small foreground sample sheet
actual = sv_calling_targeted_workflow.all_background_donors()
assert len(actual) == 0, "Small sample sheet should contain zero background donors."
# Test large background sample sheet
actual = sv_calling_targeted_workflow_large_cohort_background.all_background_donors()
assert len(actual) == 501, "Large sample sheet should contain 501 background donors."


def test_target_seq_cnv_calling_workflow_get_library_count(sv_calling_targeted_workflow):
"""Tests SvCallingTargetedWorkflow.get_library_count()"""
# Test undefined library kit
Expand Down
Loading

0 comments on commit b8e3d38

Please sign in to comment.