mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-12-22 11:08:17 +00:00
Add snpeff (#546)
* feat: add snpeff * fix: linting * fix: tests * fix: add csv output * fix: add params information * fix: improve script * Update software/snpeff/environment.yml * Update software/snpeff/environment.yml Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * Apply suggestions from code review * fix test Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>
This commit is contained in:
parent
7b4a28b6e8
commit
e0d820f9f4
9 changed files with 262 additions and 0 deletions
22
software/snpeff/Dockerfile
Normal file
22
software/snpeff/Dockerfile
Normal file
|
@ -0,0 +1,22 @@
|
|||
FROM nfcore/base:1.14
|
||||
LABEL \
|
||||
author="Maxime Garcia" \
|
||||
description="snpEff image for nf-core pipelines" \
|
||||
maintainer="maxime.garcia@scilifelab.se"
|
||||
|
||||
# Install the conda environment
|
||||
COPY environment.yml /
|
||||
RUN conda env create -f /environment.yml && conda clean -a
|
||||
|
||||
# Add conda installation dir to PATH (instead of doing 'conda activate')
|
||||
ENV PATH /opt/conda/envs/nf-core-snpeff-5.0/bin:$PATH
|
||||
|
||||
# Setup default ARG variables
|
||||
ARG GENOME=GRCh38
|
||||
ARG SNPEFF_CACHE_VERSION=99
|
||||
|
||||
# Download Genome
|
||||
RUN snpEff download -v ${GENOME}.${SNPEFF_CACHE_VERSION}
|
||||
|
||||
# Dump the details of the installed packages to a file for posterity
|
||||
RUN conda env export --name nf-core-snpeff-5.0 > nf-core-snpeff-5.0.yml
|
24
software/snpeff/build.sh
Executable file
24
software/snpeff/build.sh
Executable file
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Build and push all containers
|
||||
|
||||
build_push() {
|
||||
GENOME=$1
|
||||
SNPEFF_CACHE_VERSION=$2
|
||||
SNPEFF_TAG=$3
|
||||
|
||||
docker build \
|
||||
-t nfcore/snpeff:${SNPEFF_TAG}.${GENOME} \
|
||||
software/snpeff/. \
|
||||
--build-arg GENOME=${GENOME} \
|
||||
--build-arg SNPEFF_CACHE_VERSION=${SNPEFF_CACHE_VERSION}
|
||||
|
||||
docker push nfcore/snpeff:${SNPEFF_TAG}.${GENOME}
|
||||
}
|
||||
|
||||
build_push "GRCh37" "75" "5.0"
|
||||
build_push "GRCh38" "99" "5.0"
|
||||
build_push "GRCm38" "99" "5.0"
|
||||
build_push "CanFam3.1" "99" "5.0"
|
||||
build_push "WBcel235" "99" "5.0"
|
10
software/snpeff/environment.yml
Normal file
10
software/snpeff/environment.yml
Normal file
|
@ -0,0 +1,10 @@
|
|||
# You can use this file to create a conda environment for this module:
|
||||
# conda env create -f environment.yml
|
||||
name: nf-core-snpeff-5.0
|
||||
channels:
|
||||
- conda-forge
|
||||
- bioconda
|
||||
- defaults
|
||||
|
||||
dependencies:
|
||||
- bioconda::snpeff=5.0
|
68
software/snpeff/functions.nf
Normal file
68
software/snpeff/functions.nf
Normal file
|
@ -0,0 +1,68 @@
|
|||
//
|
||||
// Utility functions used in nf-core DSL2 module files
|
||||
//
|
||||
|
||||
//
|
||||
// Extract name of software tool from process name using $task.process
|
||||
//
|
||||
def getSoftwareName(task_process) {
|
||||
return task_process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()
|
||||
}
|
||||
|
||||
//
|
||||
// Function to initialise default values and to generate a Groovy Map of available options for nf-core modules
|
||||
//
|
||||
def initOptions(Map args) {
|
||||
def Map options = [:]
|
||||
options.args = args.args ?: ''
|
||||
options.args2 = args.args2 ?: ''
|
||||
options.args3 = args.args3 ?: ''
|
||||
options.publish_by_meta = args.publish_by_meta ?: []
|
||||
options.publish_dir = args.publish_dir ?: ''
|
||||
options.publish_files = args.publish_files
|
||||
options.suffix = args.suffix ?: ''
|
||||
return options
|
||||
}
|
||||
|
||||
//
|
||||
// Tidy up and join elements of a list to return a path string
|
||||
//
|
||||
def getPathFromList(path_list) {
|
||||
def paths = path_list.findAll { item -> !item?.trim().isEmpty() } // Remove empty entries
|
||||
paths = paths.collect { it.trim().replaceAll("^[/]+|[/]+\$", "") } // Trim whitespace and trailing slashes
|
||||
return paths.join('/')
|
||||
}
|
||||
|
||||
//
|
||||
// Function to save/publish module results
|
||||
//
|
||||
def saveFiles(Map args) {
|
||||
if (!args.filename.endsWith('.version.txt')) {
|
||||
def ioptions = initOptions(args.options)
|
||||
def path_list = [ ioptions.publish_dir ?: args.publish_dir ]
|
||||
if (ioptions.publish_by_meta) {
|
||||
def key_list = ioptions.publish_by_meta instanceof List ? ioptions.publish_by_meta : args.publish_by_meta
|
||||
for (key in key_list) {
|
||||
if (args.meta && key instanceof String) {
|
||||
def path = key
|
||||
if (args.meta.containsKey(key)) {
|
||||
path = args.meta[key] instanceof Boolean ? "${key}_${args.meta[key]}".toString() : args.meta[key]
|
||||
}
|
||||
path = path instanceof String ? path : ''
|
||||
path_list.add(path)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ioptions.publish_files instanceof Map) {
|
||||
for (ext in ioptions.publish_files) {
|
||||
if (args.filename.endsWith(ext.key)) {
|
||||
def ext_list = path_list.collect()
|
||||
ext_list.add(ext.value)
|
||||
return "${getPathFromList(ext_list)}/$args.filename"
|
||||
}
|
||||
}
|
||||
} else if (ioptions.publish_files == null) {
|
||||
return "${getPathFromList(path_list)}/$args.filename"
|
||||
}
|
||||
}
|
||||
}
|
57
software/snpeff/main.nf
Normal file
57
software/snpeff/main.nf
Normal file
|
@ -0,0 +1,57 @@
|
|||
// Import generic module functions
|
||||
include { initOptions; saveFiles; getSoftwareName } from './functions'
|
||||
|
||||
params.options = [:]
|
||||
options = initOptions(params.options)
|
||||
params.use_cache = false
|
||||
params.snpeff_tag = ""
|
||||
|
||||
process SNPEFF {
|
||||
label 'process_medium'
|
||||
publishDir "${params.outdir}",
|
||||
mode: params.publish_dir_mode,
|
||||
saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), meta:meta, publish_by_meta:['id']) }
|
||||
|
||||
conda (params.enable_conda ? "bioconda::snpeff=5.0" : null)
|
||||
if (params.use_cache) {
|
||||
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||
container "https://depot.galaxyproject.org/singularity/snpeff:5.0--hdfd78af_1"
|
||||
} else {
|
||||
container "quay.io/biocontainers/snpeff:5.0--hdfd78af_1"
|
||||
}
|
||||
} else {
|
||||
container "nfcore/snpeff:${params.snpeff_tag}"
|
||||
}
|
||||
|
||||
input:
|
||||
tuple val(meta), path(vcf)
|
||||
val db
|
||||
path cache
|
||||
|
||||
output:
|
||||
tuple val(meta), path("*.ann.vcf"), emit: vcf
|
||||
path "*.csv" , emit: report
|
||||
path "*.version.txt" , emit: version
|
||||
|
||||
script:
|
||||
def software = getSoftwareName(task.process)
|
||||
def avail_mem = 6
|
||||
if (!task.memory) {
|
||||
log.info '[snpEff] Available memory not known - defaulting to 6GB. Specify process memory requirements to change this.'
|
||||
} else {
|
||||
avail_mem = task.memory.giga
|
||||
}
|
||||
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
||||
cache = params.use_cache ? "-dataDir \${PWD}/${snpeff_cache}" : ""
|
||||
"""
|
||||
snpEff -Xmx${avail_mem}g \\
|
||||
$db \\
|
||||
$options.args \\
|
||||
-csvStats ${prefix}.csv \\
|
||||
$cache \\
|
||||
$vcf \\
|
||||
> ${prefix}.ann.vcf
|
||||
|
||||
echo \$(snpEff -version 2>&1) > ${software}.version.txt
|
||||
"""
|
||||
}
|
57
software/snpeff/meta.yml
Normal file
57
software/snpeff/meta.yml
Normal file
|
@ -0,0 +1,57 @@
|
|||
name: snpEff
|
||||
description: Genetic variant annotation and functional effect prediction toolbox
|
||||
keywords:
|
||||
- annotation
|
||||
tools:
|
||||
- snpeff:
|
||||
description: |
|
||||
SnpEff is a variant annotation and effect prediction tool.
|
||||
It annotates and predicts the effects of genetic variants on genes and proteins (such as amino acid changes).
|
||||
homepage: https://pcingola.github.io/SnpEff/
|
||||
documentation: https://pcingola.github.io/SnpEff/se_introduction/
|
||||
params:
|
||||
- use_cache:
|
||||
type: boolean
|
||||
description: |
|
||||
boolean to enable the usage of containers with cache
|
||||
Enable the usage of containers with cache
|
||||
Does not work with conda
|
||||
- snpeff_tag:
|
||||
type: value
|
||||
description: |
|
||||
Specify the tag for the container
|
||||
https://hub.docker.com/r/nfcore/snpeff/tags
|
||||
input:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'test', single_end:false ]
|
||||
- vcf:
|
||||
type: file
|
||||
description: |
|
||||
vcf to annotate
|
||||
- db:
|
||||
type: value
|
||||
description: |
|
||||
which db to annotate with
|
||||
- cache:
|
||||
type: file
|
||||
description: |
|
||||
path to snpEff cache (optional)
|
||||
output:
|
||||
- vcf:
|
||||
type: file
|
||||
description: |
|
||||
annotated vcf
|
||||
pattern: "*.ann.vcf"
|
||||
- report:
|
||||
type: file
|
||||
description: snpEff report file
|
||||
pattern: "*.html"
|
||||
- version:
|
||||
type: file
|
||||
description: File containing software version
|
||||
pattern: "*.{version.txt}"
|
||||
authors:
|
||||
- "@maxulysse"
|
|
@ -719,6 +719,10 @@ shovill:
|
|||
- software/shovill/**
|
||||
- tests/software/shovill/**
|
||||
|
||||
snpeff:
|
||||
- software/snpeff/**
|
||||
- tests/software/snpeff/**
|
||||
|
||||
snpsites:
|
||||
- software/snpsites/**
|
||||
- tests/software/snpsites/**
|
||||
|
|
12
tests/software/snpeff/main.nf
Normal file
12
tests/software/snpeff/main.nf
Normal file
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env nextflow
|
||||
|
||||
nextflow.enable.dsl = 2
|
||||
|
||||
include { SNPEFF } from '../../../software/snpeff/main.nf' addParams( snpeff_tag: '5.0.WBcel235', use_cache: false )
|
||||
|
||||
workflow test_snpeff {
|
||||
input = [ [ id:'test' ], // meta map
|
||||
[ file(params.test_data['sarscov2']['illumina']['test_vcf'], checkIfExists: true) ]
|
||||
]
|
||||
SNPEFF ( input, "WBcel235.99", [] )
|
||||
}
|
8
tests/software/snpeff/test.yml
Normal file
8
tests/software/snpeff/test.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
- name: snpeff test_snpeff
|
||||
command: nextflow run tests/software/snpeff -entry test_snpeff -c tests/config/nextflow.config
|
||||
tags:
|
||||
- snpeff
|
||||
files:
|
||||
- path: output/snpeff/test.ann.vcf
|
||||
md5sum: 42db84cb186e33c6992f9306627201ac
|
||||
- path: output/snpeff/test.csv
|
Loading…
Reference in a new issue