Skip to content

Commit

Permalink
fix: eb_filter wrapper assuming ANN/CSQ is present (#506)
Browse files Browse the repository at this point in the history
  • Loading branch information
tedil authored May 6, 2024
1 parent 66f555c commit 4dc4948
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ def input_function(wildcards):
filter_nb = int(wildcards["filter_nb"])
ebfilter_config = self.config["filter_list"][filter_nb - 1][self.filter_name]
parameters.update(ebfilter_config)
parameters["has_annotation"] = self.config.get("has_annotation", False)
return parameters

return input_function
Expand Down Expand Up @@ -731,6 +732,7 @@ def get_params(self, action):
self._validate_action(action)
parameters = self.config["eb_filter"]
parameters.update(self.config["filter_sets"]["dkfz_and_ebfilter"])
parameters["has_annotation"] = self.config.get("has_annotation", False)
return parameters

@dictify
Expand Down
7 changes: 6 additions & 1 deletion snappy_wrappers/wrappers/eb_filter/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

params = dict(snakemake.params)["args"]
filter_name = params["filter_name"] if "filter_name" in params else ""
has_annotation = str(params["has_annotation"] if "has_annotation" in params else False)

if "interval" in params:
cmd_fetch = "tabix --print-header {} {}".format(
Expand Down Expand Up @@ -61,7 +62,11 @@
filter=$(echo "$filter" | sed -e "s/^ || //")
ann="CSQ"
zgrep -q "^##INFO=<ID=CSQ," {snakemake.input.vcf} || ann="ANN"
filter="$filter || $ann ~ \"stream_gene_variant\""
if [[ '{has_annotation}' == "True" ]]; then
filter="$filter || $ann ~ \"stream_gene_variant\""
else
filter="$filter"
fi
{cmd_fetch} \
| bcftools view \
-e "$filter" \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ def test_one_filter_step_part_get_params(somatic_variant_filtration_workflow_lis
assert actual == expected

wildcards = Wildcards(fromdict={"filter_nb": 2})
expected = {"filter_name": "ebfilter_2", "threshold": 2.3}
expected = {"filter_name": "ebfilter_2", "threshold": 2.3, "has_annotation": True}
actual = somatic_variant_filtration_workflow_list.get_params("one_ebfilter", "run")(wildcards)
assert actual == expected

Expand Down

0 comments on commit 4dc4948

Please sign in to comment.