.. _`bio/hisat2/index`: HISAT2 INDEX ============ .. image:: https://img.shields.io/github/issues-pr/snakemake/snakemake-wrappers/bio/hisat2/index?label=version%20update%20pull%20requests :target: https://github.com/snakemake/snakemake-wrappers/pulls?q=is%3Apr+is%3Aopen+label%3Abio/hisat2/index Create index with hisat2. Example ------- This wrapper can be used in the following way: .. code-block:: python rule hisat2_index: input: fasta = "{genome}.fasta" output: directory("index_{genome}") params: prefix = "index_{genome}/" log: "logs/hisat2_index_{genome}.log" threads: 2 wrapper: "v3.0.1/bio/hisat2/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. Software dependencies --------------------- * ``hisat2=2.2.1`` * ``samtools=1.18`` Input/Output ------------ **Input:** * ``sequence``: list of FASTA files of list of sequences **Output:** * Directory of the hisat2 custom index. Params ------ * ``prefix``: prefix of index file path (required). Must be related to output * ``extra``: additional parameters Authors ------- * Joël Simoneau Code ---- .. code-block:: python """Snakemake wrapper for HISAT2 index""" __author__ = "Joël Simoneau" __copyright__ = "Copyright 2019, Joël Simoneau" __email__ = "simoneaujoel@gmail.com" __license__ = "MIT" import os from snakemake.shell import shell # Creating log log = snakemake.log_fmt_shell(stdout=True, stderr=True) # Placeholder for optional parameters extra = snakemake.params.get("extra", "") # Allowing for multiple FASTA files fasta = snakemake.input.get("fasta") assert fasta is not None, "input-> a FASTA-file or a sequence is required" input_seq = "" if not "." in fasta: input_seq += "-c " input_seq += ",".join(fasta) if isinstance(fasta, list) else fasta hisat_dir = snakemake.params.get("prefix", "") if hisat_dir: os.makedirs(hisat_dir) shell( "hisat2-build {extra} " "-p {snakemake.threads} " "{input_seq} " "{snakemake.params.prefix} " "{log}" ) .. |nl| raw:: html