From 673bb21ba4eb9d137db07de058a567b03de9d7d5 Mon Sep 17 00:00:00 2001 From: tdayris Date: Tue, 24 Mar 2026 09:43:20 +0100 Subject: [PATCH 1/5] fix: Typo in GATK command line arguments --- snakemake_wrapper_utils/gatk.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/snakemake_wrapper_utils/gatk.py b/snakemake_wrapper_utils/gatk.py index 7a5dc3e..f3ef237 100644 --- a/snakemake_wrapper_utils/gatk.py +++ b/snakemake_wrapper_utils/gatk.py @@ -25,16 +25,16 @@ def get_gatk_opts( if parse_arg_file: if is_arg("--arguments_file", extra): sys.exit( - "You have specified an argument file (`--argument_file`) in `params.extra`; this is automatically inferred from `input.arg_file`." + "You have specified an argument file (`--arguments_file`) in `params.extra`; this is automatically inferred from `input.arg_file`." ) # Multiple argument files can be provided. Order matters. arg_file = snakemake.input.get("arg_file", "") if arg_file: if isinstance(arg_file, list): - arg_file = " --argument_file ".join(arg_file) + arg_file = " --arguments_file ".join(arg_file) - gatk_opts += f" --argument_file {arg_file}" + gatk_opts += f" --arguments_file {arg_file}" ###################### ### Reference file ### From 6b1b8cd87addbe32aa5643bf0b00d1417671b3fc Mon Sep 17 00:00:00 2001 From: tdayris Date: Tue, 24 Mar 2026 11:07:15 +0100 Subject: [PATCH 2/5] feat: draft for bcftools read/write variants --- snakemake_wrapper_utils/bcftools.py | 49 +++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/snakemake_wrapper_utils/bcftools.py b/snakemake_wrapper_utils/bcftools.py index 31a5e4b..30de527 100644 --- a/snakemake_wrapper_utils/bcftools.py +++ b/snakemake_wrapper_utils/bcftools.py @@ -144,3 +144,52 @@ def get_bcftools_opts( ) return bcftools_opts + + +def read_write_variants(snakemake, variant_key_name="call"): + """Obtain command lines to read gzipped VCF or BCF files and path to named pipes""" + in_call = snakemake.input.get(variant_key_name) + min_threads: 1 + if not in_call: + raise KeyError( + f"Could not find {variant_key_name} within available snakemake input keys" + ) + + command_lines = "" + input_file_name = in_call + if str(in_call).endswith((".gz", ".bcf")): + input_file_name = "snakemake_wrapper_utils_read_variants.vcf" + min_threads += 1 + + # Case there is a comparison: + bcftools_opts = get_bcftools_opts( + snakemake, + parse_threads=False, # Since no additional threads are required for reading + parse_output=False, # Since we do not write to any file + parse_output_format=False, + ) + + # Create named pipe + command_lines += str( + f"mkfifo {input_file_name} ; " + f"bcftools view {bcftools_opts} {in_call} > {input_file_name} & " + ) + + out_call = snakemake.output.get(variant_key_name) + output_file_name = out_call + if str(out_call).endswith((".gz", ".bcf")): + output_file_name = "snakemake_wrapper_utils_write_variants.vcf" + min_threads += 1 + + # This time, we include threading and output formats + bcftools_opts = get_bcftools_opts(snakemake) + command_lines += str( + f"mkfifo {output_file_name} ; " + f"bcftools view {bcftools_opts} < {output_file_name} & " + ) + + if snakemake.threads < min_threads: + raise ValueError( + f"At least {min_threads} threads required, got {snakemake.threads}" + ) + return command_lines, input_file_name, output_file_name From b6d9977b8add70249364725062b055244a4c37db Mon Sep 17 00:00:00 2001 From: tdayris Date: Tue, 24 Mar 2026 11:49:11 +0100 Subject: [PATCH 3/5] typos --- snakemake_wrapper_utils/bcftools.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/snakemake_wrapper_utils/bcftools.py b/snakemake_wrapper_utils/bcftools.py index 30de527..070f873 100644 --- a/snakemake_wrapper_utils/bcftools.py +++ b/snakemake_wrapper_utils/bcftools.py @@ -149,7 +149,7 @@ def get_bcftools_opts( def read_write_variants(snakemake, variant_key_name="call"): """Obtain command lines to read gzipped VCF or BCF files and path to named pipes""" in_call = snakemake.input.get(variant_key_name) - min_threads: 1 + min_threads = 1 if not in_call: raise KeyError( f"Could not find {variant_key_name} within available snakemake input keys" @@ -177,6 +177,12 @@ def read_write_variants(snakemake, variant_key_name="call"): out_call = snakemake.output.get(variant_key_name) output_file_name = out_call + if not out_call: + raise KeyError( + f"Could not find {variant_key_name} within available snakemake output keys" + ) + + if str(out_call).endswith((".gz", ".bcf")): output_file_name = "snakemake_wrapper_utils_write_variants.vcf" min_threads += 1 From 8d306b302476ac54505b3ef7d381d983a7ce28f6 Mon Sep 17 00:00:00 2001 From: tdayris Date: Tue, 24 Mar 2026 13:03:56 +0100 Subject: [PATCH 4/5] coderabbit points --- snakemake_wrapper_utils/bcftools.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/snakemake_wrapper_utils/bcftools.py b/snakemake_wrapper_utils/bcftools.py index 070f873..0454577 100644 --- a/snakemake_wrapper_utils/bcftools.py +++ b/snakemake_wrapper_utils/bcftools.py @@ -148,7 +148,10 @@ def get_bcftools_opts( def read_write_variants(snakemake, variant_key_name="call"): """Obtain command lines to read gzipped VCF or BCF files and path to named pipes""" - in_call = snakemake.input.get(variant_key_name) + if isinstance(variant_key_name, int): + in_call = snakemake.input[0] + else: + in_call = snakemake.input.get(variant_key_name) min_threads = 1 if not in_call: raise KeyError( @@ -158,7 +161,7 @@ def read_write_variants(snakemake, variant_key_name="call"): command_lines = "" input_file_name = in_call if str(in_call).endswith((".gz", ".bcf")): - input_file_name = "snakemake_wrapper_utils_read_variants.vcf" + input_file_name = f"{in_call}.snakemake_wrapper_utils_read_variants.vcf" min_threads += 1 # Case there is a comparison: @@ -175,23 +178,25 @@ def read_write_variants(snakemake, variant_key_name="call"): f"bcftools view {bcftools_opts} {in_call} > {input_file_name} & " ) - out_call = snakemake.output.get(variant_key_name) + if isinstance(variant_key_name, int): + out_call = snakemake.output[0] + else: + out_call = snakemake.output.get(variant_key_name) output_file_name = out_call if not out_call: raise KeyError( f"Could not find {variant_key_name} within available snakemake output keys" ) - if str(out_call).endswith((".gz", ".bcf")): - output_file_name = "snakemake_wrapper_utils_write_variants.vcf" + output_file_name = f"{out_call}.snakemake_wrapper_utils_write_variants.vcf" min_threads += 1 # This time, we include threading and output formats bcftools_opts = get_bcftools_opts(snakemake) command_lines += str( f"mkfifo {output_file_name} ; " - f"bcftools view {bcftools_opts} < {output_file_name} & " + f"bcftools view {bcftools_opts} {output_file_name} & " ) if snakemake.threads < min_threads: From d86c7ba4bf61a9e8f6f3cfe014c8c350b4a5ee68 Mon Sep 17 00:00:00 2001 From: tdayris Date: Thu, 23 Apr 2026 09:59:47 +0200 Subject: [PATCH 5/5] code rabbit review --- snakemake_wrapper_utils/bcftools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snakemake_wrapper_utils/bcftools.py b/snakemake_wrapper_utils/bcftools.py index 0454577..477dc10 100644 --- a/snakemake_wrapper_utils/bcftools.py +++ b/snakemake_wrapper_utils/bcftools.py @@ -179,7 +179,7 @@ def read_write_variants(snakemake, variant_key_name="call"): ) if isinstance(variant_key_name, int): - out_call = snakemake.output[0] + out_call = snakemake.output[variant_key_name] else: out_call = snakemake.output.get(variant_key_name) output_file_name = out_call