Skip to content

Commit

Permalink
[dev] (bwa): Automatix prefix detection (snakemake#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
tdayris committed Oct 19, 2020
1 parent 0d2b20f commit 661f288
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
6 changes: 5 additions & 1 deletion bio/bwa-mem2/index/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
raise ValueError("Please provide exactly one reference genome as input.")

# Prefix that should be used for the database
prefix = snakemake.params.get("prefix", "")
prefix = None
if "prefix" in snakemake.params.keys():
prefix = snakemake.params["prefix"]
else:
prefix = splitext(snakemake.output[0])[0]

if len(prefix) > 0:
prefix = "-p " + prefix
Expand Down
10 changes: 9 additions & 1 deletion bio/bwa-mem2/mem-samblaster/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
sort_extra = snakemake.params.get("sort_extra", "")
samblaster_extra = snakemake.params.get("samblaster_extra", "")

index = None
if "index" in snakemake.params.keys():
index = snakemake.params["index"]
elif "index" in snakemake.input.keys():
index = path.splitext(snakemake.input["index"])[0]
else:
raise ValueError("Could not find BWA index prefix")

log = snakemake.log_fmt_shell(stdout=False, stderr=True)

# Check inputs/arguments.
Expand All @@ -27,7 +35,7 @@
"(bwa-mem2 mem"
" -t {snakemake.threads}"
" {extra}"
" {snakemake.params.index}"
" {index}"
" {snakemake.input.reads}"
" | samblaster"
" {samblaster_extra}"
Expand Down
10 changes: 9 additions & 1 deletion bio/bwa-mem2/mem/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
sort_order = snakemake.params.get("sort_order", "coordinate")
sort_extra = snakemake.params.get("sort_extra", "")

index = None
if "index" in snakemake.params.keys():
index = snakemake.params["index"]
elif "index" in snakemake.input.keys():
index = path.splitext(snakemake.input["index"])[0]
else:
raise ValueError("Could not find BWA index prefix")

log = snakemake.log_fmt_shell(stdout=False, stderr=True)

# Check inputs/arguments.
Expand Down Expand Up @@ -63,7 +71,7 @@
"(bwa-mem2 mem"
" -t {snakemake.threads}"
" {extra}"
" {snakemake.params.index}"
" {index}"
" {snakemake.input.reads}"
" | " + pipe_cmd + ") {log}"
)
10 changes: 9 additions & 1 deletion bio/bwa/mem/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
sort_order = snakemake.params.get("sort_order", "coordinate")
sort_extra = snakemake.params.get("sort_extra", "")

index = None
if "index" in snakemake.params.keys():
index = snakemake.params["index"]
elif "index" in snakemake.input.keys():
index = path.splitext(snakemake.input["index"])[0]
else:
raise ValueError("Could not find BWA index prefix")

log = snakemake.log_fmt_shell(stdout=False, stderr=True)

# Check inputs/arguments.
Expand Down Expand Up @@ -61,7 +69,7 @@
"(bwa mem"
" -t {snakemake.threads}"
" {extra}"
" {snakemake.params.index}"
" {index}"
" {snakemake.input.reads}"
" | " + pipe_cmd + ") {log}"
)

0 comments on commit 661f288

Please sign in to comment.