-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added Bellerophon wrapper (#529)
* Added Bellerophon * Added sorting * Fixed log * Added sort doc * Fixed tests * fix env Co-authored-by: Johannes Köster <johannes.koester@uni-due.de>
- Loading branch information
1 parent
8f95ddb
commit 888f651
Showing
7 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
channels: | ||
- conda-forge | ||
- bioconda | ||
- nodefaults | ||
dependencies: | ||
- bellerophon =1.0 | ||
- samtools =1.15 | ||
- snakemake-wrapper-utils =0.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: Bellerophon | ||
description: Filter mapped reads where the mapping spans a junction, retaining the 5-prime read. | ||
url: https://github.com/davebx/bellerophon/ | ||
authors: | ||
- Filipe G. Vieira | ||
input: | ||
- Forward reads (BAM format) | ||
- Reverse reads (BAM format) | ||
output: | ||
- SAM/BAM/CRAM file | ||
notes: | | ||
* The `sort` param allows to enable sorting ('none', 'queryname' or 'coordinate'). | ||
* The `sort_extra` allows for extra arguments for samtools. | ||
* The `extra` param allows for additional program arguments. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
rule bellerophon_sam: | ||
input: | ||
fwd="test_1500_forward.bam", | ||
rev="test_1500_reverse.bam", | ||
output: | ||
bam="out.sam", | ||
log: | ||
"logs/bellerophon.log", | ||
params: | ||
extra="--quality 20", | ||
sorting="none", # optional: Enable sorting. Possible values: 'none', 'queryname' or 'coordinate' | ||
sort_extra="--no-PG", # optional: extra arguments for samtools/picard | ||
threads: 2 | ||
wrapper: | ||
"master/bio/bellerophon" | ||
|
||
|
||
rule bellerophon_bam: | ||
input: | ||
fwd="test_1500_forward.bam", | ||
rev="test_1500_reverse.bam", | ||
output: | ||
bam="out.bam", | ||
log: | ||
"logs/bellerophon.log", | ||
params: | ||
extra="--quality 20", | ||
sorting="coordinate", # optional: Enable sorting. Possible values: 'none', 'queryname' or 'coordinate' | ||
sort_extra="--no-PG", # optional: extra arguments for samtools/picard | ||
threads: 2 | ||
wrapper: | ||
"master/bio/bellerophon" |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
__author__ = "Filipe G. Vieira" | ||
__copyright__ = "Copyright 2022, Filipe G. Vieira" | ||
__license__ = "MIT" | ||
|
||
|
||
from snakemake.shell import shell | ||
from snakemake_wrapper_utils.samtools import get_samtools_opts | ||
|
||
|
||
samtools_opts = get_samtools_opts(snakemake, parse_output=False) | ||
log = snakemake.log_fmt_shell(stdout=False, stderr=True) | ||
extra = snakemake.params.get("extra", "") | ||
sort = snakemake.params.get("sorting", "none") | ||
sort_extra = snakemake.params.get("sort_extra", "") | ||
|
||
|
||
pipe_cmd = "" | ||
# Determine which pipe command to use for converting to bam or sorting. | ||
if sort == "none": | ||
# Simply convert to output format using samtools view. | ||
pipe_cmd = f"| samtools view -h {sort_extra} {samtools_opts}" | ||
elif sort in ["coordinate", "queryname"]: | ||
# Add name flag if needed. | ||
if sort == "queryname": | ||
sort_extra += " -n" | ||
|
||
# Sort alignments. | ||
pipe_cmd = f"| samtools sort {sort_extra} {samtools_opts}" | ||
else: | ||
raise ValueError(f"Unexpected value for params.sort: {sort}") | ||
|
||
|
||
shell( | ||
"(bellerophon" | ||
" --threads {snakemake.threads}" | ||
" --forward {snakemake.input.fwd}" | ||
" --reverse {snakemake.input.rev}" | ||
" {extra}" | ||
" --output /dev/stdout" | ||
" {pipe_cmd}" | ||
" > {snakemake.output[0]}" | ||
") {log}" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters