.. _`bio/samtools/index`: SAMTOOLS INDEX ============== .. image:: https://img.shields.io/github/issues-pr/snakemake/snakemake-wrappers/bio/samtools/index?label=version%20update%20pull%20requests :target: https://github.com/snakemake/snakemake-wrappers/pulls?q=is%3Apr+is%3Aopen+label%3Abio/samtools/index Index bam file with samtools. Example ------- This wrapper can be used in the following way: .. code-block:: python rule samtools_index: input: "mapped/{sample}.sorted.bam", output: "mapped/{sample}.sorted.bam.bai", log: "logs/samtools_index/{sample}.log", params: extra="", # optional params string threads: 4 # This value - 1 will be sent to -@ wrapper: "v3.0.1/bio/samtools/index" 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. Notes ----- * The `extra` param allows for additional program arguments. * For more information see, http://www.htslib.org/doc/samtools-index.html Software dependencies --------------------- * ``samtools=1.18`` Input/Output ------------ **Input:** * bam file **Output:** * bam file index (.bai) Authors ------- * Johannes Köster * Filipe G. Vieira Code ---- .. code-block:: python __author__ = "Johannes Köster" __copyright__ = "Copyright 2016, Johannes Köster" __email__ = "koester@jimmy.harvard.edu" __license__ = "MIT" from snakemake.shell import shell extra = snakemake.params.get("extra", "") log = snakemake.log_fmt_shell(stdout=True, stderr=True) # Samtools takes additional threads through its option -@ # One thread for samtools merge # Other threads are *additional* threads passed to the '-@' argument threads = "" if snakemake.threads <= 1 else " -@ {} ".format(snakemake.threads - 1) shell( "samtools index {threads} {extra} {snakemake.input[0]} {snakemake.output[0]} {log}" ) .. |nl| raw:: html