From 48d5037b1336df121fd8922627273dbb9beef760 Mon Sep 17 00:00:00 2001 From: "Lataretu, Marie" Date: Mon, 18 Mar 2024 15:45:35 +0100 Subject: [PATCH 1/4] added new module lofraq/viterbi; solves new module: lofreq/viterbi #5158 --- .../nf-core/lofreq/viterbi/environment.yml | 9 +++ modules/nf-core/lofreq/viterbi/main.nf | 54 ++++++++++++++ modules/nf-core/lofreq/viterbi/meta.yml | 52 ++++++++++++++ .../nf-core/lofreq/viterbi/tests/main.nf.test | 64 +++++++++++++++++ .../lofreq/viterbi/tests/main.nf.test.snap | 72 +++++++++++++++++++ modules/nf-core/lofreq/viterbi/tests/tags.yml | 2 + 6 files changed, 253 insertions(+) create mode 100644 modules/nf-core/lofreq/viterbi/environment.yml create mode 100644 modules/nf-core/lofreq/viterbi/main.nf create mode 100644 modules/nf-core/lofreq/viterbi/meta.yml create mode 100644 modules/nf-core/lofreq/viterbi/tests/main.nf.test create mode 100644 modules/nf-core/lofreq/viterbi/tests/main.nf.test.snap create mode 100644 modules/nf-core/lofreq/viterbi/tests/tags.yml diff --git a/modules/nf-core/lofreq/viterbi/environment.yml b/modules/nf-core/lofreq/viterbi/environment.yml new file mode 100644 index 00000000000..ff5f29fd342 --- /dev/null +++ b/modules/nf-core/lofreq/viterbi/environment.yml @@ -0,0 +1,9 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json +name: "lofreq_viterbi" +channels: + - conda-forge + - bioconda + - defaults +dependencies: + - bioconda::lofreq=2.1.5 diff --git a/modules/nf-core/lofreq/viterbi/main.nf b/modules/nf-core/lofreq/viterbi/main.nf new file mode 100644 index 00000000000..9f842762b92 --- /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--py38h588ecb2_4' : + 'biocontainers/lofreq:2.1.5--py38h588ecb2_4' }" + + 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..b871cd1f76b --- /dev/null +++ b/modules/nf-core/lofreq/viterbi/meta.yml @@ -0,0 +1,52 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json +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..4e1d85e2c8d --- /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,5a6dabbbf1d179b208c18650778fb936" + ] + ], + "1": [ + "versions.yml:md5,42875f148272abe6fcf2a179235e1ebc" + ], + "bam": [ + [ + { + "id": "test", + "single_end": false + }, + "test.bam:md5,5a6dabbbf1d179b208c18650778fb936" + ] + ], + "versions": [ + "versions.yml:md5,42875f148272abe6fcf2a179235e1ebc" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.04.1" + }, + "timestamp": "2024-03-18T13:31:41.331061677" + }, + "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/**" From 9234a4c052847a62663e88c746acee6d6851ac52 Mon Sep 17 00:00:00 2001 From: "Lataretu, Marie" Date: Mon, 18 Mar 2024 15:45:35 +0100 Subject: [PATCH 2/4] added new module lofraq/viterbi; solves new module: lofreq/viterbi #5158 --- .../nf-core/lofreq/viterbi/environment.yml | 9 +++ modules/nf-core/lofreq/viterbi/main.nf | 54 ++++++++++++++ modules/nf-core/lofreq/viterbi/meta.yml | 52 ++++++++++++++ .../nf-core/lofreq/viterbi/tests/main.nf.test | 64 +++++++++++++++++ .../lofreq/viterbi/tests/main.nf.test.snap | 72 +++++++++++++++++++ modules/nf-core/lofreq/viterbi/tests/tags.yml | 2 + 6 files changed, 253 insertions(+) create mode 100644 modules/nf-core/lofreq/viterbi/environment.yml create mode 100644 modules/nf-core/lofreq/viterbi/main.nf create mode 100644 modules/nf-core/lofreq/viterbi/meta.yml create mode 100644 modules/nf-core/lofreq/viterbi/tests/main.nf.test create mode 100644 modules/nf-core/lofreq/viterbi/tests/main.nf.test.snap create mode 100644 modules/nf-core/lofreq/viterbi/tests/tags.yml diff --git a/modules/nf-core/lofreq/viterbi/environment.yml b/modules/nf-core/lofreq/viterbi/environment.yml new file mode 100644 index 00000000000..ff5f29fd342 --- /dev/null +++ b/modules/nf-core/lofreq/viterbi/environment.yml @@ -0,0 +1,9 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json +name: "lofreq_viterbi" +channels: + - conda-forge + - bioconda + - defaults +dependencies: + - bioconda::lofreq=2.1.5 diff --git a/modules/nf-core/lofreq/viterbi/main.nf b/modules/nf-core/lofreq/viterbi/main.nf new file mode 100644 index 00000000000..9f842762b92 --- /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--py38h588ecb2_4' : + 'biocontainers/lofreq:2.1.5--py38h588ecb2_4' }" + + 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..b871cd1f76b --- /dev/null +++ b/modules/nf-core/lofreq/viterbi/meta.yml @@ -0,0 +1,52 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json +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..4e1d85e2c8d --- /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,5a6dabbbf1d179b208c18650778fb936" + ] + ], + "1": [ + "versions.yml:md5,42875f148272abe6fcf2a179235e1ebc" + ], + "bam": [ + [ + { + "id": "test", + "single_end": false + }, + "test.bam:md5,5a6dabbbf1d179b208c18650778fb936" + ] + ], + "versions": [ + "versions.yml:md5,42875f148272abe6fcf2a179235e1ebc" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.04.1" + }, + "timestamp": "2024-03-18T13:31:41.331061677" + }, + "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/**" From f11d9dfc89e052139c61b7210a945971223724d1 Mon Sep 17 00:00:00 2001 From: "Lataretu, Marie" Date: Tue, 19 Mar 2024 11:18:29 +0100 Subject: [PATCH 3/4] removed yml schema comments --- modules/nf-core/lofreq/viterbi/environment.yml | 2 -- modules/nf-core/lofreq/viterbi/meta.yml | 2 -- 2 files changed, 4 deletions(-) diff --git a/modules/nf-core/lofreq/viterbi/environment.yml b/modules/nf-core/lofreq/viterbi/environment.yml index ff5f29fd342..6643c987fe5 100644 --- a/modules/nf-core/lofreq/viterbi/environment.yml +++ b/modules/nf-core/lofreq/viterbi/environment.yml @@ -1,5 +1,3 @@ ---- -# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json name: "lofreq_viterbi" channels: - conda-forge diff --git a/modules/nf-core/lofreq/viterbi/meta.yml b/modules/nf-core/lofreq/viterbi/meta.yml index b871cd1f76b..3ae9844b429 100644 --- a/modules/nf-core/lofreq/viterbi/meta.yml +++ b/modules/nf-core/lofreq/viterbi/meta.yml @@ -1,5 +1,3 @@ ---- -# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json name: "lofreq_viterbi" description: Lofreq subcommand to call low frequency variants from alignments when tumor-normal paired samples are available keywords: From a5df768717ffc5774481c9823108f997a1c1fe60 Mon Sep 17 00:00:00 2001 From: "Lataretu, Marie" Date: Tue, 19 Mar 2024 11:31:03 +0100 Subject: [PATCH 4/4] added samtools as conda dependency; chnaged container build version to py310h47ef89e_10; updated test snapshot --- modules/nf-core/lofreq/viterbi/environment.yml | 1 + modules/nf-core/lofreq/viterbi/main.nf | 4 ++-- modules/nf-core/lofreq/viterbi/tests/main.nf.test.snap | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/nf-core/lofreq/viterbi/environment.yml b/modules/nf-core/lofreq/viterbi/environment.yml index 6643c987fe5..d81bc229270 100644 --- a/modules/nf-core/lofreq/viterbi/environment.yml +++ b/modules/nf-core/lofreq/viterbi/environment.yml @@ -5,3 +5,4 @@ channels: - 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 index 9f842762b92..e16bd4a4cc3 100644 --- a/modules/nf-core/lofreq/viterbi/main.nf +++ b/modules/nf-core/lofreq/viterbi/main.nf @@ -4,8 +4,8 @@ process LOFREQ_VITERBI { conda "${moduleDir}/environment.yml" container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? - 'https://depot.galaxyproject.org/singularity/lofreq:2.1.5--py38h588ecb2_4' : - 'biocontainers/lofreq:2.1.5--py38h588ecb2_4' }" + 'https://depot.galaxyproject.org/singularity/lofreq:2.1.5--py310h47ef89e_10' : + 'biocontainers/lofreq:2.1.5--py310h47ef89e_10' }" input: tuple val(meta), path(bam) diff --git a/modules/nf-core/lofreq/viterbi/tests/main.nf.test.snap b/modules/nf-core/lofreq/viterbi/tests/main.nf.test.snap index 4e1d85e2c8d..051374e384d 100644 --- a/modules/nf-core/lofreq/viterbi/tests/main.nf.test.snap +++ b/modules/nf-core/lofreq/viterbi/tests/main.nf.test.snap @@ -8,7 +8,7 @@ "id": "test", "single_end": false }, - "test.bam:md5,5a6dabbbf1d179b208c18650778fb936" + "test.bam:md5,714e906a0c1a4e3d4c7e5ac25ea0edec" ] ], "1": [ @@ -20,7 +20,7 @@ "id": "test", "single_end": false }, - "test.bam:md5,5a6dabbbf1d179b208c18650778fb936" + "test.bam:md5,714e906a0c1a4e3d4c7e5ac25ea0edec" ] ], "versions": [ @@ -32,7 +32,7 @@ "nf-test": "0.8.4", "nextflow": "23.04.1" }, - "timestamp": "2024-03-18T13:31:41.331061677" + "timestamp": "2024-03-19T11:22:12.627457484" }, "sarscov2 - bam, fasta - stub": { "content": [