Skip to content

Commit 86b8e23

Browse files
committed
Refine freebayes multi file command line passing
1 parent 84f303c commit 86b8e23

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

workflow/rules/calling-freebayes.smk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ rule call_variants:
5050
output:
5151
# touch("calling/called/{contig}.vcf.done"),
5252
pipe("calling/called/{contig}.vcf"),
53+
bamlist=temp("calling/called/{contig}.bamlist")
5354
params:
5455
# Optional extra parameters.
5556
extra=config["params"]["freebayes"]["extra"] + know_variants_extra(),

workflow/scripts/freebayes.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@
5656
# Main Call
5757
# =================================================================================================
5858

59+
# For large numbers of input bam files, we might run into a max length issue when trying to
60+
# call parallel. Hence, we write a temporary list of the bam files instead.
61+
# One BAM path per line, so freebayes-parallel only needs a single --bam-list arg.
62+
with open(snakemake.output.bamlist, "w") as fh:
63+
for bam in snakemake.input.samples:
64+
fh.write(f"{bam}\n")
65+
5966
# Prepare the output and compression.
6067
# We need to pipe through bcftools in each case, in order to ensure the correct output format.
6168
pipe = ""
@@ -156,5 +163,5 @@
156163

157164
shell(
158165
"({freebayes} {extra_params} -f {snakemake.input.ref}"
159-
" {snakemake.input.samples} {pipe} > {snakemake.output[0]}) {log}"
166+
" --bam-list {snakemake.output.bamlist} {pipe} > {snakemake.output[0]}) {log}"
160167
)

0 commit comments

Comments
 (0)