From b59713e6230cd5966d176cfd23288074612ede8f Mon Sep 17 00:00:00 2001 From: Matthias De Smet <11850640+matthdsm@users.noreply.github.com> Date: Tue, 12 Apr 2022 11:20:35 +0200 Subject: [PATCH] Tool/snap aligner single (#1510) * first commit * add tool * fix tests * fix indents * Update modules/snapaligner/single/meta.yml Co-authored-by: James A. Fellows Yates * fix comments * fix versions * prettier Co-authored-by: James A. Fellows Yates --- modules/snapaligner/single/main.nf | 41 ++++++++++++++++ modules/snapaligner/single/meta.yml | 48 +++++++++++++++++++ tests/config/pytest_modules.yml | 4 ++ tests/modules/snapaligner/single/main.nf | 17 +++++++ .../snapaligner/single/nextflow.config | 5 ++ tests/modules/snapaligner/single/test.yml | 9 ++++ 6 files changed, 124 insertions(+) create mode 100644 modules/snapaligner/single/main.nf create mode 100644 modules/snapaligner/single/meta.yml create mode 100644 tests/modules/snapaligner/single/main.nf create mode 100644 tests/modules/snapaligner/single/nextflow.config create mode 100644 tests/modules/snapaligner/single/test.yml diff --git a/modules/snapaligner/single/main.nf b/modules/snapaligner/single/main.nf new file mode 100644 index 00000000..b13e1153 --- /dev/null +++ b/modules/snapaligner/single/main.nf @@ -0,0 +1,41 @@ +process SNAPALIGNER_SINGLE { + tag '$meta.id' + label 'process_high' + + conda (params.enable_conda ? "bioconda::snap-aligner=2.0.1" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/snap-aligner:2.0.1--hd03093a_1': + 'quay.io/biocontainers/snap-aligner:2.0.1--hd03093a_1' }" + + input: + tuple val(meta), path(reads) + path index + + 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}" + + """ + mkdir -p index + mv $index index/ + + snap-aligner single \\ + index \\ + ${reads.join(" ")} \\ + -o -bam ${prefix}.bam \\ + -t ${task.cpus} \\ + $args + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + snapaligner: \$(snap-aligner 2>&1| head -n 1 | sed 's/^.*version //;s/.\$//') + END_VERSIONS + """ +} diff --git a/modules/snapaligner/single/meta.yml b/modules/snapaligner/single/meta.yml new file mode 100644 index 00000000..e69cc721 --- /dev/null +++ b/modules/snapaligner/single/meta.yml @@ -0,0 +1,48 @@ +name: "snapaligner_single" +description: Performs single end fastq alignment to a fasta reference using SNAP +keywords: + - alignment + - map + - fastq + - bam + - sam +tools: + - "snapaligner": + description: "Scalable Nucleotide Alignment Program -- a fast and accurate read aligner for high-throughput sequencing data" + homepage: "http://snap.cs.berkeley.edu" + documentation: "https://1drv.ms/b/s!AhuEg_0yZD86hcpblUt-muHKYsG8fA?e=R8ogug" + tool_dev_url: "https://github.com/amplab/snap" + doi: "10.1101/2021.11.23.469039" + licence: "['Apache v2']" +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - reads: + type: file + description: List of single end input files + pattern: "*.{fastq.gz,fq.gz,fastq,fq,bam}" + - index: + type: file + description: List of SNAP genome index files + pattern: "{Genome,GenomeIndex,GenomeIndexHash,OverflowTable}" + +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" + - bam: + type: file + description: Aligned BAM file + pattern: "*.{bam}" + +authors: + - "@matthdsm" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index b195968f..cd4913cf 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -1679,6 +1679,10 @@ snapaligner/paired: - modules/snapaligner/paired/** - tests/modules/snapaligner/paired/** +snapaligner/single: + - modules/snapaligner/single/** + - tests/modules/snapaligner/single/** + snpdists: - modules/snpdists/** - tests/modules/snpdists/** diff --git a/tests/modules/snapaligner/single/main.nf b/tests/modules/snapaligner/single/main.nf new file mode 100644 index 00000000..616e517a --- /dev/null +++ b/tests/modules/snapaligner/single/main.nf @@ -0,0 +1,17 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { SNAPALIGNER_INDEX } from '../../../../modules/snapaligner/index/main.nf' +include { SNAPALIGNER_SINGLE } from '../../../../modules/snapaligner/single/main.nf' + +workflow test_snapaligner_single { + + input = [ + [ id:'test', single_end:false ], // meta map + [file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true)] + ] + + SNAPALIGNER_INDEX ( file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true),[],[],[]) + SNAPALIGNER_SINGLE ( input, SNAPALIGNER_INDEX.out.index ) +} diff --git a/tests/modules/snapaligner/single/nextflow.config b/tests/modules/snapaligner/single/nextflow.config new file mode 100644 index 00000000..50f50a7a --- /dev/null +++ b/tests/modules/snapaligner/single/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/snapaligner/single/test.yml b/tests/modules/snapaligner/single/test.yml new file mode 100644 index 00000000..bbcbba1f --- /dev/null +++ b/tests/modules/snapaligner/single/test.yml @@ -0,0 +1,9 @@ +- name: snapaligner single test_snapaligner_single + command: nextflow run tests/modules/snapaligner/single -entry test_snapaligner_single -c tests/config/nextflow.config + tags: + - snapaligner/single + - snapaligner + files: + - path: output/snapaligner/test.bam + md5sum: 696f7ea8e1aa5f9d7dafb9d0134fe25d + - path: output/snapaligner/versions.yml