Skip to content

Commit

Permalink
Added VCF to output.
Browse files Browse the repository at this point in the history
  • Loading branch information
eudesbarbosa committed Aug 2, 2021
1 parent 16e7634 commit cdfbd12
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 17 deletions.
35 changes: 24 additions & 11 deletions snappy_pipeline/workflows/repeat_expansion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
AnnotateExpansionHunter,
)

#: Extensions of files to create as main payload
EXT_VALUES = (".json", ".json.md5")

#: Default configuration for the repeat_expansion step
#: Extensions of files to create as main payload - JSON.
EXT_JSON = (".json", ".json.md5")
#: Extensions of files to create as main payload - VCF.
EXT_VCF = (".vcf", ".vcf.md5")
#: Default configuration for the repeat_expansion step.
DEFAULT_CONFIG = r"""
# Default configuration repeat_expansion
step_config:
Expand Down Expand Up @@ -124,11 +125,14 @@ def _get_input_files_annotate(_wildcards):
@dictify
def _get_output_files_run():
"""Yield output files' patterns for rule `run` - ExpansionHunter call."""
ext = "json"
# Initialise variables
name_pattern = "{mapper}.expansionhunter.{library_name}"
yield ext, "work/{name_pattern}/out/{name_pattern}.{ext}".format(
name_pattern=name_pattern, ext=ext
)
ext_dict = {"json": "json", "vcf": "vcf", "vcf_md5": "vcf.md5"}
# Yield
for key, ext in ext_dict.items():
yield key, "work/{name_pattern}/out/{name_pattern}.{ext}".format(
name_pattern=name_pattern, ext=ext
)

@staticmethod
@dictify
Expand Down Expand Up @@ -218,14 +222,23 @@ def _all_donors(self, include_background=True):
@listify
def get_result_files(self):
"""Return list of result files for the germline repeat expansion analysis workflow."""
# Actually yield the result files.
name_pattern = "{mapper}.{tool}_annotated.{donor.dna_ngs_library.name}"
# Initialise variable
tools = ("expansionhunter",)
# Yield the JSON annotated results files
name_pattern = "{mapper}.{tool}_annotated.{donor.dna_ngs_library.name}"
yield from self._yield_result_files(
os.path.join("output", name_pattern, "out", name_pattern + "{ext}"),
mapper=self.w_config["step_config"]["ngs_mapping"]["tools"]["dna"],
tool=tools,
ext=EXT_JSON,
)
# Yield the VCF results files
name_pattern = "{mapper}.{tool}.{donor.dna_ngs_library.name}"
yield from self._yield_result_files(
os.path.join("output", name_pattern, "out", name_pattern + "{ext}"),
mapper=self.w_config["step_config"]["ngs_mapping"]["tools"]["dna"],
tool=tools,
ext=EXT_VALUES,
ext=EXT_VCF,
)

def _yield_result_files(self, tpl, **kwargs):
Expand Down
3 changes: 2 additions & 1 deletion snappy_wrappers/wrappers/expansionhunter/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@
"""
)

# Compute MD5 sums of logs.
# Compute MD5 sums of log and vcf.
shell(
r"""
md5sum {snakemake.log} >{snakemake.log}.md5
md5sum {snakemake.output.vcf} >{snakemake.output.vcf_md5}
"""
)
27 changes: 22 additions & 5 deletions tests/snappy_pipeline/workflows/test_workflows_repeat_expansion.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,30 @@ def test_repeat_expansion_workflow_files(repeat_expansion_workflow):
to the expected results for ExpansionHunter.
"""
# Define expected
pattern_out = (
pattern_json_out = (
"output/bwa.expansionhunter_annotated.P00{i}-N1-DNA1-WGS1/out/"
"bwa.expansionhunter_annotated.P00{i}-N1-DNA1-WGS1.{ext}"
)
pattern_vcf_out = (
"output/bwa.expansionhunter.P00{i}-N1-DNA1-WGS1/out/"
"bwa.expansionhunter.P00{i}-N1-DNA1-WGS1.{ext}"
)
expected = [
pattern_out.format(i=i, ext=ext)
pattern_json_out.format(i=i, ext=ext)
for i in range(1, 7) # all donors: P001 - P006
for ext in (
"json",
"json.md5",
)
]
expected += [
pattern_vcf_out.format(i=i, ext=ext)
for i in range(1, 7) # all donors: P001 - P006
for ext in (
"vcf",
"vcf.md5",
)
]
# Get actual
actual = repeat_expansion_workflow.get_result_files()
assert sorted(actual) == sorted(expected)
Expand All @@ -110,13 +122,18 @@ def test_expansionhunter_run_step_part_get_input_files(repeat_expansion_workflow
def test_expansionhunter_run_step_part_get_output_files(repeat_expansion_workflow):
"""Tests ExpansionHunterStepPart::_get_output_files_run()"""
# Define expected
json_out = (
pattern_out = (
"work/{mapper}.expansionhunter.{library_name}/out/"
"{mapper}.expansionhunter.{library_name}.json"
"{mapper}.expansionhunter.{library_name}"
)
expected = {"json": json_out}
expected = {
"json": pattern_out + ".json",
"vcf": pattern_out + ".vcf",
"vcf_md5": pattern_out + ".vcf.md5",
}
# Get actual
actual = repeat_expansion_workflow.get_output_files("expansionhunter", "run")
print(actual)
assert actual == expected


Expand Down

0 comments on commit cdfbd12

Please sign in to comment.