From 786279b4735481e734e1dafcb1285d7868bd4e13 Mon Sep 17 00:00:00 2001 From: Chase Mateusiak Date: Tue, 27 Sep 2022 14:44:47 -0500 Subject: [PATCH] New Module: NextGenMap (#1938) adding nextgenmap module Co-authored-by: Simon Pearce <24893913+SPPearce@users.noreply.github.com> --- modules/nextgenmap/main.nf | 58 ++++++++++++++++++++++++ modules/nextgenmap/meta.yml | 55 ++++++++++++++++++++++ tests/config/pytest_modules.yml | 4 ++ tests/modules/nextgenmap/main.nf | 36 +++++++++++++++ tests/modules/nextgenmap/nextflow.config | 5 ++ tests/modules/nextgenmap/test.yml | 15 ++++++ 6 files changed, 173 insertions(+) create mode 100644 modules/nextgenmap/main.nf create mode 100644 modules/nextgenmap/meta.yml create mode 100644 tests/modules/nextgenmap/main.nf create mode 100644 tests/modules/nextgenmap/nextflow.config create mode 100644 tests/modules/nextgenmap/test.yml diff --git a/modules/nextgenmap/main.nf b/modules/nextgenmap/main.nf new file mode 100644 index 00000000..ad619420 --- /dev/null +++ b/modules/nextgenmap/main.nf @@ -0,0 +1,58 @@ +process NEXTGENMAP { + tag "$meta.id" + label 'process_medium' + + conda (params.enable_conda ? "bioconda::nextgenmap=0.5.5" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/nextgenmap%3A0.5.5--hc9558a2_4' : + 'quay.io/biocontainers/nextgenmap:0.5.5--hc9558a2_4' }" + + input: + tuple val(meta), path(reads) + path(fasta) + + output: + tuple val(meta), path("*.bam"), emit: bam + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + def threads = task.cpus + + if(meta.single_end){ + """ + ngm \\ + -r $fasta \\ + -q $reads \\ + -t $threads \\ + --bam \\ + -o ${prefix}.bam \\ + $args + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + NextGenMap: \$(ngm 2>&1 | head -1 | grep -o -E '[[:digit:]]+.[[:digit:]]+.[[:digit:]]+') + END_VERSIONS + """ + } else{ + """ + ngm \\ + -r $fasta \\ + -1 ${reads[0]} \\ + -2 ${reads[1]} \\ + -t $threads \\ + --bam \\ + -o ${prefix}.bam \\ + $args + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + NextGenMap: \$(ngm 2>&1 | head -1 | grep -o -E '[[:digit:]]+.[[:digit:]]+.[[:digit:]]+') + END_VERSIONS + """ + } +} diff --git a/modules/nextgenmap/meta.yml b/modules/nextgenmap/meta.yml new file mode 100644 index 00000000..11c2fd28 --- /dev/null +++ b/modules/nextgenmap/meta.yml @@ -0,0 +1,55 @@ +name: nextgenmap +description: Performs fastq alignment to a fasta reference using NextGenMap +keywords: + - NextGenMap + - ngm + - alignment + - map + - fastq + - bam + - sam +tools: + - bwa: + description: | + NextGenMap is a flexible highly sensitive short read mapping tool that + handles much higher mismatch rates than comparable algorithms while + still outperforming them in terms of runtime + homepage: https://github.com/Cibiv/NextGenMap + documentation: https://github.com/Cibiv/NextGenMap/wiki + doi: 10.1093/bioinformatics/btt468 + licence: ["MIT"] +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, if meta.single_end is true, and 2 + if meta.single_end is false. + - fasta: + type: file + description: | + Genomic reference fasta file + pattern: "*.{fa,fa.gz,fas,fas.gz,fna,fna.gz,fasta,fasta.gz}" +output: + - meta: + type: map + description: | + Groovy Map containing sample information. First item of tuple with + bam, below. + e.g. [ id:'test', single_end:false ] + - bam: + type: file + description: | + Output BAM file containing read alignments. Second item of tuple with + meta, above + pattern: "*.{bam}" + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" +authors: + - "@cmatkhan" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 166023d2..99df6ba1 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -1723,6 +1723,10 @@ nextclade/run: - modules/nextclade/run/** - tests/modules/nextclade/run/** +nextgenmap: + - modules/nextgenmap/** + - tests/modules/nextgenmap/** + ngmaster: - modules/ngmaster/** - tests/modules/ngmaster/** diff --git a/tests/modules/nextgenmap/main.nf b/tests/modules/nextgenmap/main.nf new file mode 100644 index 00000000..450551de --- /dev/null +++ b/tests/modules/nextgenmap/main.nf @@ -0,0 +1,36 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { NEXTGENMAP } from '../../../modules/nextgenmap/main.nf' + +// +// Test with single-end data +// +workflow test_nextgenmap_single { + input = [ + [ id:'test', single_end:true ], // meta map + [ + file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true) + ] + ] + fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) + + NEXTGENMAP ( input, fasta ) +} + +// +// Test with paired-end data +// +workflow test_bwamem2_mem_paired_end { + 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) + ] + ] + fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) + + NEXTGENMAP ( input, fasta ) +} diff --git a/tests/modules/nextgenmap/nextflow.config b/tests/modules/nextgenmap/nextflow.config new file mode 100644 index 00000000..8730f1c4 --- /dev/null +++ b/tests/modules/nextgenmap/nextflow.config @@ -0,0 +1,5 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + +} diff --git a/tests/modules/nextgenmap/test.yml b/tests/modules/nextgenmap/test.yml new file mode 100644 index 00000000..96c51d2c --- /dev/null +++ b/tests/modules/nextgenmap/test.yml @@ -0,0 +1,15 @@ +- name: nextgenmap test_nextgenmap_single + command: nextflow run ./tests/modules/nextgenmap -entry test_nextgenmap_single -c ./tests/config/nextflow.config -c ./tests/modules/nextgenmap/nextflow.config + tags: + - nextgenmap + files: + - path: output/nextgenmap/test.bam + md5sum: ada069bc5c670ffee23871f3ca525d0a + +- name: nextgenmap test_bwamem2_mem_paired_end + command: nextflow run ./tests/modules/nextgenmap -entry test_bwamem2_mem_paired_end -c ./tests/config/nextflow.config -c ./tests/modules/nextgenmap/nextflow.config + tags: + - nextgenmap + files: + - path: output/nextgenmap/test.bam + md5sum: fa76167e236cf1aabdafdbb0632253cd