diff --git a/CHANGELOG.md b/CHANGELOG.md index 23f93f12..4adec731 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [#248](https://github.com/nf-core/phaseimpute/pull/248) - Add chromosomes concatenation to `BAM_GL_BCFTOOLS` - [#259](https://github.com/nf-core/phaseimpute/pull/259) - Add `publish_all` arguments to all workflow level nf-test. - [#272](https://github.com/nf-core/phaseimpute/pull/272) - Add genetic map detection and convertion for all phasing and imputation tools. Update usage. +- [#](https://github.com/nf-core/phaseimpute/pull/) - Add `chunk_version` parameter to control which Glimpse version to use to chunk. ### `Changed` diff --git a/conf/test_full.config b/conf/test_full.config index 00ab556d..62455864 100644 --- a/conf/test_full.config +++ b/conf/test_full.config @@ -33,6 +33,7 @@ params { normalize = true compute_freq = false phase = false + chunk_version = "V2" // Validation optional args min_val_gl = 0 diff --git a/main.nf b/main.nf index 99ea537d..4a3228a7 100644 --- a/main.nf +++ b/main.nf @@ -60,7 +60,7 @@ workflow NFCORE_PHASEIMPUTE { rename_chr // parameter: rename chromosome prefix max_chr_names // parameter: max number of chr to show in message params_simulate // map: parameters use for simulation step [depth: float, genotype: path] - params_panelprep // map: parameters use for panelprep step [normalize: boolean, remove_samples: string, compute_freq: boolean, phase: boolean, chunk_model: string ] + params_panelprep // map: parameters use for panelprep step [normalize: boolean, remove_samples: string, compute_freq: boolean, phase: boolean, chunk_model: string, chunk_version: string ] params_impute // map: parameters use for imputation step [batch_size: integer, k_val: integer, n_gen: integer, buffer: integer] params_validate // map: parameters use for validation step [bins: string, min_val_gl: float, min_val_dp: integer] params_multiqc // map: parameters use for multiqc report [config: path, logo: path, methods_description: string] @@ -166,7 +166,8 @@ workflow { remove_samples: params.remove_samples, compute_freq : params.compute_freq, phase : params.phase, - chunk_model : params.chunk_model + chunk_model : params.chunk_model, + chunk_version : params.chunk_version ] def params_impute = [ diff --git a/nextflow.config b/nextflow.config index af23ed99..5d00fe2f 100644 --- a/nextflow.config +++ b/nextflow.config @@ -25,6 +25,7 @@ params { compute_freq = false remove_samples = null chunk_model = 'sequential' + chunk_version = 'V1' // ChrCheck parameters rename_chr = false diff --git a/nextflow_schema.json b/nextflow_schema.json index cee82d7c..a7b661b7 100644 --- a/nextflow_schema.json +++ b/nextflow_schema.json @@ -144,6 +144,13 @@ "enum": ["recursive", "sequential"], "default": "sequential", "hidden": true + }, + "chunk_version": { + "type": "string", + "description": "Glimpse version to use for chunking", + "enum": ["V1", "V2"], + "default": "V1", + "hidden": true } } }, diff --git a/subworkflows/local/vcf_chunk_glimpse/main.nf b/subworkflows/local/vcf_chunk_glimpse/main.nf index d2bbffaa..3bd09a9e 100644 --- a/subworkflows/local/vcf_chunk_glimpse/main.nf +++ b/subworkflows/local/vcf_chunk_glimpse/main.nf @@ -6,7 +6,8 @@ workflow VCF_CHUNK_GLIMPSE { take: ch_reference // channel (mandatory): [ [panel_id, chr], vcf, csi ] ch_map // channel (optional) : [ [panel_id, chr], map ] - chunk_model // channel : model + chunk_model // value : model + chunk_version // value : glimpse version to use main: @@ -14,44 +15,21 @@ workflow VCF_CHUNK_GLIMPSE { ch_vcf_csi_chr = ch_reference .map{metaPC, vcf, csi -> [metaPC, vcf, csi, metaPC.chr]} - // Make chunks with Glimpse1 - GLIMPSE_CHUNK(ch_vcf_csi_chr) - - // Rearrange chunks into channel for QUILT - ch_chunks_quilt = GLIMPSE_CHUNK.out.chunk_chr - .splitText() - .map { metaPC, line -> - def fields = line.split("\t") - def startEnd = fields[2].split(':')[1].split('-') - [metaPC, metaPC.chr, startEnd[0], startEnd[1]] - } - - // Rearrange chunks into channel for GLIMPSE1 and GLIMPSE2 - ch_chunks_glimpse1 = GLIMPSE_CHUNK.out.chunk_chr - .splitCsv( - header: ['ID', 'Chr', 'RegionIn', 'RegionOut', 'Size1', 'Size2'], - sep: "\t", skip: 0 - ) - .map { metaPC, it -> [metaPC, it["RegionIn"], it["RegionOut"]]} - - ch_input_glimpse2 = ch_vcf_csi_chr - .combine(ch_map, by:0) - - GLIMPSE2_CHUNK(ch_input_glimpse2, chunk_model) - - // Rearrange channels - ch_chunks_glimpse2 = GLIMPSE2_CHUNK.out.chunk_chr - .splitCsv( - header: [ - 'ID', 'Chr', 'RegionBuf', 'RegionCnk', 'WindowCm', - 'WindowMb', 'NbTotVariants', 'NbComVariants' - ], sep: "\t", skip: 0 - ) - .map { metaPC, it -> [metaPC, it["RegionBuf"], it["RegionCnk"]]} + if (chunk_version == "V1") { + // Make chunks with Glimpse1 + GLIMPSE_CHUNK(ch_vcf_csi_chr) + + ch_chunks = GLIMPSE_CHUNK.out.chunk_chr + } else if (chunk_version == "V2") { + ch_input_glimpse2 = ch_vcf_csi_chr + .combine(ch_map, by:0) + + GLIMPSE2_CHUNK(ch_input_glimpse2, chunk_model) + ch_chunks = GLIMPSE2_CHUNK.out.chunk_chr + } else { + error ("Parameter chunk_version should be V1 or V2, found: ${chunk_version}.") + } emit: - chunks = GLIMPSE_CHUNK.out.chunk_chr // channel: [ [panel_id, chr], txt ] - chunks_quilt = ch_chunks_quilt // channel: [ [panel_id, chr], chr, start, end ] - chunks_glimpse1 = ch_chunks_glimpse1 // channel: [ [panel_id, chr], chr, region1, region2 ] - chunks_glimpse2 = ch_chunks_glimpse2 // channel: [ [panel_id, chr], chr, region1, region2 ] + chunks = ch_chunks // channel: [ [panel_id, chr], txt ] } diff --git a/subworkflows/local/vcf_chunk_glimpse/meta.yml b/subworkflows/local/vcf_chunk_glimpse/meta.yml index 57282572..4b6349cb 100644 --- a/subworkflows/local/vcf_chunk_glimpse/meta.yml +++ b/subworkflows/local/vcf_chunk_glimpse/meta.yml @@ -43,6 +43,12 @@ input: - recursive - sequential - uniform-number-variants + - chunk_version: + description: Glimpse version to chunk + type: string + enum: + - V1 + - V2 output: - chunks: description: Channel with chunks files diff --git a/subworkflows/local/vcf_chunk_glimpse/tests/main.nf.test b/subworkflows/local/vcf_chunk_glimpse/tests/main.nf.test index e654a8e7..4f895bfc 100644 --- a/subworkflows/local/vcf_chunk_glimpse/tests/main.nf.test +++ b/subworkflows/local/vcf_chunk_glimpse/tests/main.nf.test @@ -17,7 +17,7 @@ nextflow_workflow { tag "glimpse2" tag "glimpse2/chunk" - test("Chunks with Map") { + test("Chunks with Map - V1") { when { workflow { """ @@ -36,14 +36,15 @@ nextflow_workflow { input[1] = channel.of( [ [panel_id: "1000GP", chr: "chr22"], - file(params.pipelines_testdata_base_path + "hum_data/reference_genome/GRCh38_chr22.glimpse.map", checkIfExist:true) + file(params.modules_testdata_base_path + "genomics/homo_sapiens/genome/genetic_map/genome.GRCh38.chr22.glimpse.map", checkIfExist:true) ], [ [panel_id: "1000GP", chr: "chr21"], - file(params.pipelines_testdata_base_path + "hum_data/reference_genome/GRCh38_chr21.glimpse.map", checkIfExist:true) + file(params.modules_testdata_base_path + "genomics/homo_sapiens/genome/genetic_map/genome.GRCh38.chr21.glimpse.map", checkIfExist:true) ] ) input[2] = "recursive" + input[3] = "V1" """ } } @@ -52,7 +53,7 @@ nextflow_workflow { assertAll( { assert workflow.success }, { assert snapshot( - workflow.out, + workflow.out.chunks, workflow.out.chunks.collect{ path(it[1]).readLines() } @@ -62,7 +63,53 @@ nextflow_workflow { } } - test("Chunks without Map") { + test("Chunks with Map - V2") { + when { + workflow { + """ + input[0] = channel.of( + [ + [panel_id: "1000GP", chr: "chr22"], + file(params.pipelines_testdata_base_path + "hum_data/panel/chr22/1000GP.chr22.s.norel.vcf.gz", checkIfExist:true), + file(params.pipelines_testdata_base_path + "hum_data/panel/chr22/1000GP.chr22.s.norel.vcf.gz.csi", checkIfExist:true), + ], + [ + [panel_id: "1000GP", chr: "chr21"], + file(params.pipelines_testdata_base_path + "hum_data/panel/chr21/1000GP.chr21.s.norel.vcf.gz", checkIfExist:true), + file(params.pipelines_testdata_base_path + "hum_data/panel/chr21/1000GP.chr21.s.norel.vcf.gz.csi", checkIfExist:true), + ] + ) + input[1] = channel.of( + [ + [panel_id: "1000GP", chr: "chr22"], + file(params.modules_testdata_base_path + "genomics/homo_sapiens/genome/genetic_map/genome.GRCh38.chr22.glimpse.map", checkIfExist:true) + ], + [ + [panel_id: "1000GP", chr: "chr21"], + file(params.modules_testdata_base_path + "genomics/homo_sapiens/genome/genetic_map/genome.GRCh38.chr21.glimpse.map", checkIfExist:true) + ] + ) + input[2] = "recursive" + input[3] = "V2" + """ + } + } + + then { + assertAll( + { assert workflow.success }, + { assert snapshot( + workflow.out.chunks, + workflow.out.chunks.collect{ + path(it[1]).readLines() + } + ).match() + } + ) + } + } + + test("Chunks without Map - V1") { when { workflow { """ @@ -83,6 +130,7 @@ nextflow_workflow { [[panel_id: "1000GP", chr: "chr21"], []] ) input[2] = "recursive" + input[3] = "V1" """ } } @@ -91,7 +139,7 @@ nextflow_workflow { assertAll( { assert workflow.success }, { assert snapshot( - workflow.out, + workflow.out.chunks, workflow.out.chunks.collect{ path(it[1]).readLines() } @@ -101,7 +149,7 @@ nextflow_workflow { } } - test("Chunks with sequential model") { + test("Chunks with sequential model - V2") { when { workflow { """ @@ -122,6 +170,7 @@ nextflow_workflow { [[panel_id: "1000GP", chr: "chr21"], []] ) input[2] = "sequential" + input[3] = "V2" """ } } @@ -130,7 +179,7 @@ nextflow_workflow { assertAll( { assert workflow.success }, { assert snapshot( - workflow.out, + workflow.out.chunks, workflow.out.chunks.collect{ path(it[1]).readLines() } diff --git a/subworkflows/local/vcf_chunk_glimpse/tests/main.nf.test.snap b/subworkflows/local/vcf_chunk_glimpse/tests/main.nf.test.snap index 660098eb..d7913e06 100644 --- a/subworkflows/local/vcf_chunk_glimpse/tests/main.nf.test.snap +++ b/subworkflows/local/vcf_chunk_glimpse/tests/main.nf.test.snap @@ -1,252 +1,22 @@ { - "Chunks without Map": { + "Chunks without Map - V1": { "content": [ - { - "0": [ - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "1000GP_chr21.txt:md5,64ca4a1655363e4a4e558836e5ac12f9" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "1000GP_chr22.txt:md5,3344e171251722cf58ae31136da223ac" - ] - ], - "1": [ - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21", - "16570070", - "16595525" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21", - "16585483", - "16609998" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22", - "16570065", - "16597215" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22", - "16587172", - "16609999" - ] - ], - "2": [ - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21:16570070-16595525", - "chr21:16570070-16590513" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21:16585483-16609998", - "chr21:16590521-16609998" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22:16570065-16597215", - "chr22:16570065-16592216" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22:16587172-16609999", - "chr22:16592229-16609999" - ] - ], - "3": [ - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21:16570070-16609998", - "chr21:16570070-16590517" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21:16570070-16609998", - "chr21:16590518-16609998" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22:16570065-16609999", - "chr22:16570065-16592222" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22:16570065-16609999", - "chr22:16592223-16609999" - ] - ], - "chunks": [ - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "1000GP_chr21.txt:md5,64ca4a1655363e4a4e558836e5ac12f9" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "1000GP_chr22.txt:md5,3344e171251722cf58ae31136da223ac" - ] - ], - "chunks_glimpse1": [ - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21:16570070-16595525", - "chr21:16570070-16590513" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21:16585483-16609998", - "chr21:16590521-16609998" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22:16570065-16597215", - "chr22:16570065-16592216" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22:16587172-16609999", - "chr22:16592229-16609999" - ] - ], - "chunks_glimpse2": [ - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21:16570070-16609998", - "chr21:16570070-16590517" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21:16570070-16609998", - "chr21:16590518-16609998" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22:16570065-16609999", - "chr22:16570065-16592222" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22:16570065-16609999", - "chr22:16592223-16609999" - ] + [ + [ + { + "panel_id": "1000GP", + "chr": "chr21" + }, + "1000GP_chr21.txt:md5,64ca4a1655363e4a4e558836e5ac12f9" ], - "chunks_quilt": [ - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21", - "16570070", - "16595525" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21", - "16585483", - "16609998" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22", - "16570065", - "16597215" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22", - "16587172", - "16609999" - ] + [ + { + "panel_id": "1000GP", + "chr": "chr22" + }, + "1000GP_chr22.txt:md5,3344e171251722cf58ae31136da223ac" ] - }, + ], [ [ "0\tchr21\tchr21:16570070-16595525\tchr21:16570070-16590513\t20444\t419", @@ -258,260 +28,65 @@ ] ] ], - "timestamp": "2026-03-03T11:23:28.044105102", + "timestamp": "2026-09-01T18:58:22.306561207", "meta": { - "nf-test": "0.9.4", - "nextflow": "25.10.4" + "nf-test": "0.9.5", + "nextflow": "26.04.3" } }, - "Chunks with Map": { + "Chunks with Map - V2": { "content": [ - { - "0": [ - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "1000GP_chr21.txt:md5,64ca4a1655363e4a4e558836e5ac12f9" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "1000GP_chr22.txt:md5,3344e171251722cf58ae31136da223ac" - ] - ], - "1": [ - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21", - "16570070", - "16595525" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21", - "16585483", - "16609998" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22", - "16570065", - "16597215" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22", - "16587172", - "16609999" - ] - ], - "2": [ - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21:16570070-16595525", - "chr21:16570070-16590513" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21:16585483-16609998", - "chr21:16590521-16609998" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22:16570065-16597215", - "chr22:16570065-16592216" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22:16587172-16609999", - "chr22:16592229-16609999" - ] - ], - "3": [ - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21:16570070-16609998", - "chr21:16570070-16590517" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21:16570070-16609998", - "chr21:16590518-16609998" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22:16570065-16609999", - "chr22:16570065-16592222" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22:16570065-16609999", - "chr22:16592223-16609999" - ] - ], - "chunks": [ - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "1000GP_chr21.txt:md5,64ca4a1655363e4a4e558836e5ac12f9" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "1000GP_chr22.txt:md5,3344e171251722cf58ae31136da223ac" - ] + [ + [ + { + "panel_id": "1000GP", + "chr": "chr21" + }, + "1000GP_chr21.txt:md5,9f516b111710d22969aab9ad46850fdf" ], - "chunks_glimpse1": [ - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21:16570070-16595525", - "chr21:16570070-16590513" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21:16585483-16609998", - "chr21:16590521-16609998" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22:16570065-16597215", - "chr22:16570065-16592216" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22:16587172-16609999", - "chr22:16592229-16609999" - ] + [ + { + "panel_id": "1000GP", + "chr": "chr22" + }, + "1000GP_chr22.txt:md5,3bfef0fe24564dd3f759ee390345970a" + ] + ], + [ + [ + "0\tchr21\tchr21:16570070-16609998\tchr21:16570070-16590517\t0.0566807\t20443\t419\t201", + "1\tchr21\tchr21:16570070-16609998\tchr21:16590518-16609998\t0.0107975\t19477\t417\t220" ], - "chunks_glimpse2": [ - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21:16570070-16609998", - "chr21:16570070-16590517" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21:16570070-16609998", - "chr21:16590518-16609998" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22:16570065-16609999", - "chr22:16570065-16592222" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22:16570065-16609999", - "chr22:16592223-16609999" - ] + [ + "0\tchr22\tchr22:16570065-16609999\tchr22:16570065-16592222\t0.0598867\t22151\t452\t218", + "1\tchr22\tchr22:16570065-16609999\tchr22:16592223-16609999\t0.0331761\t17770\t451\t200" + ] + ] + ], + "timestamp": "2026-09-01T18:58:14.220996698", + "meta": { + "nf-test": "0.9.5", + "nextflow": "26.04.3" + } + }, + "Chunks with Map - V1": { + "content": [ + [ + [ + { + "panel_id": "1000GP", + "chr": "chr21" + }, + "1000GP_chr21.txt:md5,64ca4a1655363e4a4e558836e5ac12f9" ], - "chunks_quilt": [ - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21", - "16570070", - "16595525" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21", - "16585483", - "16609998" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22", - "16570065", - "16597215" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22", - "16587172", - "16609999" - ] + [ + { + "panel_id": "1000GP", + "chr": "chr22" + }, + "1000GP_chr22.txt:md5,3344e171251722cf58ae31136da223ac" ] - }, + ], [ [ "0\tchr21\tchr21:16570070-16595525\tchr21:16570070-16590513\t20444\t419", @@ -523,275 +98,45 @@ ] ] ], - "timestamp": "2026-03-03T11:23:15.791547471", + "timestamp": "2026-09-01T18:58:04.139816463", "meta": { - "nf-test": "0.9.4", - "nextflow": "25.10.4" + "nf-test": "0.9.5", + "nextflow": "26.04.3" } }, - "Chunks with sequential model": { + "Chunks with sequential model - V2": { "content": [ - { - "0": [ - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "1000GP_chr21.txt:md5,64ca4a1655363e4a4e558836e5ac12f9" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "1000GP_chr22.txt:md5,3344e171251722cf58ae31136da223ac" - ] - ], - "1": [ - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21", - "16570070", - "16595525" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21", - "16585483", - "16609998" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22", - "16570065", - "16597215" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22", - "16587172", - "16609999" - ] - ], - "2": [ - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21:16570070-16595525", - "chr21:16570070-16590513" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21:16585483-16609998", - "chr21:16590521-16609998" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22:16570065-16597215", - "chr22:16570065-16592216" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22:16587172-16609999", - "chr22:16592229-16609999" - ] - ], - "3": [ - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21:1-16609998", - "chr21:1-16590145" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21:16570070-1248956422", - "chr21:16590146-1248956422" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22:1-16609999", - "chr22:1-16590520" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22:16570065-1248956422", - "chr22:16590521-1248956422" - ] - ], - "chunks": [ - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "1000GP_chr21.txt:md5,64ca4a1655363e4a4e558836e5ac12f9" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "1000GP_chr22.txt:md5,3344e171251722cf58ae31136da223ac" - ] - ], - "chunks_glimpse1": [ - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21:16570070-16595525", - "chr21:16570070-16590513" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21:16585483-16609998", - "chr21:16590521-16609998" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22:16570065-16597215", - "chr22:16570065-16592216" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22:16587172-16609999", - "chr22:16592229-16609999" - ] - ], - "chunks_glimpse2": [ - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21:1-16609998", - "chr21:1-16590145" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21:16570070-1248956422", - "chr21:16590146-1248956422" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22:1-16609999", - "chr22:1-16590520" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22:16570065-1248956422", - "chr22:16590521-1248956422" - ] + [ + [ + { + "panel_id": "1000GP", + "chr": "chr21" + }, + "1000GP_chr21.txt:md5,e6156c3f8f0273b4d5c49784300ecc86" ], - "chunks_quilt": [ - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21", - "16570070", - "16595525" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr21" - }, - "chr21", - "16585483", - "16609998" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22", - "16570065", - "16597215" - ], - [ - { - "panel_id": "1000GP", - "chr": "chr22" - }, - "chr22", - "16587172", - "16609999" - ] + [ + { + "panel_id": "1000GP", + "chr": "chr22" + }, + "1000GP_chr22.txt:md5,4714831df331b665e634eb1a86a84156" ] - }, + ], [ [ - "0\tchr21\tchr21:16570070-16595525\tchr21:16570070-16590513\t20444\t419", - "1\tchr21\tchr21:16585483-16609998\tchr21:16590521-16609998\t19478\t417" + "0\tchr21\tchr21:1-16609998\tchr21:1-16590145\t0.0199917\t19992\t414\t201", + "1\tchr21\tchr21:16570070-1248956422\tchr21:16590146-1248956422\t0.019769\t19769\t422\t221" ], [ - "0\tchr22\tchr22:16570065-16597215\tchr22:16570065-16592216\t22152\t452", - "1\tchr22\tchr22:16587172-16609999\tchr22:16592229-16609999\t17771\t451" + "0\tchr22\tchr22:1-16609999\tchr22:1-16590520\t0.0204135\t20413\t410\t201", + "1\tchr22\tchr22:16570065-1248956422\tchr22:16590521-1248956422\t0.019437\t19437\t493\t219" ] ] ], - "timestamp": "2026-03-03T11:23:40.295298786", + "timestamp": "2026-09-01T18:58:30.252352768", "meta": { - "nf-test": "0.9.4", - "nextflow": "25.10.4" + "nf-test": "0.9.5", + "nextflow": "26.04.3" } } } \ No newline at end of file diff --git a/subworkflows/local/vcf_chunk_glimpse/tests/nextflow.config b/subworkflows/local/vcf_chunk_glimpse/tests/nextflow.config index 7191780d..43696b73 100644 --- a/subworkflows/local/vcf_chunk_glimpse/tests/nextflow.config +++ b/subworkflows/local/vcf_chunk_glimpse/tests/nextflow.config @@ -1,9 +1,4 @@ process { - resourceLimits = [ - memory : "2.GB", - cpus : 2, - time : "1h" - ] withName: GLIMPSE2_CHUNK { ext.args = ["--window-mb 0.01", "--window-cm 0.01", "--window-count 200", "--buffer-mb 0.005", "--buffer-cm 0.005", "--buffer-count 30"].join(' ') ext.prefix = { "${meta.panel_id}_${meta.chr}" } diff --git a/tests/config/test_data.config b/tests/config/test_data.config index d514c9c9..7e4f0887 100644 --- a/tests/config/test_data.config +++ b/tests/config/test_data.config @@ -3,7 +3,8 @@ params { // Base directory for test data - test_data_base = "https://raw.githubusercontent.com/nf-core/test-datasets/modules" + test_data_base = "https://raw.githubusercontent.com/nf-core/test-datasets/modules" + modules_testdata_base_path = 'https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/' test_data { 'sarscov2' { diff --git a/tests/csv/map_glimpse.csv b/tests/csv/map_glimpse.csv index 830f4d20..e81e0e4d 100644 --- a/tests/csv/map_glimpse.csv +++ b/tests/csv/map_glimpse.csv @@ -1,3 +1,3 @@ chr,map -chr21,https://raw.githubusercontent.com/nf-core/test-datasets/phaseimpute/hum_data/reference_genome/GRCh38_chr21.glimpse.map -chr22,https://raw.githubusercontent.com/nf-core/test-datasets/phaseimpute/hum_data/reference_genome/GRCh38_chr22.glimpse.map +chr21,https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/homo_sapiens/genome/genetic_map/genome.GRCh38.chr21.plink.map +chr22,https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/homo_sapiens/genome/genetic_map/genome.GRCh38.chr22.plink.map diff --git a/tests/csv/map_plink.csv b/tests/csv/map_plink.csv index b8f8fb3c..e81e0e4d 100644 --- a/tests/csv/map_plink.csv +++ b/tests/csv/map_plink.csv @@ -1,3 +1,3 @@ chr,map -chr21,https://raw.githubusercontent.com/nf-core/test-datasets/phaseimpute/hum_data/reference_genome/GRCh38_chr21.plink.map -chr22,https://raw.githubusercontent.com/nf-core/test-datasets/phaseimpute/hum_data/reference_genome/GRCh38_chr22.plink.map +chr21,https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/homo_sapiens/genome/genetic_map/genome.GRCh38.chr21.plink.map +chr22,https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/homo_sapiens/genome/genetic_map/genome.GRCh38.chr22.plink.map diff --git a/tests/function.nf.test b/tests/function.nf.test index 801f435b..38a2c0ab 100644 --- a/tests/function.nf.test +++ b/tests/function.nf.test @@ -110,6 +110,62 @@ nextflow_function { } } + test("Prepare chunks channel Glimpse - input Glimpse V2 - with chunks") { + function "chunkPrepareChannel" + tag "chunkPrepareChannel" + when { + function { + """ + input[0] = channel.of([ + [id: "1000GP", chr: "chr21"], + file(params.pipelines_testdata_base_path + "hum_data/panel/chr21/1000GP.chr21_chunks_v2.txt", checkIfExist:true) + ]) + input[1] = channel.of([ + [chr: "chr21", region: "chr21:16570000-16610000"], + "chr21:16570000-16610000" + ]) + input[2] = "glimpse1" + """ + } + } + + then { + assertAll( + { assert function.success }, + { assert snapshot(function.result).match()} + ) + } + } + + test("Prepare chunks channel Glimpse - input wrong format") { + function "chunkPrepareChannel" + tag "chunkPrepareChannel" + when { + function { + """ + ch_chunks = channel.of([ + "0\tchr22\tchr22:16570065-16597215\tchr22:16570065-16592216\t22152\t452\textrafield", + "1\tchr22\tchr22:16587172-16609999\tchr22:16592229-16609999\t17771\t451\textrafield" + ]).collectFile(name: 'chunks.txt', newLine: true) + input[0] = channel.of([ + [id: "1000GP", chr: "chr21"] + ]).combine(ch_chunks) + input[1] = channel.of([ + [chr: "chr21", region: "chr21:16570000-16610000"], + "chr21:16570000-16610000" + ]) + input[2] = "glimpse1" + """ + } + } + + then { + assertAll( + { assert function.failed } + ) + } + } + test("Prepare chunks channel error tool") { function "chunkPrepareChannel" tag "chunkPrepareChannel" diff --git a/tests/function.nf.test.snap b/tests/function.nf.test.snap index 23448808..e7c56948 100644 --- a/tests/function.nf.test.snap +++ b/tests/function.nf.test.snap @@ -11,6 +11,18 @@ "nextflow": "25.10.0" } }, + "Prepare chunks channel Glimpse - input Glimpse V2 - with chunks": { + "content": [ + { + + } + ], + "timestamp": "2026-09-01T19:04:57.436505706", + "meta": { + "nf-test": "0.9.5", + "nextflow": "26.04.3" + } + }, "Prepare chunks channel Glimpse - no chunks": { "content": [ { diff --git a/tests/test_all.nf.test.snap b/tests/test_all.nf.test.snap index e6b4655c..0ca9515b 100644 --- a/tests/test_all.nf.test.snap +++ b/tests/test_all.nf.test.snap @@ -2,7 +2,7 @@ "Check test_all - no map - no chunks": { "content": [ { - "workflow size": 240, + "workflow size": 238, "versions": { "ADDCOLUMNS": { "gawk": "5.3.1" @@ -89,9 +89,6 @@ "GAWK_TRUTH": { "gawk": "5.3.1" }, - "GLIMPSE2_CHUNK": { - "glimpse2": "2.0.0" - }, "GLIMPSE2_CONCORDANCE": { "glimpse2": "2.0.0" }, @@ -431,9 +428,6 @@ "prep_panel/chunks/glimpse1", "prep_panel/chunks/glimpse1/1000GP_chr21_chunks_glimpse1.txt", "prep_panel/chunks/glimpse1/1000GP_chr22_chunks_glimpse1.txt", - "prep_panel/chunks/glimpse2", - "prep_panel/chunks/glimpse2/1000GP_chr21_chunks_glimpse2.txt", - "prep_panel/chunks/glimpse2/1000GP_chr22_chunks_glimpse2.txt", "prep_panel/concat", "prep_panel/concat/1000GP.panel.vcf.gz", "prep_panel/concat/1000GP.panel.vcf.gz.tbi", @@ -603,8 +597,6 @@ "samtools-coverage_Reads.txt:md5,b4d9f56aedae09971ff3353eea5a9451", "1000GP_chr21_chunks_glimpse1.txt:md5,64ca4a1655363e4a4e558836e5ac12f9", "1000GP_chr22_chunks_glimpse1.txt:md5,3344e171251722cf58ae31136da223ac", - "1000GP_chr21_chunks_glimpse2.txt:md5,834dea86a63b5a49d36f53c0ac7e01a2", - "1000GP_chr22_chunks_glimpse2.txt:md5,c363e235162ca0f7d22e5604c192e256", "1000GP_chr21.hap.gz:md5,64d7fdfc96ce79848cf9c3c220e6774f", "1000GP_chr21.legend.gz:md5,3f7edc4c153521a0871c9d51f7da2372", "1000GP_chr21.samples:md5,d8ca3e8336976001de8df6be7ae236cb", @@ -952,16 +944,16 @@ } } ], - "timestamp": "2026-06-21T19:28:15.252414691", + "timestamp": "2026-09-02T15:11:35.015117606", "meta": { "nf-test": "0.9.5", - "nextflow": "26.04.0" + "nextflow": "26.04.6" } }, "Check test_all - with map - no chunks": { "content": [ { - "workflow size": 242, + "workflow size": 240, "versions": { "ADDCOLUMNS": { "gawk": "5.3.1" @@ -1054,9 +1046,6 @@ "GAWK_TRUTH": { "gawk": "5.3.1" }, - "GLIMPSE2_CHUNK": { - "glimpse2": "2.0.0" - }, "GLIMPSE2_CONCORDANCE": { "glimpse2": "2.0.0" }, @@ -1405,9 +1394,6 @@ "prep_panel/chunks/glimpse1", "prep_panel/chunks/glimpse1/1000GP_chr21_chunks_glimpse1.txt", "prep_panel/chunks/glimpse1/1000GP_chr22_chunks_glimpse1.txt", - "prep_panel/chunks/glimpse2", - "prep_panel/chunks/glimpse2/1000GP_chr21_chunks_glimpse2.txt", - "prep_panel/chunks/glimpse2/1000GP_chr22_chunks_glimpse2.txt", "prep_panel/concat", "prep_panel/concat/1000GP.panel.vcf.gz", "prep_panel/concat/1000GP.panel.vcf.gz.tbi", @@ -1585,8 +1571,6 @@ "samtools-coverage_Reads.txt:md5,b4d9f56aedae09971ff3353eea5a9451", "1000GP_chr21_chunks_glimpse1.txt:md5,64ca4a1655363e4a4e558836e5ac12f9", "1000GP_chr22_chunks_glimpse1.txt:md5,3344e171251722cf58ae31136da223ac", - "1000GP_chr21_chunks_glimpse2.txt:md5,5d68b3816a4cf607be3728237d2cfa2e", - "1000GP_chr22_chunks_glimpse2.txt:md5,3bfef0fe24564dd3f759ee390345970a", "1000GP_chr21.hap.gz:md5,64d7fdfc96ce79848cf9c3c220e6774f", "1000GP_chr21.legend.gz:md5,3f7edc4c153521a0871c9d51f7da2372", "1000GP_chr21.samples:md5,d8ca3e8336976001de8df6be7ae236cb", @@ -1934,10 +1918,10 @@ } } ], - "timestamp": "2026-06-21T19:31:43.527166058", + "timestamp": "2026-09-02T15:09:59.329236171", "meta": { "nf-test": "0.9.5", - "nextflow": "26.04.0" + "nextflow": "26.04.6" } } } \ No newline at end of file diff --git a/tests/test_dog.nf.test.snap b/tests/test_dog.nf.test.snap index 00f2e7fe..00e888b7 100644 --- a/tests/test_dog.nf.test.snap +++ b/tests/test_dog.nf.test.snap @@ -2,7 +2,7 @@ "Check test_dog - no map - no chunk": { "content": [ { - "workflow size": 91, + "workflow size": 89, "versions": { "BAMCHREXTRACT": { "samtools": "1.23" @@ -53,9 +53,6 @@ "GAWK_POSFILE_IMPUTE": { "gawk": "5.3.1" }, - "GLIMPSE2_CHUNK": { - "glimpse2": "2.0.0" - }, "GLIMPSE2_LIGATE": { "glimpse2": "2.0.0" }, @@ -226,9 +223,6 @@ "prep_panel/chunks/glimpse1", "prep_panel/chunks/glimpse1/658Dog_chr21_chunks_glimpse1.txt", "prep_panel/chunks/glimpse1/658Dog_chr22_chunks_glimpse1.txt", - "prep_panel/chunks/glimpse2", - "prep_panel/chunks/glimpse2/658Dog_chr21_chunks_glimpse2.txt", - "prep_panel/chunks/glimpse2/658Dog_chr22_chunks_glimpse2.txt", "prep_panel/csv", "prep_panel/csv/chunks_glimpse1.csv", "prep_panel/csv/panel.csv", @@ -287,8 +281,6 @@ "multiqc_general_stats.txt:md5,308b31e233de70b3e1e7b9c093e58093", "658Dog_chr21_chunks_glimpse1.txt:md5,fc93d5f473c8bff30c1244c968be6b8c", "658Dog_chr22_chunks_glimpse1.txt:md5,846073f9a512a680f7e7155cc4ac1f70", - "658Dog_chr21_chunks_glimpse2.txt:md5,76a5a9b772ce2f8e6f5bef47743a24aa", - "658Dog_chr22_chunks_glimpse2.txt:md5,087f226af57448b5777a0fac6806a776", "658Dog_chr21.hap.gz:md5,0730a032b058730d6abdbf836bb57ba7", "658Dog_chr21.legend.gz:md5,3eaa371bdf51f74f9749fd35e9e834a6", "658Dog_chr21.samples:md5,92a2aa1d024ca2001cfec04671082eff", @@ -450,10 +442,10 @@ } } ], - "timestamp": "2026-06-21T18:08:14.707538039", + "timestamp": "2026-09-02T15:21:12.966406137", "meta": { "nf-test": "0.9.5", - "nextflow": "26.04.0" + "nextflow": "26.04.6" } } } \ No newline at end of file diff --git a/tests/test_panelprep.nf.test.snap b/tests/test_panelprep.nf.test.snap index da41889d..bf6dddf5 100644 --- a/tests/test_panelprep.nf.test.snap +++ b/tests/test_panelprep.nf.test.snap @@ -2,7 +2,7 @@ "Check test_panelprep - no map - no chunks": { "content": [ { - "workflow size": 34, + "workflow size": 32, "versions": { "BCFTOOLS_CONVERT": { "bcftools": "1.23.1" @@ -25,9 +25,6 @@ "GAWK": { "gawk": "5.3.1" }, - "GLIMPSE2_CHUNK": { - "glimpse2": "2.0.0" - }, "GLIMPSE_CHUNK": { "glimpse": "1.1.1" }, @@ -73,9 +70,6 @@ "prep_panel/chunks/glimpse1", "prep_panel/chunks/glimpse1/1000GP_chr21_chunks_glimpse1.txt", "prep_panel/chunks/glimpse1/1000GP_chr22_chunks_glimpse1.txt", - "prep_panel/chunks/glimpse2", - "prep_panel/chunks/glimpse2/1000GP_chr21_chunks_glimpse2.txt", - "prep_panel/chunks/glimpse2/1000GP_chr22_chunks_glimpse2.txt", "prep_panel/csv", "prep_panel/csv/chunks_glimpse1.csv", "prep_panel/csv/panel.csv", @@ -129,8 +123,6 @@ "multiqc_citations.txt:md5,4c806e63a283ec1b7e78cdae3a923d4f", "1000GP_chr21_chunks_glimpse1.txt:md5,64ca4a1655363e4a4e558836e5ac12f9", "1000GP_chr22_chunks_glimpse1.txt:md5,3344e171251722cf58ae31136da223ac", - "1000GP_chr21_chunks_glimpse2.txt:md5,834dea86a63b5a49d36f53c0ac7e01a2", - "1000GP_chr22_chunks_glimpse2.txt:md5,c363e235162ca0f7d22e5604c192e256", "1000GP_chr21.hap.gz:md5,d18ac86ed7080c6527aade3b6717ebb0", "1000GP_chr21.legend.gz:md5,3f7edc4c153521a0871c9d51f7da2372", "1000GP_chr21.samples:md5,ba53fdcb71cd6dbd218e0e932555086c", @@ -191,10 +183,10 @@ ] } ], - "timestamp": "2026-06-21T18:16:13.344773591", + "timestamp": "2026-09-02T15:28:40.592623143", "meta": { "nf-test": "0.9.5", - "nextflow": "26.04.0" + "nextflow": "26.04.6" } }, "Check test_panelprep - with map - with chunks": { diff --git a/workflows/phaseimpute/function.nf b/workflows/phaseimpute/function.nf index 4078957b..1717b4a2 100644 --- a/workflows/phaseimpute/function.nf +++ b/workflows/phaseimpute/function.nf @@ -12,27 +12,34 @@ def chunkPrepareChannel(ch_chunks, ch_region, tool) { empty: true return [metaPC, region] } + + def ch_chunks_in_out = channel.of() + + ch_chunks_in_out = ch_chunks_branched.txt.map { metaPC, txt -> [metaPC, file(txt)]} + .splitCsv(sep:"\t", skip:0) + .map{ meta, row -> + if (row.size() == 6 ) { + return [ meta, row[2], row[3] ] // header is 'ID', 'Chr', 'RegionIn', 'RegionOut', 'Size1', 'Size2' + } + if (row.size() == 8) { + return [ meta, row[3], row[2] ] // header is 'ID', 'Chr', 'RegionBuff', 'RegionCnk', 'WindowCm', 'WindowMb', 'NbTotVariants', 'NbComVariants' + } + error "Chunks csv should have either 6 columns (glimpse V1 format) or 8 columns (glimpse V2 format)" + } + if(tool == "glimpse1"){ - def ch_chunks_txt = ch_chunks_branched.txt.map { metaPC, txt -> [metaPC, file(txt)]} - .splitCsv(header: ['ID', 'Chr', 'RegionIn', 'RegionOut', 'Size1', 'Size2'], sep: "\t", skip: 0) - .map { meta, it -> [meta, it["RegionIn"], it["RegionOut"]]} def ch_chunks_region = ch_chunks_branched.empty.map{ metaPC, region -> [ metaPC, region, region ] } - return ch_chunks_txt.mix(ch_chunks_region) + return ch_chunks_in_out.mix(ch_chunks_region) } else if(tool == "quilt") { - def ch_chunks_txt = ch_chunks_branched.txt.map { metaC, txt -> [metaC, file(txt)]} - .splitCsv(header: ['ID', 'Chr', 'RegionIn', 'RegionOut', 'Size1', 'Size2'], sep: "\t", skip: 0) - .map { metaC, it -> - def startEnd = it["RegionIn"].split(':')[1].split('-') - [ metaC, metaC.chr, startEnd[0], startEnd[1] ] + return ch_chunks_in_out + .map{meta, region_in, _region_out -> [meta, region_in] } + .mix(ch_chunks_branched.empty) + .map { meta, it -> + def startEnd = it.split(':')[1].split('-') + [ meta, meta.chr, startEnd[0], startEnd[1] ] } - def ch_chunks_region = ch_chunks_branched.empty.map{ - metaPC, region -> - def startEnd = region.split(':')[1].split('-') - [ metaPC, metaPC.chr, startEnd[0], startEnd[1] ] - } - return ch_chunks_txt.mix(ch_chunks_region) } else { error "ERROR: Only 'glimpse1' and 'quilt' output format are supported. Got ${tool}" } diff --git a/workflows/phaseimpute/main.nf b/workflows/phaseimpute/main.nf index 7595a1be..76212102 100644 --- a/workflows/phaseimpute/main.nf +++ b/workflows/phaseimpute/main.nf @@ -251,7 +251,8 @@ workflow PHASEIMPUTE { VCF_CHUNK_GLIMPSE( VCF_NORMALIZE_BCFTOOLS.out.vcf_index, ch_map_glimpse, - params_panelprep["chunk_model"] + params_panelprep["chunk_model"], + params_panelprep["chunk_version"] ) ch_chunks = VCF_CHUNK_GLIMPSE.out.chunks