PRETEXT MAP

https://img.shields.io/github/issues-pr/snakemake/snakemake-wrappers/bio/pretext/map?label=version%20update%20pull%20requests

Paired REad TEXTure Mapper. Converts SAM formatted read pairs into genome contact maps.

URL: https://github.com/wtsi-hpag/PretextMap

Example

This wrapper can be used in the following way:

rule pretext_map:
    input:
        "a.bam",
    output:
        "map.pretext",
    log:
        "logs/pretext_map.log",
    params:
        extra="--sortby length --sortorder descend --mapq 10",
    wrapper:
        "v3.7.0-10-g491d5b6/bio/pretext/map"

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 arguments.

Software dependencies

  • pretextmap=0.1.9

  • samtools=1.19.2

  • snakemake-wrapper-utils=0.6.2

Input/Output

Input:

  • SAM/BAM/CRAM file

Output:

  • pretext contact map

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 infer_out_format


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


if snakemake.input[0].endswith(".gz"):
    pipe = "gunzip -c"
elif snakemake.input[0].endswith(".bz2"):
    pipe = "bunzip2 -c"
elif infer_out_format(snakemake.input[0]) in ["SAM", "BAM", "CRAM"]:
    pipe = "samtools view -h"
else:
    pipe = "cat"


shell(
    "({pipe}"
    " {snakemake.input} | "
    "PretextMap"
    " {extra}"
    " -o {snakemake.output}"
    ") {log}"
)