diff --git a/snappy_pipeline/workflows/repeat_expansion/__init__.py b/snappy_pipeline/workflows/repeat_expansion/__init__.py index a322dd2a9..9f670794e 100644 --- a/snappy_pipeline/workflows/repeat_expansion/__init__.py +++ b/snappy_pipeline/workflows/repeat_expansion/__init__.py @@ -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: @@ -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 @@ -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): diff --git a/snappy_wrappers/wrappers/expansionhunter/wrapper.py b/snappy_wrappers/wrappers/expansionhunter/wrapper.py index 8c5ffed71..3044f6b3e 100644 --- a/snappy_wrappers/wrappers/expansionhunter/wrapper.py +++ b/snappy_wrappers/wrappers/expansionhunter/wrapper.py @@ -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} """ ) diff --git a/tests/snappy_pipeline/workflows/test_workflows_repeat_expansion.py b/tests/snappy_pipeline/workflows/test_workflows_repeat_expansion.py index 56d47bdc9..ec5a5c4a2 100644 --- a/tests/snappy_pipeline/workflows/test_workflows_repeat_expansion.py +++ b/tests/snappy_pipeline/workflows/test_workflows_repeat_expansion.py @@ -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) @@ -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