diff --git a/modules/nf-core/lofreq/viterbi/environment.yml b/modules/nf-core/lofreq/viterbi/environment.yml new file mode 100644 index 00000000000..d81bc229270 --- /dev/null +++ b/modules/nf-core/lofreq/viterbi/environment.yml @@ -0,0 +1,8 @@ +name: "lofreq_viterbi" +channels: + - conda-forge + - bioconda + - defaults +dependencies: + - bioconda::lofreq=2.1.5 + - bioconda::samtools=1.17 diff --git a/modules/nf-core/lofreq/viterbi/main.nf b/modules/nf-core/lofreq/viterbi/main.nf new file mode 100644 index 00000000000..e16bd4a4cc3 --- /dev/null +++ b/modules/nf-core/lofreq/viterbi/main.nf @@ -0,0 +1,54 @@ +process LOFREQ_VITERBI { + tag "$meta.id" + label 'process_single' + + conda "${moduleDir}/environment.yml" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/lofreq:2.1.5--py310h47ef89e_10' : + 'biocontainers/lofreq:2.1.5--py310h47ef89e_10' }" + + input: + tuple val(meta), path(bam) + 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 args2 = task.ext.args2 ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + """ + lofreq \\ + viterbi \\ + $args \\ + -ref $fasta \\ + $bam | + samtools sort \\ + $args2 \\ + -T ${prefix} \\ + --threads $task.cpus \\ + -o ${prefix}.bam + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + lofreq: \$(echo \$(lofreq version 2>&1) | sed 's/^version: //; s/ *commit.*\$//') + END_VERSIONS + """ + + stub: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + """ + touch ${prefix}.bam + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + lofreq: \$(echo \$(lofreq version 2>&1) | sed 's/^version: //; s/ *commit.*\$//') + END_VERSIONS + """ +} diff --git a/modules/nf-core/lofreq/viterbi/meta.yml b/modules/nf-core/lofreq/viterbi/meta.yml new file mode 100644 index 00000000000..3ae9844b429 --- /dev/null +++ b/modules/nf-core/lofreq/viterbi/meta.yml @@ -0,0 +1,50 @@ +name: "lofreq_viterbi" +description: Lofreq subcommand to call low frequency variants from alignments when tumor-normal paired samples are available +keywords: + - variant calling + - low frequency variant calling + - variants + - bam + - probabilistic realignment +tools: + - "lofreq": + description: "A fast and sensitive variant-caller for inferring SNVs and indels from next-generation sequencing data" + homepage: https://csb5.github.io/lofreq/ + documentation: https://csb5.github.io/lofreq/commands/ + doi: 10.1093/nar/gks918 + licence: ["MIT"] +input: + # Only when we have meta + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + - bam: + type: file + description: Sorted BAM file + pattern: "*.{bam}" + - fasta: + type: file + description: Reference genome FASTA file + pattern: "*.{fasta}" +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + - bam: + type: file + description: Realignment and sorted BAM file + pattern: "*.{bam}" + +authors: + - "@MarieLataretu" +maintainers: + - "@MarieLataretu" diff --git a/modules/nf-core/lofreq/viterbi/tests/main.nf.test b/modules/nf-core/lofreq/viterbi/tests/main.nf.test new file mode 100644 index 00000000000..aa94635ec6c --- /dev/null +++ b/modules/nf-core/lofreq/viterbi/tests/main.nf.test @@ -0,0 +1,64 @@ +nextflow_process { + + name "Test Process LOFREQ_VITERBI" + script "../main.nf" + process "LOFREQ_VITERBI" + + tag "modules" + tag "modules_nfcore" + tag "lofreq" + tag "lofreq/viterbi" + + test("sarscov2 - bam, fasta") { + + when { + process { + """ + input[0] = [ + [ id:'test', single_end:false ], // meta map + file(params.test_data['sarscov2']['illumina']['test_paired_end_bam'], checkIfExists: true) + ] + input[1] = [ + file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + + } + + test("sarscov2 - bam, fasta - stub") { + + options "-stub" + + when { + process { + """ + input[0] = [ + [ id:'test', single_end:false ], // meta map + file(params.test_data['sarscov2']['illumina']['test_paired_end_bam'], checkIfExists: true) + ] + input[1] = [ + file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + + } + +} diff --git a/modules/nf-core/lofreq/viterbi/tests/main.nf.test.snap b/modules/nf-core/lofreq/viterbi/tests/main.nf.test.snap new file mode 100644 index 00000000000..051374e384d --- /dev/null +++ b/modules/nf-core/lofreq/viterbi/tests/main.nf.test.snap @@ -0,0 +1,72 @@ +{ + "sarscov2 - bam, fasta": { + "content": [ + { + "0": [ + [ + { + "id": "test", + "single_end": false + }, + "test.bam:md5,714e906a0c1a4e3d4c7e5ac25ea0edec" + ] + ], + "1": [ + "versions.yml:md5,42875f148272abe6fcf2a179235e1ebc" + ], + "bam": [ + [ + { + "id": "test", + "single_end": false + }, + "test.bam:md5,714e906a0c1a4e3d4c7e5ac25ea0edec" + ] + ], + "versions": [ + "versions.yml:md5,42875f148272abe6fcf2a179235e1ebc" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.04.1" + }, + "timestamp": "2024-03-19T11:22:12.627457484" + }, + "sarscov2 - bam, fasta - stub": { + "content": [ + { + "0": [ + [ + { + "id": "test", + "single_end": false + }, + "test.bam:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + "versions.yml:md5,42875f148272abe6fcf2a179235e1ebc" + ], + "bam": [ + [ + { + "id": "test", + "single_end": false + }, + "test.bam:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,42875f148272abe6fcf2a179235e1ebc" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.04.1" + }, + "timestamp": "2024-03-18T13:31:47.157939767" + } +} \ No newline at end of file diff --git a/modules/nf-core/lofreq/viterbi/tests/tags.yml b/modules/nf-core/lofreq/viterbi/tests/tags.yml new file mode 100644 index 00000000000..9c5b0876945 --- /dev/null +++ b/modules/nf-core/lofreq/viterbi/tests/tags.yml @@ -0,0 +1,2 @@ +lofreq/viterbi: + - "modules/nf-core/lofreq/viterbi/**"