.. _`bio/umis/bamtag`: UMIS BAMTAG =========== .. image:: https://img.shields.io/github/issues-pr/snakemake/snakemake-wrappers/bio/umis/bamtag?label=version%20update%20pull%20requests :target: https://github.com/snakemake/snakemake-wrappers/pulls?q=is%3Apr+is%3Aopen+label%3Abio/umis/bamtag Convert a BAM/SAM with fastqtransformed read names to have UMI and Example ------- This wrapper can be used in the following way: .. code-block:: python rule umis_bamtag: input: "data/{sample}.bam" output: "data/{sample}.annotated.bam" log: "logs/umis/bamtag/{sample}.log" params: extra="" threads: 1 wrapper: "v3.0.1/bio/umis/bamtag" Note that input, output and log file paths can be chosen freely. When running with .. code-block:: bash snakemake --use-conda the software dependencies will be automatically deployed into an isolated environment before execution. Software dependencies --------------------- * ``umis=1.0.9`` * ``samtools=1.18`` Authors ------- * Patrik Smeds Code ---- .. code-block:: python __author__ = "Patrik Smeds" __copyright__ = "Copyright 2019, Patrik Smeds" __email__ = "patrik.smeds@gmail.com" __license__ = "MIT" import os from snakemake.shell import shell log = snakemake.log_fmt_shell(stdout=False, stderr=True) extra = snakemake.params.get("extra", "") bam_input = snakemake.input[0] if bam_input is None: raise ValueError("Missing bam input file!") elif not len(snakemake.input) == 1: raise ValueError("Only expecting one input file: " + str(snakemake.input) + "!") output_file = snakemake.output[0] if output_file is None: raise ValueError("Missing output file") elif not len(snakemake.output) == 1: raise ValueError("Only expecting one output file: " + str(output_file) + "!") in_pipe = "" if bam_input.endswith(".sam"): in_pipe = "cat " else: in_pipe = "samtools view -h " out_pipe = "" if not output_file.endswith(".sam"): out_pipe = " | samtools view -S -b - " shell( " {in_pipe} {bam_input} | " " umis bamtag -" " {out_pipe} > {output_file}" " {log}" ) .. |nl| raw:: html