SAMTOOLS COLLATE
Shuffles and groups reads together by their names.
URL: http://www.htslib.org/doc/samtools-collate.html
Example
This wrapper can be used in the following way:
rule samtools_collate:
input:
"mapped/{sample}.bam",
output:
"{sample}.collated.bam",
log:
"logs/{sample}.log",
params:
extra="-f",
threads: 2
wrapper:
"v5.6.1-7-g2ff6d79/bio/samtools/collate"
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.
Software dependencies
samtools=1.21
snakemake-wrapper-utils=0.6.2
Input/Output
Input:
SAM/BAM/CRAM file
Output:
SAM/BAM/CRAM file
Params
extra
: additional program arguments (not -@/–threads, –reference, -o or -O/–output-fmt).
Code
__author__ = "Filipe G. Vieira"
__copyright__ = "Copyright 2024, Filipe G. Vieira"
__license__ = "MIT"
import tempfile
from pathlib import Path
from snakemake.shell import shell
from snakemake_wrapper_utils.samtools import get_samtools_opts
samtools_opts = get_samtools_opts(snakemake, parse_write_index=False)
extra = snakemake.params.get("extra", "")
log = snakemake.log_fmt_shell(stdout=True, stderr=True)
with tempfile.TemporaryDirectory() as tmpdir:
tmp_prefix = Path(tmpdir) / "samtools_collate"
shell(
"samtools collate {samtools_opts} {extra} -T {tmp_prefix} {snakemake.input[0]} {log}"
)