.. _`bio/gatk/printreadsspark`: GATK PRINTREADSSPARK ==================== .. image:: https://img.shields.io/github/issues-pr/snakemake/snakemake-wrappers/bio/gatk/printreadsspark?label=version%20update%20pull%20requests :target: https://github.com/snakemake/snakemake-wrappers/pulls?q=is%3Apr+is%3Aopen+label%3Abio/gatk/printreadsspark Write reads from SAM format file (SAM/BAM/CRAM) that pass specified criteria to a new file. This is the version that can be run on Spark. **URL**: https://gatk.broadinstitute.org/hc/en-us/articles/9570521694747-PrintReadsSpark Example ------- This wrapper can be used in the following way: .. code-block:: python rule gatk_printreadsspark: input: bam="mapped/{sample}.bam", ref="genome.fasta", dict="genome.dict", output: bam="{sample}.bam", log: "logs/{sample}.log", params: extra="", # optional java_opts="", # optional #spark_runner="", # optional, local by default #spark_v3.0.1="", # optional #spark_extra="", # optional resources: mem_mb=1024, threads: 8 wrapper: "v3.0.1/bio/gatk/printreadsspark" 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 `java_opts` param allows for additional arguments to be passed to the java compiler, e.g. "-XX:ParallelGCThreads=10" (not for `-XmX` or `-Djava.io.tmpdir`, since they are handled automatically). * The `extra` param allows for additional program arguments for `printreadsspark`. * The `spark_runner` param = "LOCAL"|"SPARK"|"GCS" allows to set the spark_runner. Set the parameter to "LOCAL" or don't set it at all to run on local machine. * The `spark_master` param allows to set the URL of the Spark Master to submit the job. Set to "local[number_of_cores]" for local execution. Don't set it at all for local execution with number of cores determined by snakemake. * The `spark_extra` param allows for additional spark arguments. Software dependencies --------------------- * ``gatk4=4.4.0.0`` * ``snakemake-wrapper-utils=0.6.2`` Input/Output ------------ **Input:** * bam file * reference file * reference dict **Output:** * filtered bam file Authors ------- * Filipe G. Vieira Code ---- .. code-block:: python __author__ = "Filipe G. Vieira" __copyright__ = "Copyright 2021, Filipe G. Vieira" __license__ = "MIT" import tempfile from snakemake.shell import shell from snakemake_wrapper_utils.java import get_java_opts log = snakemake.log_fmt_shell(stdout=True, stderr=True) extra = snakemake.params.get("extra", "") spark_runner = snakemake.params.get("spark_runner", "LOCAL") spark_master = snakemake.params.get( "spark_master", "local[{}]".format(snakemake.threads) ) spark_extra = snakemake.params.get("spark_extra", "") java_opts = get_java_opts(snakemake) with tempfile.TemporaryDirectory() as tmpdir: shell( "gatk --java-options '{java_opts}' PrintReadsSpark" " --input {snakemake.input.bam}" " --reference {snakemake.input.ref}" " {extra}" " --tmp-dir {tmpdir}" " --output {snakemake.output.bam}" " -- --spark-runner {spark_runner} --spark-master {spark_master} {spark_extra}" " {log}" ) .. |nl| raw:: html