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: eb_filter wrapper assuming ANN/CSQ is present #506

Merged
merged 10 commits into from
May 6, 2024
42 changes: 29 additions & 13 deletions snappy_pipeline/workflows/somatic_variant_filtration/__init__.py
tedil marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -502,11 +502,13 @@ def get_input_files(self, action):
"""Return path to jannovar-annotated vcf input file"""
# Validate action
self._validate_action(action)

name_pattern = "{mapper}.{var_caller}"
if self.config["has_annotation"]:
name_pattern += ".{annotator}"

# VCF file and index
tpl = (
"output/{mapper}.{var_caller}.{annotator}.{tumor_library}/out/"
"{mapper}.{var_caller}.{annotator}.{tumor_library}"
)
tpl = f"output/{name_pattern}." "{tumor_library}/" f"out/{name_pattern}." "{tumor_library}"
key_ext = {"vcf": ".vcf.gz", "vcf_tbi": ".vcf.gz.tbi"}
somatic_variant = self.parent.sub_workflows["somatic_variant"]
for key, ext in key_ext.items():
Expand All @@ -523,10 +525,16 @@ def get_output_files(self, action):
"""Return output files for the filtration"""
# Validate action
self._validate_action(action)

name_pattern = "{mapper}.{var_caller}"
if self.config["has_annotation"]:
name_pattern += ".{annotator}"

prefix = (
r"work/{mapper}.{var_caller}.{annotator}."
r"dkfz_bias_filter.{tumor_library,[^\.]+}/out/{mapper}.{var_caller}."
r"{annotator}.dkfz_bias_filter.{tumor_library}"
rf"work/{name_pattern}."
r"dkfz_bias_filter.{tumor_library,[^\.]+}/"
rf"out/{name_pattern}."
r"dkfz_bias_filter.{tumor_library}"
)
key_ext = {
"vcf": ".vcf.gz",
Expand Down Expand Up @@ -588,11 +596,15 @@ def get_input_files(self, action):

@dictify
def _get_input_files_run(self, wildcards):
name_pattern = "{mapper}.{var_caller}"
if self.config["has_annotation"]:
name_pattern += ".{annotator}"
# VCF file and index
tpl = (
"work/{mapper}.{var_caller}.{annotator}."
"dkfz_bias_filter.{tumor_library}/out/{mapper}.{var_caller}."
"{annotator}.dkfz_bias_filter."
f"work/{name_pattern}."
"dkfz_bias_filter.{tumor_library}/"
f"out/{name_pattern}."
"dkfz_bias_filter."
"{tumor_library}"
)
key_ext = {"vcf": ".vcf.gz", "vcf_tbi": ".vcf.gz.tbi"}
Expand All @@ -619,10 +631,14 @@ def get_output_files(self, action):

@dictify
def _get_output_files_run(self):
name_pattern = "{mapper}.{var_caller}"
if self.config["has_annotation"]:
name_pattern += ".{annotator}"
# VCF file and index
prefix = (
r"work/{mapper}.{var_caller}.{annotator}."
r"dkfz_bias_filter.eb_filter.{tumor_library,[^\.]+}/out/"
r"{mapper}.{var_caller}.{annotator}."
rf"work/{name_pattern}."
r"dkfz_bias_filter.eb_filter.{tumor_library,[^\.]+}/"
rf"out/{name_pattern}."
r"dkfz_bias_filter.eb_filter.{tumor_library}"
)
key_ext = {
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 @@ -15,6 +15,7 @@

step = snakemake.config["pipeline_step"]["name"]
config = snakemake.config["step_config"][step]
has_annotation = str(config.get("has_annotation", False))

if "ebfilter_threshold" in config:
threshold = config.get("ebfilter_threshold", 0)
Expand Down Expand Up @@ -86,7 +87,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
tedil marked this conversation as resolved.
Show resolved Hide resolved
filter="$filter || $ann ~ \"stream_gene_variant\""
else
filter="$filter"
fi
{cmd_fetch} \
| bcftools view \
-e "$filter" \
Expand Down
Loading