diff --git a/modules/nf-core/trgt/merge/main.nf b/modules/nf-core/trgt/merge/main.nf index 24c4d59a13ba..1b0e407049f5 100644 --- a/modules/nf-core/trgt/merge/main.nf +++ b/modules/nf-core/trgt/merge/main.nf @@ -14,6 +14,7 @@ process TRGT_MERGE { output: tuple val(meta), path("*.{vcf,vcf.gz,bcf,bcf.gz}"), emit: vcf + tuple val(meta), path("*.{tbi,csi}") , emit: index, optional: true tuple val("${task.process}"), val('trgt'), eval("trgt --version | sed 's/.* //g'"), emit: versions_trgt, topic: versions when: @@ -32,15 +33,11 @@ process TRGT_MERGE { """ trgt merge \\ + --threads ${task.cpus} \\ $args \\ $reference \\ $output \\ --vcf ${vcfs} - - cat <<-END_VERSIONS > versions.yml - "${task.process}": - trgt: \$(trgt --version |& sed '1!d ; s/trgt //') - END_VERSIONS """ stub: @@ -52,12 +49,10 @@ process TRGT_MERGE { args.contains("--output-type v") || args.contains("-Ov") ? "vcf" : "vcf" def create_cmd = extension.endsWith(".gz") ? "echo '' | gzip >" : "touch" + def index_type = extension == "vcf.gz" ? "tbi" : extension == "bcf.gz" ? "csi" : '' + def create_index = args.contains("--write-index") && extension.endsWith(".gz") ? "touch ${prefix}.${extension}.${index_type}" : '' """ $create_cmd ${prefix}.${extension} - - cat <<-END_VERSIONS > versions.yml - "${task.process}": - trgt: \$(trgt --version |& sed '1!d ; s/trgt //') - END_VERSIONS + $create_index """ } diff --git a/modules/nf-core/trgt/merge/meta.yml b/modules/nf-core/trgt/merge/meta.yml index 72ed57d50a93..c1bb9cec6b08 100644 --- a/modules/nf-core/trgt/merge/meta.yml +++ b/modules/nf-core/trgt/merge/meta.yml @@ -72,6 +72,17 @@ output: description: "Merged output file" pattern: "*.{vcf,vcf.gz,bcf,bcf.gz}" ontologies: [] + index: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + - "*.{tbi,csi}": + type: file + description: "Index of merged output file" + pattern: "*.{tbi,csi}" + ontologies: [] versions_trgt: - - ${task.process}: type: string diff --git a/modules/nf-core/trgt/merge/tests/main.nf.test b/modules/nf-core/trgt/merge/tests/main.nf.test index 5b3697a1e233..c9b5bf8b005e 100644 --- a/modules/nf-core/trgt/merge/tests/main.nf.test +++ b/modules/nf-core/trgt/merge/tests/main.nf.test @@ -95,6 +95,7 @@ nextflow_process { path(process.out.vcf.get(0).get(1)).vcf.variantsMD5, path(process.out.vcf.get(0).get(1)).vcf.summary, path(process.out.vcf.get(0).get(1)).vcf.sampleCount, + process.out.index, process.out.findAll { key, val -> key.startsWith("versions")} ).match() } ) @@ -120,6 +121,7 @@ nextflow_process { path(process.out.vcf.get(0).get(1)).vcf.variantsMD5, path(process.out.vcf.get(0).get(1)).vcf.summary, path(process.out.vcf.get(0).get(1)).vcf.sampleCount, + process.out.index, process.out.findAll { key, val -> key.startsWith("versions")} ).match() } ) @@ -132,6 +134,7 @@ nextflow_process { input[0] = BCFTOOLS_SORT.out.vcf .join(BCFTOOLS_SORT.out.tbi) .first() + .map { meta, vcf, tbi -> [ [ id : 'test' ], vcf, tbi ] } input[1] = GUNZIP.out.gunzip input[2] = SAMTOOLS_FAIDX.out.fai """ @@ -143,16 +146,17 @@ nextflow_process { ) } } - test("homo sapiens - 1 VCF - --force-single") { + test("homo sapiens - 1 VCF - --force-single --output-type z --write-index") { when { params { - trgt_merge_args = "--force-single" + trgt_merge_args = "--force-single --output-type z --write-index" } process { """ input[0] = BCFTOOLS_SORT.out.vcf .join(BCFTOOLS_SORT.out.tbi) .first() + .map { meta, vcf, tbi -> [ [ id : 'test' ], vcf, tbi ] } input[1] = GUNZIP.out.gunzip input[2] = SAMTOOLS_FAIDX.out.fai """ @@ -165,11 +169,87 @@ nextflow_process { path(process.out.vcf.get(0).get(1)).vcf.variantsMD5, path(process.out.vcf.get(0).get(1)).vcf.summary, path(process.out.vcf.get(0).get(1)).vcf.sampleCount, + process.out.index, process.out.findAll { key, val -> key.startsWith("versions")} ).match() } ) } } + test("homo sapiens - 1 VCF - --force-single --output-type b --write-index") { + when { + params { + trgt_merge_args = "--force-single --output-type b --write-index" + } + process { + """ + input[0] = BCFTOOLS_SORT.out.vcf + .join(BCFTOOLS_SORT.out.tbi) + .first() + .map { meta, vcf, tbi -> [ [ id : 'test' ], vcf, tbi ] } + input[1] = GUNZIP.out.gunzip + input[2] = SAMTOOLS_FAIDX.out.fai + """ + } + } + then { + assertAll( + { assert process.success }, + { assert snapshot( + file(process.out.vcf.get(0).get(1)).name, + process.out.index, + process.out.findAll { key, val -> key.startsWith("versions")} + ).match() } + ) + } + } + test("homo sapiens - 2 VCFs - tbi index - stub") { + options "-stub" + when { + params { + trgt_merge_args = "--output-type z --write-index" + } + process { + """ + input[0] = BCFTOOLS_SORT.out.vcf + .join(BCFTOOLS_SORT.out.tbi) + .map { meta, vcf, tbi -> [ [ id : 'test' ], vcf, tbi ] } + .groupTuple() + input[1] = [[],[]] + input[2] = [[],[]] + """ + } + } + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } + test("homo sapiens - 2 VCFs - csi index - stub") { + options "-stub" + when { + params { + trgt_merge_args = "--output-type b --write-index" + } + process { + """ + input[0] = BCFTOOLS_SORT.out.vcf + .join(BCFTOOLS_SORT.out.tbi) + .map { meta, vcf, tbi -> [ [ id : 'test' ], vcf, tbi ] } + .groupTuple() + input[1] = [[],[]] + input[2] = [[],[]] + """ + } + } + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } test("homo sapiens - 2 VCFs - stub") { options "-stub" when { @@ -187,10 +267,7 @@ nextflow_process { then { assertAll( { assert process.success }, - { assert snapshot( - process.out, - process.out.findAll { key, val -> key.startsWith("versions")} - ).match() } + { assert snapshot(process.out).match() } ) } } diff --git a/modules/nf-core/trgt/merge/tests/main.nf.test.snap b/modules/nf-core/trgt/merge/tests/main.nf.test.snap index 4168ceba4ce0..7c2cf06b934d 100644 --- a/modules/nf-core/trgt/merge/tests/main.nf.test.snap +++ b/modules/nf-core/trgt/merge/tests/main.nf.test.snap @@ -1,9 +1,39 @@ { + "homo sapiens - 1 VCF - --force-single --output-type b --write-index": { + "content": [ + "test.bcf.gz", + [ + [ + { + "id": "test" + }, + "test.bcf.gz.csi:md5,25edb1e7fca90690371848b7c01b9631" + ] + ], + { + "versions_trgt": [ + [ + "TRGT_MERGE", + "trgt", + "5.0.0-e9acee0" + ] + ] + } + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "25.04.6" + }, + "timestamp": "2025-12-10T15:42:21.803640957" + }, "homo sapiens - 2 VCFs - reference": { "content": [ "497b2c70fe41ad0c67c5fc4e1f281227", "VcfFile [chromosomes=[chr22], sampleCount=2, variantCount=1, phased=false, phasedAutodetect=false]", 2, + [ + + ], { "versions_trgt": [ [ @@ -18,13 +48,16 @@ "nf-test": "0.9.2", "nextflow": "25.04.6" }, - "timestamp": "2025-12-10T13:39:09.705242328" + "timestamp": "2025-12-10T15:36:01.2063008" }, "homo sapiens - 2 VCFs": { "content": [ "497b2c70fe41ad0c67c5fc4e1f281227", "VcfFile [chromosomes=[chr22], sampleCount=2, variantCount=1, phased=false, phasedAutodetect=false]", 2, + [ + + ], { "versions_trgt": [ [ @@ -39,9 +72,9 @@ "nf-test": "0.9.2", "nextflow": "25.04.6" }, - "timestamp": "2025-12-10T13:39:03.993142872" + "timestamp": "2025-12-10T15:35:55.048303885" }, - "homo sapiens - 2 VCFs - stub": { + "homo sapiens - 2 VCFs - tbi index - stub": { "content": [ { "0": [ @@ -49,22 +82,38 @@ { "id": "test" }, - "test.vcf:md5,d41d8cd98f00b204e9800998ecf8427e" + "test.vcf.gz:md5,68b329da9893e34099c7d8ad5cb9c940" ] ], "1": [ + [ + { + "id": "test" + }, + "test.vcf.gz.tbi:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "2": [ [ "TRGT_MERGE", "trgt", "5.0.0-e9acee0" ] ], + "index": [ + [ + { + "id": "test" + }, + "test.vcf.gz.tbi:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], "vcf": [ [ { "id": "test" }, - "test.vcf:md5,d41d8cd98f00b204e9800998ecf8427e" + "test.vcf.gz:md5,68b329da9893e34099c7d8ad5cb9c940" ] ], "versions_trgt": [ @@ -74,8 +123,46 @@ "5.0.0-e9acee0" ] ] - }, + } + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "25.04.6" + }, + "timestamp": "2025-12-10T15:36:25.238838671" + }, + "homo sapiens - 2 VCFs - stub": { + "content": [ { + "0": [ + [ + { + "id": "test" + }, + "test.vcf:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + + ], + "2": [ + [ + "TRGT_MERGE", + "trgt", + "5.0.0-e9acee0" + ] + ], + "index": [ + + ], + "vcf": [ + [ + { + "id": "test" + }, + "test.vcf:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], "versions_trgt": [ [ "TRGT_MERGE", @@ -89,13 +176,21 @@ "nf-test": "0.9.2", "nextflow": "25.04.6" }, - "timestamp": "2025-12-10T13:39:26.797540928" + "timestamp": "2025-12-10T15:36:37.406628045" }, - "homo sapiens - 1 VCF - --force-single": { + "homo sapiens - 1 VCF - --force-single --output-type z --write-index": { "content": [ "bad30e1ef353973510fcf4125d127a13", "VcfFile [chromosomes=[chr22], sampleCount=1, variantCount=1, phased=false, phasedAutodetect=false]", 1, + [ + [ + { + "id": "test" + }, + "test.vcf.gz.tbi:md5,bd5b91195c6b4b92b1727a170a2656e4" + ] + ], { "versions_trgt": [ [ @@ -110,6 +205,63 @@ "nf-test": "0.9.2", "nextflow": "25.04.6" }, - "timestamp": "2025-12-10T13:39:21.394392963" + "timestamp": "2025-12-10T15:42:15.567594151" + }, + "homo sapiens - 2 VCFs - csi index - stub": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test.bcf.gz:md5,68b329da9893e34099c7d8ad5cb9c940" + ] + ], + "1": [ + [ + { + "id": "test" + }, + "test.bcf.gz.csi:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "2": [ + [ + "TRGT_MERGE", + "trgt", + "5.0.0-e9acee0" + ] + ], + "index": [ + [ + { + "id": "test" + }, + "test.bcf.gz.csi:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "vcf": [ + [ + { + "id": "test" + }, + "test.bcf.gz:md5,68b329da9893e34099c7d8ad5cb9c940" + ] + ], + "versions_trgt": [ + [ + "TRGT_MERGE", + "trgt", + "5.0.0-e9acee0" + ] + ] + } + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "25.04.6" + }, + "timestamp": "2025-12-10T15:36:31.142452836" } } \ No newline at end of file