BAMTOBED

Conversion utility that converts sequence alignments in BAM format into BED, BED12, and/or BEDPE records.

URL: https://bedtools.readthedocs.io/en/latest/content/tools/bamtobed.html

Example

This wrapper can be used in the following way:

rule bamtobed:
    input:
        "{sample}.bam",
    output:
        "{sample}.bed",
    log:
        "logs/bamtobed/{sample}.log",
    params:
        extra="-bedpe",  # optional parameters
    wrapper:
        "v1.9.0/bio/bedtools/bamtobed"

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 extra param allows for additional program arguments.

Software dependencies

  • bedtools=2.30

Input/Output

Input:

  • BAM file

Output:

  • BED file

Authors

  • Filipe G. Vieira

Code

__author__ = "Filipe G. Vieira"
__copyright__ = "Copyright 2022, Filipe G. Vieira"
__license__ = "MIT"


from snakemake.shell import shell


log = snakemake.log_fmt_shell(stdout=False, stderr=True)
extra = snakemake.params.get("extra", "")


shell(
    "(bamToBed"
    " {extra}"
    " -i {snakemake.input[0]}"
    " > {snakemake.output[0]}"
    ") {log}"
)