SNPSIFT DBNSFP

Annotate using integrated annotation from dbNSFP with SnpSift

URL:

Example

This wrapper can be used in the following way:

rule test_snpsift_dbnsfp:
    input:
        call = "in.vcf",
        dbNSFP = "dbNSFP.txt.gz"
    output:
        call = "out.vcf"
    # optional specification of memory usage of the JVM that snakemake will respect with global
    # resource restrictions (https://snakemake.readthedocs.io/en/latest/snakefiles/rules.html#resources)
    # and which can be used to request RAM during cluster job submission as `{resources.mem_mb}`:
    # https://snakemake.readthedocs.io/en/latest/executing/cluster.html#job-properties
    resources:
        mem_mb=1024
    wrapper:
        "0.77.0-2-gf3a6529/bio/snpsift/dbnsfp"

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

  • snpsift=4.3.1t
  • bcftools==1.10.2
  • snakemake-wrapper-utils==0.1.3

Input/Output

Input:

  • Calls that are to be annoated
  • A dnNSFP text file

Output:

  • Annotated calls

Authors

  • Thibault Dayris

Code

"""Snakemake wrapper for SnpSift dbNSFP"""

__author__ = "Thibault Dayris"
__copyright__ = "Copyright 2020, Dayris Thibault"
__email__ = "thibault.dayris@gustaveroussy.fr"
__license__ = "MIT"

from snakemake.shell import shell
from snakemake_wrapper_utils.java import get_java_opts

extra = snakemake.params.get("extra", "")
java_opts = get_java_opts(snakemake)
log = snakemake.log_fmt_shell(stdout=False, stderr=True)

# Using user-defined file if requested
db = snakemake.input.get("dbNSFP", "")
if db != "":
    db = "-db {}".format(db)

min_threads = 1

# Uncompression shall be done on user request
incall = snakemake.input["call"]
if incall.endswith("bcf"):
    min_threads += 1
    incall = "< <(bcftools view {})".format(incall)
elif incall.endswith("gz"):
    min_threads += 1
    incall = "< <(gunzip -c {})".format(incall)

# Compression shall be done according to user-defined output
outcall = snakemake.output["call"]
if outcall.endswith("gz"):
    min_threads += 1
    outcall = "| gzip -c > {}".format(outcall)
elif outcall.endswith("bcf"):
    min_threads += 1
    outcall = "| bcftools view > {}".format(outcall)
else:
    outcall = "> {}".format(outcall)

# Each (un)compression raises the thread number
if snakemake.threads < min_threads:
    raise ValueError(
        "At least {} threads required, {} provided".format(
            min_threads, snakemake.threads
        )
    )


shell(
    "SnpSift dbnsfp"  # Tool and its subcommand
    " {java_opts} {extra}"  # Extra parameters
    " {db}"  # Path to annotation vcf file
    " {incall}"  # Path to input vcf file
    " {outcall}"  # Path to output vcf file
    " {log}"  # Logging behaviour
)