diff --git a/modules/snippy/run/main.nf b/modules/snippy/run/main.nf new file mode 100644 index 00000000..73c4b94d --- /dev/null +++ b/modules/snippy/run/main.nf @@ -0,0 +1,55 @@ +process SNIPPY_RUN { + tag "$meta.id" + label 'process_low' + + conda (params.enable_conda ? "bioconda::snippy=4.6.0" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/snippy:4.6.0--hdfd78af_2 ': + 'quay.io/biocontainers/snippy:4.6.0--hdfd78af_2' }" + + input: + tuple val(meta), path(reads) + path reference + + output: + tuple val(meta), path("${prefix}/${prefix}.tab") , emit: tab + tuple val(meta), path("${prefix}/${prefix}.csv") , emit: csv + tuple val(meta), path("${prefix}/${prefix}.html") , emit: html + tuple val(meta), path("${prefix}/${prefix}.vcf") , emit: vcf + tuple val(meta), path("${prefix}/${prefix}.bed") , emit: bed + tuple val(meta), path("${prefix}/${prefix}.gff") , emit: gff + tuple val(meta), path("${prefix}/${prefix}.bam") , emit: bam + tuple val(meta), path("${prefix}/${prefix}.bam.bai") , emit: bai + tuple val(meta), path("${prefix}/${prefix}.log") , emit: log + tuple val(meta), path("${prefix}/${prefix}.aligned.fa") , emit: aligned_fa + tuple val(meta), path("${prefix}/${prefix}.consensus.fa") , emit: consensus_fa + tuple val(meta), path("${prefix}/${prefix}.consensus.subs.fa"), emit: consensus_subs_fa + tuple val(meta), path("${prefix}/${prefix}.raw.vcf") , emit: raw_vcf + tuple val(meta), path("${prefix}/${prefix}.filt.vcf") , emit: filt_vcf + tuple val(meta), path("${prefix}/${prefix}.vcf.gz") , emit: vcf_gz + tuple val(meta), path("${prefix}/${prefix}.vcf.gz.csi") , emit: vcf_csi + tuple val(meta), path("${prefix}/${prefix}.txt") , emit: txt + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + prefix = task.ext.prefix ?: "${meta.id}" + def read_inputs = meta.single_end ? "--se ${reads[0]}" : "--R1 ${reads[0]} --R2 ${reads[1]}" + """ + snippy \\ + $args \\ + --cpus $task.cpus \\ + --outdir $prefix \\ + --reference $reference \\ + --prefix $prefix \\ + $read_inputs + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + snippy: \$(echo \$(snippy --version 2>&1) | sed 's/snippy //') + END_VERSIONS + """ +} diff --git a/modules/snippy/run/meta.yml b/modules/snippy/run/meta.yml new file mode 100644 index 00000000..fa176399 --- /dev/null +++ b/modules/snippy/run/meta.yml @@ -0,0 +1,110 @@ +name: snippy +description: Rapid haploid variant calling +keywords: + - variant + - fastq + - bacteria +tools: + - snippy: + description: "Rapid bacterial SNP calling and core genome alignments" + homepage: "https://github.com/tseemann/snippy" + documentation: "https://github.com/tseemann/snippy" + tool_dev_url: "https://github.com/tseemann/snippy" + doi: "" + licence: "['GPL v2']" +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - reads: + type: file + description: | + List of input FastQ files of size 1 and 2 for single-end and paired-end data, + respectively. + pattern: "*.{fq,fastq,fq.gz,fastq.gz}" + - index: + type: file + description: Reference genome in GenBank (preferred) or FASTA format + pattern: "*.{gbk,gbk.gz,fa,fa.gz}" +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + - tab: + type: file + description: A simple tab-separated summary of all the variants + pattern: "*.tab" + - csv: + type: file + description: A comma-separated version of the .tab file + pattern: "*.csv" + - html: + type: file + description: A HTML version of the .tab file + pattern: "*.html" + - vcf: + type: file + description: The final annotated variants in VCF format + pattern: "*.vcf" + - bed: + type: file + description: The variants in BED format + pattern: "*.bed" + - gff: + type: file + description: The variants in GFF3 format + pattern: "*.gff" + - bam: + type: file + description: The alignments in BAM format. Includes unmapped, multimapping reads. Excludes duplicates. + pattern: "*.bam" + - bai: + type: file + description: Index for the .bam file + pattern: "*.bam.bai" + - log: + type: file + description: A log file with the commands run and their outputs + pattern: "*.log" + - aligned_fa: + type: file + description: A version of the reference but with - at position with depth=0 and N for 0 < depth < --mincov (does not have variants) + pattern: "*.aligned.fa" + - consensus_fa: + type: file + description: A version of the reference genome with all variants instantiated + pattern: "*.consensus.fa" + - consensus_subs_fa: + type: file + description: A version of the reference genome with only substitution variants instantiated + pattern: "*.consensus.subs.fa" + - raw_vcf: + type: file + description: The unfiltered variant calls from Freebayes + pattern: "*.raw.vcf" + - filt_vcf: + type: file + description: The filtered variant calls from Freebayes + pattern: "*.filt.vcf" + - vcf_gz: + type: file + description: Compressed .vcf file via BGZIP + pattern: "*.vcf.gz" + - vcf_csi: + type: file + description: Index for the .vcf.gz via bcftools index + pattern: "*.vcf.gz.csi" + - txt: + type: file + description: Tab-separated columnar list of statistics + pattern: "*.txt" +authors: + - "@rpetit3" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 9afe83fd..5a204ac4 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -1643,14 +1643,14 @@ samtools/bam2fq: - modules/samtools/bam2fq/** - tests/modules/samtools/bam2fq/** -samtools/convert: - - modules/samtools/convert/** - - tests/modules/samtools/convert/** - samtools/collatefastq: - modules/samtools/collatefastq/** - tests/modules/samtools/collatefastq/** +samtools/convert: + - modules/samtools/convert/** + - tests/modules/samtools/convert/** + samtools/depth: - modules/samtools/depth/** - tests/modules/samtools/depth/** @@ -1787,6 +1787,10 @@ snapaligner/index: - modules/snapaligner/index/** - tests/modules/snapaligner/index/** +snippy/run: + - modules/snippy/run/** + - tests/modules/snippy/run/** + snpdists: - modules/snpdists/** - tests/modules/snpdists/** diff --git a/tests/modules/snippy/run/main.nf b/tests/modules/snippy/run/main.nf new file mode 100644 index 00000000..bfc4082e --- /dev/null +++ b/tests/modules/snippy/run/main.nf @@ -0,0 +1,16 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { SNIPPY_RUN } from '../../../../modules/snippy/run/main.nf' + +workflow test_snippy_run { + + input = [ [ id:'test', single_end:false ], // meta map + [ file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true), + file(params.test_data['sarscov2']['illumina']['test_2_fastq_gz'], checkIfExists: true) ] + ] + reference = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) + + SNIPPY_RUN ( input, reference ) +} diff --git a/tests/modules/snippy/run/nextflow.config b/tests/modules/snippy/run/nextflow.config new file mode 100644 index 00000000..50f50a7a --- /dev/null +++ b/tests/modules/snippy/run/nextflow.config @@ -0,0 +1,5 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + +} \ No newline at end of file diff --git a/tests/modules/snippy/run/test.yml b/tests/modules/snippy/run/test.yml new file mode 100644 index 00000000..e38e8b9e --- /dev/null +++ b/tests/modules/snippy/run/test.yml @@ -0,0 +1,39 @@ +- name: snippy run test_snippy_run + command: nextflow run tests/modules/snippy/run -entry test_snippy_run -c tests/config/nextflow.config -c tests/modules/snippy/run/nextflow.config + tags: + - snippy + - snippy/run + files: + - path: output/snippy/test/test.aligned.fa + md5sum: 47e3390d4167edf1955d162d37aca5e3 + - path: output/snippy/test/test.bam + - path: output/snippy/test/test.bam.bai + - path: output/snippy/test/test.bed + md5sum: d41d8cd98f00b204e9800998ecf8427e + - path: output/snippy/test/test.consensus.fa + md5sum: 483f4a5dfe60171c86ee9b7e6dff908b + - path: output/snippy/test/test.consensus.subs.fa + md5sum: 483f4a5dfe60171c86ee9b7e6dff908b + - path: output/snippy/test/test.csv + md5sum: 322f942115e5945c2041a88246166703 + - path: output/snippy/test/test.filt.vcf + contains: ['fileformat', 'freebayes', 'CHROM'] + - path: output/snippy/test/test.gff + md5sum: df19e1b84ba6f691d20c72b397c88abf + - path: output/snippy/test/test.html + md5sum: 1ccbf0ffcadae1a6b2e11681d24c9938 + - path: output/snippy/test/test.log + contains: ['snippy', 'consensus', 'subs'] + - path: output/snippy/test/test.raw.vcf + contains: ['fileformat', 'freebayes', 'CHROM'] + - path: output/snippy/test/test.tab + md5sum: beb9bde3bce985e53e8feba9ec5b136e + - path: output/snippy/test/test.txt + contains: ['DateTime', 'ReadFiles', 'VariantTotal'] + - path: output/snippy/test/test.vcf + contains: ['fileformat', 'freebayes', 'CHROM'] + - path: output/snippy/test/test.vcf.gz + - path: output/snippy/test/test.vcf.gz.csi + md5sum: bed9fa291c220a1ba04eb2d448932ffc + - path: output/snippy/versions.yml + md5sum: 518aad56c4dbefb6cbcde5ab38cf7b5d