BELLEROPHON

Filter mapped reads where the mapping spans a junction, retaining the 5-prime read.

URL: https://github.com/davebx/bellerophon/

Example

This wrapper can be used in the following way:

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:
        "v1.9.0/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:
        "v1.9.0/bio/bellerophon"

Note that input, output and log file paths can be chosen freely.

When running with

snakemake --use-conda

the software dependencies will be automatically deployed into an isolated environment before execution.

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.

Software dependencies

  • bellerophon=1.0
  • samtools=1.15
  • snakemake-wrapper-utils=0.4

Input/Output

Input:

  • Forward reads (BAM format)
  • Reverse reads (BAM format)

Output:

  • SAM/BAM/CRAM file

Authors

  • Filipe G. Vieira

Code

__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}"
)