Skip to content

Commit

Permalink
feat: Bowtie2 meta (#1586)
Browse files Browse the repository at this point in the history
<!-- 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
-->

### Description

This meta-wrapper simply aligns, filters and deduplicates reads. I've
been helping co-workers with Snakemake basics and snakemake-wrappers,
and I used this very short pipeline.

### 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),
* 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).

---------

Co-authored-by: tdayris <tdayris@gustaveroussy.fr>
Co-authored-by: tdayris <thibault.dayris@gustaveroussy.fr>
Co-authored-by: Johannes Köster <johannes.koester@uni-due.de>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: snakedeploy-bot[bot] <115615832+snakedeploy-bot[bot]@users.noreply.github.com>
Co-authored-by: Felix Mölder <felix.moelder@uni-due.de>
Co-authored-by: Christopher Schröder <christopher.schroeder@tu-dortmund.de>
  • Loading branch information
8 people committed Aug 2, 2023
1 parent 8656035 commit d8edd7b
Show file tree
Hide file tree
Showing 7 changed files with 217 additions and 0 deletions.
22 changes: 22 additions & 0 deletions meta/bio/bowtie2_sambamba/meta.yaml
@@ -0,0 +1,22 @@
name: Bowtie2 Sambamba
url: http://lomereiter.github.io/sambamba/
description: >
Map reads with Bowtie 2, and post-process alignments with Sambamba.
+----------------+----------+----------------------------------------------------------------------------------------------+
| Step | Tool | Reason |
+================+==========+==============================================================================================+
| Indexation | Bowtie 2 | Create genome sequence index |
+----------------+----------+----------------------------------------------------------------------------------------------+
| Mapping | Bowtie 2 | Perform read mapping |
+----------------+----------+----------------------------------------------------------------------------------------------+
| Sort | Sambamba | Perform sort based on mapping position |
+----------------+----------+----------------------------------------------------------------------------------------------+
| Quality filter | Sambamba | Perform mapping quality filter |
+----------------+----------+----------------------------------------------------------------------------------------------+
| Deduplication | Sambamba | Identify possible sequencing duplicates |
+----------------+----------+----------------------------------------------------------------------------------------------+
| Indexation | Sambamba | Index deduplicated reads |
+----------------+----------+----------------------------------------------------------------------------------------------+
authors:
- Thibault Dayris
32 changes: 32 additions & 0 deletions meta/bio/bowtie2_sambamba/test/Sample1.R1.fastq
@@ -0,0 +1,32 @@
@1
GCTGCTATGGCTATAGCTCTA
+
IIIIIIIIIIIIIIIIIIIII
@2
GCTGCTATGGCTATAGCTCTA
+
IIIIIIIIIIIIIIIIIIIII
@3
GCTGCTATGGCTATAGCTCTA
+
IIIIIIIIIIIIIIIIIIIII
@4
GCTGCTATGGCTATAGCTCTA
+
IIIIIIIIIIIIIIIIIIIII
@5
GCTGCTATGGCTATAGCTCTA
+
IIIIIIIIIIIIIIIIIIIII
@6
GCTGCTATGGCTATAGCTCTA
+
IIIIIIIIIIIIIIIIIIIII
@7
GCTGCTATGGCTATAGCTCTA
+
IIIIIIIIIIIIIIIIIIIII
@8
GTATCGATCCGATTA
+
IIIIIIIIIIIIIII
32 changes: 32 additions & 0 deletions meta/bio/bowtie2_sambamba/test/Sample1.R2.fastq
@@ -0,0 +1,32 @@
@1
CTCGATATCGCGCTACGATCC
+
IIIIIIIIIIIIIIIIIIIII
@2
CTCGATATCGCGCTACGATCC
+
IIIIIIIIIIIIIIIIIIIII
@3
CTCGATATCGCGCTACGATCC
+
IIIIIIIIIIIIIIIIIIIII
@4
CTCGATATCGCGCTACGATCC
+
IIIIIIIIIIIIIIIIIIIII
@5
CTCGATATCGCGCTACGATCC
+
IIIIIIIIIIIIIIIIIIIII
@6
CTCGATATCGCGCTACGATCC
+
IIIIIIIIIIIIIIIIIIIII
@7
CTCGATATCGCGCTACGATCC
+
IIIIIIIIIIIIIIIIIIIII
@8
ATATCGATCGACGAT
+
IIIIIIIIIIIIIII
105 changes: 105 additions & 0 deletions meta/bio/bowtie2_sambamba/test/Snakefile
@@ -0,0 +1,105 @@
rule bowtie2_build:
input:
ref="genome.fasta",
output:
multiext(
"genome",
".1.bt2",
".2.bt2",
".3.bt2",
".4.bt2",
".rev.1.bt2",
".rev.2.bt2",
),
log:
"logs/bowtie2_build/build.log",
params:
extra="",
threads: 8
wrapper:
"master/bio/bowtie2/build"


rule bowtie2_alignment:
input:
sample=["{sample}.R1.fastq", "{sample}.R2.fastq"],
idx=multiext(
"genome",
".1.bt2",
".2.bt2",
".3.bt2",
".4.bt2",
".rev.1.bt2",
".rev.2.bt2",
),
output:
temp("mapped/{sample}.bam"),
log:
"logs/bowtie2/{sample}.log",
params:
extra=(
" --rg-id {sample} "
"--rg 'SM:{sample} LB:FakeLib PU:FakePU.1.{sample} PL:ILLUMINA' "
),
threads: 8
wrapper:
"master/bio/bowtie2/align"


rule sambamba_sort:
input:
"mapped/{sample}.bam",
output:
temp("mapped/{sample}.sorted.bam"),
params:
"",
log:
"logs/sambamba-sort/{sample}.log",
threads: 8
wrapper:
"master/bio/sambamba/sort"


rule sambamba_view:
input:
"mapped/{sample}.sorted.bam",
output:
temp("mapped/{sample}.filtered.bam"),
params:
extra=(
" --format 'bam' "
"--filter 'mapping_quality >= 30 and not (unmapped or mate_is_unmapped)' "
),
log:
"logs/sambamba-view/{sample}.log",
threads: 8
wrapper:
"master/bio/sambamba/view"


rule sambamba_markdup:
input:
"mapped/{sample}.filtered.bam",
output:
"mapped/{sample}.rmdup.bam",
params:
extra=" --remove-duplicates ", # optional parameters
log:
"logs/sambamba-markdup/{sample}.log",
threads: 8
wrapper:
"master/bio/sambamba/markdup"


rule sambamba_index:
input:
"mapped/{sample}.rmdup.bam",
output:
"mapped/{sample}.rmdup.bam.bai",
params:
extra="",
log:
"logs/sambamba-index/{sample}.log",
threads: 8
wrapper:
"master/bio/sambamba/index"
3 changes: 3 additions & 0 deletions meta/bio/bowtie2_sambamba/test/genome.fasta
@@ -0,0 +1,3 @@
>FakeChrom
ATCGATGCTGCTATAGCTATAGCTCTAGATCTGATCTGCTAGTATCGATCCGATTATTAGCGCGATTATAGCGTAGTCA
ATCGATCTCGATATCGCGCTACGATCCGCGCGCGCGCGCGCATTATATCGATCGACGATGCTGCTAGCTAGCTGCTAGC
7 changes: 7 additions & 0 deletions meta/bio/bowtie2_sambamba/used_wrappers.yaml
@@ -0,0 +1,7 @@
wrappers:
- bio/bowtie2/build
- bio/bowtie2/align
- bio/sambamba/sort
- bio/sambamba/view
- bio/sambamba/markdup
- bio/sambamba/index
16 changes: 16 additions & 0 deletions test.py
Expand Up @@ -5688,6 +5688,22 @@ def test_calc_consensus_reads():
)



@skip_if_not_modified
def test_bowtie2_sambamba_meta():
run(
"meta/bio/bowtie2_sambamba",
[
"snakemake",
"--cores",
"2",
"--use-conda",
"-F",
"mapped/Sample1.rmdup.bam.bai"
]
)


@skip_if_not_modified
def test_bazam_interleaved():
run(
Expand Down

0 comments on commit d8edd7b

Please sign in to comment.