Skip to content

Commit ff15cb4

Browse files
authored
test: add test for creating bai index using bwa mem (snakemake#2927)
<!-- Ensure that the PR title follows conventional commit style (<type>: <description>)--> <!-- Possible types are here: https://github.com/commitizen/conventional-commit-types/blob/master/index.json --> <!-- Add a description of your PR here--> ### QC <!-- Make sure that you can tick the boxes below. --> * [x] I confirm that: For all wrappers added by this PR, * there is a test case which covers any introduced changes, * `input:` and `output:` file paths in the resulting rule can be changed arbitrarily, * either the wrapper can only use a single core, or the example rule contains a `threads: x` statement with `x` being a reasonable default, * rule names in the test case are in [snake_case](https://en.wikipedia.org/wiki/Snake_case) and somehow tell what the rule is about or match the tools purpose or name (e.g., `map_reads` for a step that maps reads), * all `environment.yaml` specifications follow [the respective best practices](https://stackoverflow.com/a/64594513/2352071), * the `environment.yaml` pinning has been updated by running `snakedeploy pin-conda-envs environment.yaml` on a linux machine, * wherever possible, command line arguments are inferred and set automatically (e.g. based on file extensions in `input:` or `output:`), * all fields of the example rules in the `Snakefile`s and their entries are explained via comments (`input:`/`output:`/`params:` etc.), * `stderr` and/or `stdout` are logged correctly (`log:`), depending on the wrapped tool, * temporary files are either written to a unique hidden folder in the working directory, or (better) stored where the Python function `tempfile.gettempdir()` points to (see [here](https://docs.python.org/3/library/tempfile.html#tempfile.gettempdir); this also means that using any Python `tempfile` default behavior works), * the `meta.yaml` contains a link to the documentation of the respective tool or command, * `Snakefile`s pass the linting (`snakemake --lint`), * `Snakefile`s are formatted with [snakefmt](https://github.com/snakemake/snakefmt), * Python wrapper scripts are formatted with [black](https://black.readthedocs.io). * Conda environments use a minimal amount of channels, in recommended ordering. E.g. for bioconda, use (conda-forge, bioconda, nodefaults, as conda-forge should have highest priority and defaults channels are usually not needed because most packages are in conda-forge nowadays).
1 parent ebef6f8 commit ff15cb4

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

bio/bwa/mem/test/Snakefile_samtools

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,32 @@ rule bwa_mem:
1717
"master/bio/bwa/mem"
1818

1919

20-
rule bwa_mem_write_index:
20+
rule bwa_mem_write_index_csi:
2121
input:
2222
reads=["reads/{sample}.1.fastq", "reads/{sample}.2.fastq"],
2323
idx=multiext("genome", ".amb", ".ann", ".bwt", ".pac", ".sa"),
2424
output:
25-
"mapped_with_index/{sample}.bam",
26-
idx="mapped_with_index/{sample}.bam.csi",
25+
"mapped_with_index_csi/{sample}.bam",
26+
idx="mapped_with_index_csi/{sample}.bam.csi",
27+
log:
28+
"logs/bwa_mem/{sample}.log",
29+
params:
30+
extra=r"-R '@RG\tID:{sample}\tSM:{sample}'",
31+
sorting="samtools", # Can be 'none', 'samtools' or 'picard'.
32+
sort_order="coordinate", # Can be 'queryname' or 'coordinate'.
33+
sort_extra="", # Extra args for samtools/picard.
34+
tmp_dir="/tmp/", # Path to temp dir. (optional)
35+
threads: 8
36+
wrapper:
37+
"master/bio/bwa/mem"
38+
39+
rule bwa_mem_write_index_bai:
40+
input:
41+
reads=["reads/{sample}.1.fastq", "reads/{sample}.2.fastq"],
42+
idx=multiext("genome", ".amb", ".ann", ".bwt", ".pac", ".sa"),
43+
output:
44+
"mapped_with_index_bai/{sample}.bam",
45+
idx="mapped_with_index_bai/{sample}.bam.bai",
2746
log:
2847
"logs/bwa_mem/{sample}.log",
2948
params:

test.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2141,8 +2141,22 @@ def test_bwa_mem_sort_samtools_write_index():
21412141
"snakemake",
21422142
"--cores",
21432143
"1",
2144-
"mapped_with_index/a.bam",
2145-
"mapped_with_index/a.bam.csi",
2144+
"mapped_with_index_csi/a.bam",
2145+
"mapped_with_index_csi/a.bam.csi",
2146+
"--use-conda",
2147+
"-F",
2148+
"-s",
2149+
"Snakefile_samtools",
2150+
],
2151+
)
2152+
run(
2153+
"bio/bwa/mem",
2154+
[
2155+
"snakemake",
2156+
"--cores",
2157+
"1",
2158+
"mapped_with_index_bai/a.bam",
2159+
"mapped_with_index_bai/a.bam.bai",
21462160
"--use-conda",
21472161
"-F",
21482162
"-s",

0 commit comments

Comments
 (0)