CHM-EVAL-SAMPLE

Download CHM-eval sample (https://github.com/lh3/CHM-eval) for benchmarking variant calling.

URL:

Example

This wrapper can be used in the following way:

rule chm_eval_sample:
    output:
        bam="resources/chm-eval-sample.bam",
        bai="resources/chm-eval-sample.bam.bai"
    params:
        # Optionally only grab the first 100 records.
        # This is for testing, remove next line to grab all records.
        first_n=100
    log:
        "logs/chm-eval-sample.log"
    wrapper:
        "v1.2.0/bio/benchmark/chm-eval-sample"

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.10
  • curl

Authors

  • Johannes Köster

Code

__author__ = "Johannes Köster"
__copyright__ = "Copyright 2020, Johannes Köster"
__email__ = "johannes.koester@uni-due.de"
__license__ = "MIT"

from snakemake.shell import shell

log = snakemake.log_fmt_shell(stdout=False, stderr=True)

url = "ftp://ftp.sra.ebi.ac.uk/vol1/run/ERR134/ERR1341796/CHM1_CHM13_2.bam"

pipefail = ""
fmt = "-b"
prefix = snakemake.params.get("first_n", "")
if prefix:
    prefix = "| head -n {} | samtools view -h -b".format(prefix)
    fmt = "-h"
    pipefail = "set +o pipefail"

    shell(
        """
        {pipefail}
        {{
            samtools view {fmt} {url} {prefix} > {snakemake.output.bam}
            samtools index {snakemake.output.bam}
        }} {log}
        """
    )
else:
    shell(
        """
        {{
            curl -L {url} > {snakemake.output.bam}
            samtools index {snakemake.output.bam}
        }} {log}
        """
    )