diff --git a/modules.json b/modules.json index 8e361457..dff640fa 100644 --- a/modules.json +++ b/modules.json @@ -12,13 +12,8 @@ }, "bcftools/index": { "branch": "master", - "git_sha": "911696ea0b62df80e900ef244d7867d177971f73", - "installed_by": [ - "multiple_impute_glimpse2", - "modules", - "vcf_impute_glimpse", - "vcf_phase_shapeit5" - ] + "git_sha": "44096c08ffdbc694f5f92ae174ea0f7ba0f37e09", + "installed_by": ["multiple_impute_glimpse2", "vcf_impute_glimpse", "vcf_phase_shapeit5"] }, "bcftools/norm": { "branch": "master", @@ -52,17 +47,17 @@ }, "glimpse/chunk": { "branch": "master", - "git_sha": "911696ea0b62df80e900ef244d7867d177971f73", - "installed_by": ["vcf_impute_glimpse", "modules"] + "git_sha": "3f5420aa22e00bd030a2556dfdffc9e164ec0ec5", + "installed_by": ["vcf_impute_glimpse"] }, "glimpse/ligate": { "branch": "master", - "git_sha": "36cfa4c2a7e538832c50f40cb16d159e84cd3305", + "git_sha": "3f5420aa22e00bd030a2556dfdffc9e164ec0ec5", "installed_by": ["vcf_impute_glimpse"] }, "glimpse/phase": { "branch": "master", - "git_sha": "36cfa4c2a7e538832c50f40cb16d159e84cd3305", + "git_sha": "3f5420aa22e00bd030a2556dfdffc9e164ec0ec5", "installed_by": ["vcf_impute_glimpse"] }, "glimpse2/chunk": { @@ -140,29 +135,29 @@ "git_sha": "dedc0e31087f3306101c38835d051bf49789445a", "installed_by": ["subworkflows"] }, - "vcf_impute_glimpse": { + "utils_nextflow_pipeline": { "branch": "master", - "git_sha": "74d79f1853c9ff2961e6061aad3c68d728d5c20d", + "git_sha": "5caf7640a9ef1d18d765d55339be751bb0969dfa", "installed_by": ["subworkflows"] }, - "vcf_phase_shapeit5": { + "utils_nfcore_pipeline": { "branch": "master", - "git_sha": "dedc0e31087f3306101c38835d051bf49789445a", + "git_sha": "5caf7640a9ef1d18d765d55339be751bb0969dfa", "installed_by": ["subworkflows"] }, - "utils_nextflow_pipeline": { + "utils_nfvalidation_plugin": { "branch": "master", "git_sha": "5caf7640a9ef1d18d765d55339be751bb0969dfa", "installed_by": ["subworkflows"] }, - "utils_nfcore_pipeline": { + "vcf_impute_glimpse": { "branch": "master", - "git_sha": "5caf7640a9ef1d18d765d55339be751bb0969dfa", + "git_sha": "8dab3bf2aaa912730419080e96d2a7d98911db48", "installed_by": ["subworkflows"] }, - "utils_nfvalidation_plugin": { + "vcf_phase_shapeit5": { "branch": "master", - "git_sha": "5caf7640a9ef1d18d765d55339be751bb0969dfa", + "git_sha": "dedc0e31087f3306101c38835d051bf49789445a", "installed_by": ["subworkflows"] } } diff --git a/modules/nf-core/bcftools/index/environment.yml b/modules/nf-core/bcftools/index/environment.yml new file mode 100644 index 00000000..bbee37ad --- /dev/null +++ b/modules/nf-core/bcftools/index/environment.yml @@ -0,0 +1,7 @@ +name: bcftools_index +channels: + - conda-forge + - bioconda + - defaults +dependencies: + - bioconda::bcftools=1.18 diff --git a/modules/nf-core/bcftools/index/main.nf b/modules/nf-core/bcftools/index/main.nf index 43360aab..4cd0dcbb 100644 --- a/modules/nf-core/bcftools/index/main.nf +++ b/modules/nf-core/bcftools/index/main.nf @@ -2,10 +2,10 @@ process BCFTOOLS_INDEX { tag "$meta.id" label 'process_low' - conda "bioconda::bcftools=1.17" + conda "${moduleDir}/environment.yml" container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? - 'https://depot.galaxyproject.org/singularity/bcftools:1.17--haef29d1_0': - 'biocontainers/bcftools:1.17--haef29d1_0' }" + 'https://depot.galaxyproject.org/singularity/bcftools:1.18--h8b25389_0': + 'biocontainers/bcftools:1.18--h8b25389_0' }" input: tuple val(meta), path(vcf) @@ -34,4 +34,18 @@ process BCFTOOLS_INDEX { bcftools: \$(bcftools --version 2>&1 | head -n1 | sed 's/^.*bcftools //; s/ .*\$//') END_VERSIONS """ + + stub: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + def extension = args.contains("--tsi") || args.contains("-t") ? "tbi" : + "csi" + """ + touch ${vcf}.${extension} + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + bcftools: \$(bcftools --version 2>&1 | head -n1 | sed 's/^.*bcftools //; s/ .*\$//') + END_VERSIONS + """ } diff --git a/modules/nf-core/bcftools/index/meta.yml b/modules/nf-core/bcftools/index/meta.yml index b883fa5f..fc340cbc 100644 --- a/modules/nf-core/bcftools/index/meta.yml +++ b/modules/nf-core/bcftools/index/meta.yml @@ -14,7 +14,6 @@ tools: tool_dev_url: https://github.com/samtools/bcftools doi: "10.1093/gigascience/giab008" licence: ["MIT", "GPL-3.0-or-later"] - input: - meta: type: map @@ -25,7 +24,6 @@ input: type: file description: VCF file (optionally GZIPPED) pattern: "*.{vcf,vcf.gz}" - output: - meta: type: map @@ -44,6 +42,7 @@ output: type: file description: Alternative VCF file index file for larger files (activated with -t parameter) pattern: "*.tbi" - authors: - "@jfy133" +maintainers: + - "@jfy133" diff --git a/modules/nf-core/glimpse/chunk/environment.yml b/modules/nf-core/glimpse/chunk/environment.yml new file mode 100644 index 00000000..8d71aa91 --- /dev/null +++ b/modules/nf-core/glimpse/chunk/environment.yml @@ -0,0 +1,7 @@ +name: glimpse_chunk +channels: + - conda-forge + - bioconda + - defaults +dependencies: + - bioconda::glimpse-bio=1.1.1 diff --git a/modules/nf-core/glimpse/chunk/main.nf b/modules/nf-core/glimpse/chunk/main.nf index f2ffed2f..94779846 100644 --- a/modules/nf-core/glimpse/chunk/main.nf +++ b/modules/nf-core/glimpse/chunk/main.nf @@ -2,7 +2,7 @@ process GLIMPSE_CHUNK { tag "$meta.id" label 'process_medium' - conda "bioconda::glimpse-bio=1.1.1" + conda "${moduleDir}/environment.yml" container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? 'https://depot.galaxyproject.org/singularity/glimpse-bio:1.1.1--h2ce4488_2': 'biocontainers/glimpse-bio:1.1.1--hce55b13_1' }" @@ -31,7 +31,19 @@ process GLIMPSE_CHUNK { cat <<-END_VERSIONS > versions.yml "${task.process}": - glimpse: "\$(GLIMPSE_phase --help | sed -nr '/Version/p' | grep -o -E '([0-9]+.){1,2}[0-9]')" + glimpse: "\$(GLIMPSE_chunk --help | sed -nr '/Version/p' | grep -o -E '([0-9]+.){1,2}[0-9]')" + END_VERSIONS + """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + def args = task.ext.args ?: "" + """ + touch ${prefix}.txt + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + glimpse: "\$(GLIMPSE_chunk --help | sed -nr '/Version/p' | grep -o -E '([0-9]+.){1,2}[0-9]')" END_VERSIONS """ } diff --git a/modules/nf-core/glimpse/chunk/meta.yml b/modules/nf-core/glimpse/chunk/meta.yml index 9ac840a6..65fa6218 100644 --- a/modules/nf-core/glimpse/chunk/meta.yml +++ b/modules/nf-core/glimpse/chunk/meta.yml @@ -12,21 +12,18 @@ tools: tool_dev_url: "https://github.com/odelaneau/GLIMPSE" doi: "10.1038/s41588-020-00756-0" licence: "['MIT']" - input: - meta: type: map description: | Groovy Map containing sample information e.g. [ id:'test', single_end:false ] - - input: type: file description: | Target dataset in VCF/BCF format defined at all variable positions. The file could possibly be without GT field (for efficiency reasons a file containing only the positions is recommended). pattern: "*.{vcf,bcf,vcf.gz,bcf.gz}" - - region: type: string description: | @@ -38,16 +35,15 @@ output: description: | Groovy Map containing sample information e.g. [ id:'test', single_end:false ] - - versions: type: file description: File containing software versions pattern: "versions.yml" - - txt: type: file description: Tab delimited output txt file containing buffer and imputation regions. pattern: "*.{txt}" - authors: - "@louislenezet" +maintainers: + - "@louislenezet" diff --git a/modules/nf-core/glimpse/chunk/tests/main.nf.test b/modules/nf-core/glimpse/chunk/tests/main.nf.test new file mode 100644 index 00000000..4c278af1 --- /dev/null +++ b/modules/nf-core/glimpse/chunk/tests/main.nf.test @@ -0,0 +1,36 @@ +nextflow_process { + + name "Test Process GLIMPSE_CHUNK" + script "../main.nf" + process "GLIMPSE_CHUNK" + tag "glimpse" + tag "glimpse/chunk" + tag "modules_nfcore" + tag "modules" + + test("Should run without failures") { + config "modules/nf-core/glimpse/chunk/tests/nextflow.config" + + when { + process { + """ + input[0] = [ + [ id:'input' ], // meta map + file(params.test_data['homo_sapiens']['genome']['mills_and_1000g_indels_21_vcf_gz'], checkIfExists: true), + file(params.test_data['homo_sapiens']['genome']['mills_and_1000g_indels_21_vcf_gz_tbi'], checkIfExists: true), + "chr21" + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + + } + +} diff --git a/modules/nf-core/glimpse/chunk/tests/main.nf.test.snap b/modules/nf-core/glimpse/chunk/tests/main.nf.test.snap new file mode 100644 index 00000000..0490a8e4 --- /dev/null +++ b/modules/nf-core/glimpse/chunk/tests/main.nf.test.snap @@ -0,0 +1,31 @@ +{ + "Should run without failures": { + "content": [ + { + "0": [ + [ + { + "id": "input" + }, + "input.txt:md5,9e5562b3f94857b8189b59849ce65cfb" + ] + ], + "1": [ + "versions.yml:md5,a523ef8d6391ddeff47bfd30b606d628" + ], + "chunk_chr": [ + [ + { + "id": "input" + }, + "input.txt:md5,9e5562b3f94857b8189b59849ce65cfb" + ] + ], + "versions": [ + "versions.yml:md5,a523ef8d6391ddeff47bfd30b606d628" + ] + } + ], + "timestamp": "2023-10-16T15:55:52.457257547" + } +} \ No newline at end of file diff --git a/modules/nf-core/glimpse/chunk/tests/nextflow.config b/modules/nf-core/glimpse/chunk/tests/nextflow.config new file mode 100644 index 00000000..c945152e --- /dev/null +++ b/modules/nf-core/glimpse/chunk/tests/nextflow.config @@ -0,0 +1,9 @@ +process { + withName: GLIMPSE_CHUNK { + ext.args = [ + "--window-size 2000000", + "--buffer-size 200000" + ].join(' ') + ext.prefix = { "${meta.id}" } + } +} \ No newline at end of file diff --git a/modules/nf-core/glimpse/chunk/tests/tags.yml b/modules/nf-core/glimpse/chunk/tests/tags.yml new file mode 100644 index 00000000..bd846dfd --- /dev/null +++ b/modules/nf-core/glimpse/chunk/tests/tags.yml @@ -0,0 +1,2 @@ +glimpse/chunk: + - modules/nf-core/glimpse/chunk/** diff --git a/modules/nf-core/glimpse/ligate/environment.yml b/modules/nf-core/glimpse/ligate/environment.yml new file mode 100644 index 00000000..0f9e9a33 --- /dev/null +++ b/modules/nf-core/glimpse/ligate/environment.yml @@ -0,0 +1,7 @@ +name: glimpse_ligate +channels: + - conda-forge + - bioconda + - defaults +dependencies: + - bioconda::glimpse-bio=1.1.1 diff --git a/modules/nf-core/glimpse/ligate/main.nf b/modules/nf-core/glimpse/ligate/main.nf index f9775bbf..65425fd5 100644 --- a/modules/nf-core/glimpse/ligate/main.nf +++ b/modules/nf-core/glimpse/ligate/main.nf @@ -2,7 +2,7 @@ process GLIMPSE_LIGATE { tag "$meta.id" label 'process_low' - conda "bioconda::glimpse-bio=1.1.1" + conda "${moduleDir}/environment.yml" container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? 'https://depot.galaxyproject.org/singularity/glimpse-bio:1.1.1--hce55b13_1': 'biocontainers/glimpse-bio:1.1.1--hce55b13_1' }" diff --git a/modules/nf-core/glimpse/ligate/meta.yml b/modules/nf-core/glimpse/ligate/meta.yml index 9a2a8daa..da6066ad 100644 --- a/modules/nf-core/glimpse/ligate/meta.yml +++ b/modules/nf-core/glimpse/ligate/meta.yml @@ -13,42 +13,37 @@ tools: tool_dev_url: "https://github.com/odelaneau/GLIMPSE" doi: "10.1038/s41588-020-00756-0" licence: "['MIT']" - input: - meta: type: map description: | Groovy Map containing sample information e.g. [ id:'test', single_end:false ] - - input_list: type: file description: VCF/BCF file containing genotype probabilities (GP field). pattern: "*.{vcf,bcf,vcf.gz,bcf.gz}" - - input_index: type: file description: Index file of the input VCF/BCF file containing genotype likelihoods. pattern: "*.{vcf.gz.csi,bcf.gz.csi}" - 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" - - merged_variants: type: file description: | Output VCF/BCF file for the merged regions. Phased information (HS field) is updated accordingly for the full region. pattern: "*.{vcf,bcf,vcf.gz,bcf.gz}" - authors: - "@louislenezet" +maintainers: + - "@louislenezet" diff --git a/modules/nf-core/glimpse/ligate/tests/main.nf.test b/modules/nf-core/glimpse/ligate/tests/main.nf.test new file mode 100644 index 00000000..e86ff231 --- /dev/null +++ b/modules/nf-core/glimpse/ligate/tests/main.nf.test @@ -0,0 +1,73 @@ +nextflow_process { + + name "Test Process GLIMPSE_LIGATE" + script "../main.nf" + process "GLIMPSE_LIGATE" + tag "glimpse" + tag "glimpse/ligate" + tag "modules_nfcore" + tag "modules" + + test("test_glimpse_ligate") { + setup { + run("GLIMPSE_PHASE") { + script "../../phase/main.nf" + process { + """ + ch_sample = Channel.of('NA12878 2').collectFile(name: 'sampleinfos.txt') + region = Channel.fromList([ + ["chr21:16600000-16750000","chr21:16650000-16700000"], + ["chr21:16650000-16800000","chr21:16700000-16750000"] + ]) + input_vcf = Channel.of([ + [ id:'input'], // meta map + file("https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/glimpse/NA12878.chr21.s.1x.vcf.gz", checkIfExists: true), + file("https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/glimpse/NA12878.chr21.s.1x.vcf.gz.csi", checkIfExists: true) + ]) + ref_panel = Channel.of([ + file("https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/glimpse/1000GP.chr21.noNA12878.s.bcf", checkIfExists: true), + file("https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/glimpse/1000GP.chr21.noNA12878.s.bcf.csi", checkIfExists: true) + ]) + ch_map = Channel.of([ + file("https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/glimpse/chr21.b38.gmap.gz", checkIfExists: true), + ]) + + input[0] = input_vcf + | combine(ch_sample) + | combine(region) + | combine(ref_panel) + | combine(ch_map) + """ + } + } + run("BCFTOOLS_INDEX") { + script "../../../bcftools/index/main.nf" + process { + """ + input[0] = GLIMPSE_PHASE.out.phased_variant + """ + } + } + } + + when { + process { + """ + input[0] = GLIMPSE_PHASE.out.phased_variant + | groupTuple() + | join (BCFTOOLS_INDEX.out.csi.groupTuple()) + """ + } + } + + then { + def lines = path(process.out.merged_variants.get(0).get(1)).linesGzip.last() + assertAll( + { assert process.success }, + { assert snapshot(process.out.versions).match("versions") }, + { assert snapshot(lines).match("ligate") } + ) + } + + } +} diff --git a/modules/nf-core/glimpse/ligate/tests/main.nf.test.snap b/modules/nf-core/glimpse/ligate/tests/main.nf.test.snap new file mode 100644 index 00000000..8eec1328 --- /dev/null +++ b/modules/nf-core/glimpse/ligate/tests/main.nf.test.snap @@ -0,0 +1,16 @@ +{ + "versions": { + "content": [ + [ + "versions.yml:md5,0cc9dfe9c9c1087666c418aa3379cf85" + ] + ], + "timestamp": "2023-10-17T11:56:25.087453677" + }, + "ligate": { + "content": [ + "chr21\t16799989\t21:16799989:T:C\tT\tC\t.\t.\tRAF=0.000468897;AF=0;INFO=1\tGT:DS:GP:HS\t0/0:0:1,0,0:0" + ], + "timestamp": "2023-10-17T11:56:25.116120487" + } +} \ No newline at end of file diff --git a/modules/nf-core/glimpse/ligate/tests/tags.yml b/modules/nf-core/glimpse/ligate/tests/tags.yml new file mode 100644 index 00000000..f15d8121 --- /dev/null +++ b/modules/nf-core/glimpse/ligate/tests/tags.yml @@ -0,0 +1,2 @@ +glimpse/ligate: + - modules/nf-core/glimpse/ligate/** diff --git a/modules/nf-core/glimpse/phase/environment.yml b/modules/nf-core/glimpse/phase/environment.yml new file mode 100644 index 00000000..fc79765a --- /dev/null +++ b/modules/nf-core/glimpse/phase/environment.yml @@ -0,0 +1,7 @@ +name: glimpse_phase +channels: + - conda-forge + - bioconda + - defaults +dependencies: + - bioconda::glimpse-bio=1.1.1 diff --git a/modules/nf-core/glimpse/phase/main.nf b/modules/nf-core/glimpse/phase/main.nf index e2c73ea2..a6f39d15 100644 --- a/modules/nf-core/glimpse/phase/main.nf +++ b/modules/nf-core/glimpse/phase/main.nf @@ -2,7 +2,7 @@ process GLIMPSE_PHASE { tag "$meta.id" label 'process_medium' - conda "bioconda::glimpse-bio=1.1.1" + conda "${moduleDir}/environment.yml" container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? 'https://depot.galaxyproject.org/singularity/glimpse-bio:1.1.1--h2ce4488_2': 'biocontainers/glimpse-bio:1.1.1--hce55b13_1' }" diff --git a/modules/nf-core/glimpse/phase/meta.yml b/modules/nf-core/glimpse/phase/meta.yml index 47da4de6..696616d3 100644 --- a/modules/nf-core/glimpse/phase/meta.yml +++ b/modules/nf-core/glimpse/phase/meta.yml @@ -5,7 +5,6 @@ keywords: - imputation - low-coverage - glimpse - tools: - "glimpse": description: "GLIMPSE is a phasing and imputation method for large-scale low-coverage sequencing studies." @@ -14,24 +13,20 @@ tools: tool_dev_url: "https://github.com/odelaneau/GLIMPSE" doi: "10.1038/s41588-020-00756-0" licence: "['MIT']" - input: - meta: type: map description: | Groovy Map containing sample information e.g. [ id:'test', single_end:false ] - - input: type: file description: Input VCF/BCF file containing genotype likelihoods. pattern: "*.{vcf.gz,bcf.gz}" - - input_index: type: file description: Index file of the input VCF/BCF file containing genotype likelihoods. pattern: "*.{vcf.gz.csi,bcf.gz.csi}" - - samples_file: type: file description: | @@ -40,44 +35,36 @@ input: Sample names that are not present are assumed to have ploidy 2 (diploids). GLIMPSE does NOT handle the use of sex (M/F) instead of ploidy. pattern: "*.{txt,tsv}" - - input_region: type: string description: Target region used for imputation, including left and right buffers (e.g. chr20:1000000-2000000). pattern: "chrXX:leftBufferPosition-rightBufferPosition" - - output_region: type: string description: Target imputed region, excluding left and right buffers (e.g. chr20:1000000-2000000). pattern: "chrXX:leftBufferPosition-rightBufferPosition" - - reference: type: file description: Reference panel of haplotypes in VCF/BCF format. pattern: "*.{vcf.gz,bcf.gz}" - - reference_index: type: file description: Index file of the Reference panel file. pattern: "*.{vcf.gz.csi,bcf.gz.csi}" - - map: type: file description: File containing the genetic map. pattern: "*.gmap" - 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" - - phased_variants: type: file description: | @@ -85,6 +72,7 @@ output: imputed dosages (DS field), best guess genotypes (GT field), sampled haplotypes in the last (max 16) main iterations (HS field) and info-score. pattern: "*.{vcf,bcf,vcf.gz,bcf.gz}" - authors: - "@louislenezet" +maintainers: + - "@louislenezet" diff --git a/modules/nf-core/glimpse/phase/tests/main.nf.test b/modules/nf-core/glimpse/phase/tests/main.nf.test new file mode 100644 index 00000000..0009387f --- /dev/null +++ b/modules/nf-core/glimpse/phase/tests/main.nf.test @@ -0,0 +1,67 @@ +nextflow_process { + + name "Test Process GLIMPSE_PHASE" + script "../main.nf" + process "GLIMPSE_PHASE" + tag "glimpse" + tag "glimpse/phase" + tag "modules_nfcore" + tag "modules" + + test("test_glimpse_phase") { + + when { + process { + """ + ch_sample = Channel.of([sample:'present']) + | combine(Channel.of('NA12878 2').collectFile(name: 'sampleinfos.txt')) + | concat(Channel.of([[sample: 'absent'], []])) + region = Channel.fromList([ + ["chr21:16600000-16750000","chr21:16650000-16700000"], + ["chr21:16650000-16800000","chr21:16700000-16750000"] + ]) + input_vcf = Channel.of([ + [ id:'input'], // meta map + file("https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/glimpse/NA12878.chr21.s.1x.vcf.gz", checkIfExists: true), + file("https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/glimpse/NA12878.chr21.s.1x.vcf.gz.csi", checkIfExists: true) + ]) + ref_panel = Channel.of([ + file("https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/glimpse/1000GP.chr21.noNA12878.s.bcf", checkIfExists: true), + file("https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/glimpse/1000GP.chr21.noNA12878.s.bcf.csi", checkIfExists: true) + ]) + ch_map = Channel.of([ + file("https://github.com/nf-core/test-datasets/raw/modules/data/delete_me/glimpse/chr21.b38.gmap.gz", checkIfExists: true), + ]) + + input[0] = input_vcf + | combine(ch_sample) + | combine(region) + | map { meta, vcf, index, metaS, sample, regionI, regionO -> + [[id: meta.id + "_" + metaS.sample, region : regionI], vcf, index, sample, regionI, regionO] + } + | combine(ref_panel) + | combine(ch_map) + """ + } + } + + then { + String targetFileName = "input_present_chr21_16650000-16800000.vcf.gz" + File selectedFile = process.out.phased_variant.stream() + .filter(vector -> vector.size() > 1) + .map(vector -> new File(vector.get(1).toString())) + .filter(file -> file.getName().equals(targetFileName)) + .findFirst() + .orElse(null) + String selectedFilename = selectedFile != null ? selectedFile.getPath() : null + def lines = path(selectedFilename).linesGzip.last() + assertAll( + { assert process.success }, + { assert snapshot(process.out.versions).match("versions") }, + { assert process.out.phased_variant.size() == 4}, + { assert snapshot(lines).match("imputed") } + ) + } + + } +} diff --git a/modules/nf-core/glimpse/phase/tests/main.nf.test.snap b/modules/nf-core/glimpse/phase/tests/main.nf.test.snap new file mode 100644 index 00000000..d61cf86e --- /dev/null +++ b/modules/nf-core/glimpse/phase/tests/main.nf.test.snap @@ -0,0 +1,19 @@ +{ + "versions": { + "content": [ + [ + "versions.yml:md5,b24f49b2f5989a1f7da32c195334e96b", + "versions.yml:md5,b24f49b2f5989a1f7da32c195334e96b", + "versions.yml:md5,b24f49b2f5989a1f7da32c195334e96b", + "versions.yml:md5,b24f49b2f5989a1f7da32c195334e96b" + ] + ], + "timestamp": "2023-10-17T15:27:55.512415434" + }, + "imputed": { + "content": [ + "chr21\t16799989\t21:16799989:T:C\tT\tC\t.\t.\tRAF=0.000468897;AF=0;INFO=1;BUF=1\tGT:DS:GP:HS\t0/0:0:1,0,0:0" + ], + "timestamp": "2023-10-17T15:27:55.99820664" + } +} \ No newline at end of file diff --git a/modules/nf-core/glimpse/phase/tests/tags.yml b/modules/nf-core/glimpse/phase/tests/tags.yml new file mode 100644 index 00000000..61c28281 --- /dev/null +++ b/modules/nf-core/glimpse/phase/tests/tags.yml @@ -0,0 +1,2 @@ +glimpse/phase: + - modules/nf-core/glimpse/phase/** diff --git a/subworkflows/nf-core/vcf_impute_glimpse/meta.yml b/subworkflows/nf-core/vcf_impute_glimpse/meta.yml index 598b6888..6c9fe223 100644 --- a/subworkflows/nf-core/vcf_impute_glimpse/meta.yml +++ b/subworkflows/nf-core/vcf_impute_glimpse/meta.yml @@ -6,13 +6,11 @@ keywords: - chunk - phase - ligate - components: - glimpse/chunk - glimpse/phase - glimpse/ligate - bcftools/index - input: - ch_input: type: file @@ -26,14 +24,12 @@ input: File containing the genetic map. The file could possibly be without GT field (for efficiency reasons a file containing only the positions is recommended). Structure: [ meta, vcf, csi, txt, region, ref_vcf, ref_csi, gmap ] - output: - chunk_chr: type: file description: | Tab delimited output txt file containing buffer and imputation regions. Structure: [meta, txt] - - phased_variants: type: file description: | @@ -41,18 +37,17 @@ output: imputed dosages (DS field), best guess genotypes (GT field), sampled haplotypes in the last (max 16) main iterations (HS field) and info-score. Structure: [ val(meta), bcf ] - - merged_variants: type: file description: | Output VCF/BCF file for the merged regions. Phased information (HS field) is updated accordingly for the full region. Structure: [ val(meta), bcf ] - - versions: type: file description: File containing software versions pattern: "versions.yml" - authors: - "@LouisLeNezet" +maintainers: + - "@LouisLeNezet" diff --git a/subworkflows/nf-core/vcf_impute_glimpse/tests/main.nf.test b/subworkflows/nf-core/vcf_impute_glimpse/tests/main.nf.test new file mode 100644 index 00000000..7931f706 --- /dev/null +++ b/subworkflows/nf-core/vcf_impute_glimpse/tests/main.nf.test @@ -0,0 +1,110 @@ +nextflow_workflow { + + name "Test Workflow VCF_IMPUTE_GLIMPSE" + script "../main.nf" + workflow "VCF_IMPUTE_GLIMPSE" + tag "glimpse" + tag "glimpse/chunk" + tag "glimpse/phase" + tag "glimpse/ligate" + tag "subworkflows" + tag "subworkflows_nfcore" + tag "vcf_impute_glimpse" + + test("Should run without failures") { + config "./nextflow.config" + + when { + params { + outdir = "tests/results" + } + workflow { + """ + samples_infos = Channel.of('NA12878 2').collectFile(name: 'sampleinfos.txt') + + ch_panel = Channel.fromList([ + [[ ref:'ref_panel'], + file("https://github.com/nf-core/test-datasets/raw/imputation/data/panel/both/1000GP.chr21_22.noNA12878.s.bcf", + checkIfExists: true), + file("https://github.com/nf-core/test-datasets/raw/imputation/data/panel/both/1000GP.chr21_22.noNA12878.s.bcf.csi", + checkIfExists: true)], + [[ ref:'ref_panel2'], + file("https://github.com/nf-core/test-datasets/raw/imputation/data/panel/both/1000GP.chr21_22.noNA12878.s.bcf", + checkIfExists: true), + file("https://github.com/nf-core/test-datasets/raw/imputation/data/panel/both/1000GP.chr21_22.noNA12878.s.bcf.csi", + checkIfExists: true)] + ]) + region = Channel.fromList([ + [[chr: "chr21", region: "chr21:16600000-16800000"], "chr21:16600000-16800000"], + [[chr: "chr22", region: "chr22:16600000-16800000"], "chr22:16600000-16800000"] + ]) + + input_vcf = Channel.fromList([ + [[ id:'input'], // meta map + file("https://github.com/nf-core/test-datasets/raw/imputation/data/NA12878/both/NA12878.chr21_22.s.1x.vcf.gz", checkIfExists: true), + file("https://github.com/nf-core/test-datasets/raw/imputation/data/NA12878/both/NA12878.chr21_22.s.1x.vcf.gz.csi", checkIfExists: true), + ], + [[ id:'input2'], // meta map + file("https://github.com/nf-core/test-datasets/raw/imputation/data/NA12878/both/NA12878.chr21_22.s.1x.vcf.gz", checkIfExists: true), + file("https://github.com/nf-core/test-datasets/raw/imputation/data/NA12878/both/NA12878.chr21_22.s.1x.vcf.gz.csi", checkIfExists: true), + ] + ]) + input_vcf_multiple = input_vcf + .combine( samples_infos ) + .combine( region ) + .map{ metaI, vcf, index, sample, metaCR, region -> + [metaI + metaCR, vcf, index, sample, region ] + } + + ch_map = Channel.fromList([ + [[ chr: "chr21"], + file("https://github.com/nf-core/test-datasets/raw/imputation/data/genetic_maps.b38/chr21.b38.gmap.gz", checkIfExists: true) + ], + [[ chr: "chr22"], + file("https://github.com/nf-core/test-datasets/raw/imputation/data/genetic_maps.b38/chr22.b38.gmap.gz", checkIfExists: true) + ] + ]) + + // Combine input and map depending on chromosome name + ch_input_map = input_vcf_multiple + .map{ metaIRC, vcf, index, sample, region -> + [metaIRC.subMap(["chr"]), metaIRC, vcf, index, sample, region] + } + .combine(ch_map, by: 0) + .map{ metaC, metaIRC, vcf, index, sample, region, map -> + [metaIRC, vcf, index, sample, region, map] } + + // Combine input and map to reference panel could also be done by chromosome + input[0] = ch_input_map + .combine(ch_panel) + .map{ metaIRC, vcf, index, sample, region, map, metaP, ref, ref_index -> + [ metaIRC + metaP, vcf, index, sample, region, ref, ref_index, map ] + } + """ + } + } + + then { + println(workflow.out.merged_variants) + String targetFileName = "input_chr21_ref_panel2_ligate.vcf.gz" + File selectedFile = workflow.out.merged_variants.stream() + .filter(vector -> vector.size() > 1) + .map(vector -> new File(vector.get(1).toString())) + .filter(file -> file.getName().equals(targetFileName)) + .findFirst() + .orElse(null) + String selectedFilename = selectedFile != null ? selectedFile.getPath() : null + def lines = path(selectedFilename).linesGzip.last() + print(lines) + assertAll( + { assert workflow.success }, + { assert snapshot(workflow.out.versions).match("versions") }, + { assert snapshot(workflow.out.chunk_chr).match("chunk_chr") }, + { assert workflow.out.merged_variants.size() == 8}, + { assert snapshot(lines).match("merged") } + ) + } + + } + +} diff --git a/subworkflows/nf-core/vcf_impute_glimpse/tests/main.nf.test.snap b/subworkflows/nf-core/vcf_impute_glimpse/tests/main.nf.test.snap new file mode 100644 index 00000000..9265c429 --- /dev/null +++ b/subworkflows/nf-core/vcf_impute_glimpse/tests/main.nf.test.snap @@ -0,0 +1,158 @@ +{ + "chunk_chr": { + "content": [ + [ + [ + { + "id": "input", + "chr": "chr21", + "region": "chr21:16600000-16800000", + "ref": "ref_panel2" + }, + "input_chr21:16600000-16800000_chunk.txt:md5,426f0f75efed96818656876116f73b06" + ], + [ + { + "id": "input", + "chr": "chr21", + "region": "chr21:16600000-16800000", + "ref": "ref_panel" + }, + "input_chr21:16600000-16800000_chunk.txt:md5,426f0f75efed96818656876116f73b06" + ], + [ + { + "id": "input", + "chr": "chr22", + "region": "chr22:16600000-16800000", + "ref": "ref_panel2" + }, + "input_chr22:16600000-16800000_chunk.txt:md5,4f48d33fd9c1e235ccfd25827a92ddd1" + ], + [ + { + "id": "input", + "chr": "chr22", + "region": "chr22:16600000-16800000", + "ref": "ref_panel" + }, + "input_chr22:16600000-16800000_chunk.txt:md5,4f48d33fd9c1e235ccfd25827a92ddd1" + ], + [ + { + "id": "input2", + "chr": "chr21", + "region": "chr21:16600000-16800000", + "ref": "ref_panel2" + }, + "input2_chr21:16600000-16800000_chunk.txt:md5,426f0f75efed96818656876116f73b06" + ], + [ + { + "id": "input2", + "chr": "chr21", + "region": "chr21:16600000-16800000", + "ref": "ref_panel" + }, + "input2_chr21:16600000-16800000_chunk.txt:md5,426f0f75efed96818656876116f73b06" + ], + [ + { + "id": "input2", + "chr": "chr22", + "region": "chr22:16600000-16800000", + "ref": "ref_panel2" + }, + "input2_chr22:16600000-16800000_chunk.txt:md5,4f48d33fd9c1e235ccfd25827a92ddd1" + ], + [ + { + "id": "input2", + "chr": "chr22", + "region": "chr22:16600000-16800000", + "ref": "ref_panel" + }, + "input2_chr22:16600000-16800000_chunk.txt:md5,4f48d33fd9c1e235ccfd25827a92ddd1" + ] + ] + ], + "timestamp": "2023-10-17T18:20:13.045340135" + }, + "versions": { + "content": [ + [ + "versions.yml:md5,227d8e960e4382d8a615e040b874fc27", + "versions.yml:md5,227d8e960e4382d8a615e040b874fc27", + "versions.yml:md5,227d8e960e4382d8a615e040b874fc27", + "versions.yml:md5,227d8e960e4382d8a615e040b874fc27", + "versions.yml:md5,227d8e960e4382d8a615e040b874fc27", + "versions.yml:md5,227d8e960e4382d8a615e040b874fc27", + "versions.yml:md5,227d8e960e4382d8a615e040b874fc27", + "versions.yml:md5,227d8e960e4382d8a615e040b874fc27", + "versions.yml:md5,73621eae1bfd89c2ceb009524fe680d4", + "versions.yml:md5,73621eae1bfd89c2ceb009524fe680d4", + "versions.yml:md5,73621eae1bfd89c2ceb009524fe680d4", + "versions.yml:md5,73621eae1bfd89c2ceb009524fe680d4", + "versions.yml:md5,73621eae1bfd89c2ceb009524fe680d4", + "versions.yml:md5,73621eae1bfd89c2ceb009524fe680d4", + "versions.yml:md5,73621eae1bfd89c2ceb009524fe680d4", + "versions.yml:md5,73621eae1bfd89c2ceb009524fe680d4", + "versions.yml:md5,7ae4d2b0252f9382dd08d783b7a234d2", + "versions.yml:md5,7ae4d2b0252f9382dd08d783b7a234d2", + "versions.yml:md5,7ae4d2b0252f9382dd08d783b7a234d2", + "versions.yml:md5,7ae4d2b0252f9382dd08d783b7a234d2", + "versions.yml:md5,7ae4d2b0252f9382dd08d783b7a234d2", + "versions.yml:md5,7ae4d2b0252f9382dd08d783b7a234d2", + "versions.yml:md5,7ae4d2b0252f9382dd08d783b7a234d2", + "versions.yml:md5,7ae4d2b0252f9382dd08d783b7a234d2", + "versions.yml:md5,7ae4d2b0252f9382dd08d783b7a234d2", + "versions.yml:md5,7ae4d2b0252f9382dd08d783b7a234d2", + "versions.yml:md5,7ae4d2b0252f9382dd08d783b7a234d2", + "versions.yml:md5,7ae4d2b0252f9382dd08d783b7a234d2", + "versions.yml:md5,7ae4d2b0252f9382dd08d783b7a234d2", + "versions.yml:md5,7ae4d2b0252f9382dd08d783b7a234d2", + "versions.yml:md5,7ae4d2b0252f9382dd08d783b7a234d2", + "versions.yml:md5,7ae4d2b0252f9382dd08d783b7a234d2", + "versions.yml:md5,7ae4d2b0252f9382dd08d783b7a234d2", + "versions.yml:md5,7ae4d2b0252f9382dd08d783b7a234d2", + "versions.yml:md5,7ae4d2b0252f9382dd08d783b7a234d2", + "versions.yml:md5,7ae4d2b0252f9382dd08d783b7a234d2", + "versions.yml:md5,86d1ec939ded96a4ed3fb73ff83c240b", + "versions.yml:md5,86d1ec939ded96a4ed3fb73ff83c240b", + "versions.yml:md5,86d1ec939ded96a4ed3fb73ff83c240b", + "versions.yml:md5,86d1ec939ded96a4ed3fb73ff83c240b", + "versions.yml:md5,86d1ec939ded96a4ed3fb73ff83c240b", + "versions.yml:md5,86d1ec939ded96a4ed3fb73ff83c240b", + "versions.yml:md5,86d1ec939ded96a4ed3fb73ff83c240b", + "versions.yml:md5,86d1ec939ded96a4ed3fb73ff83c240b", + "versions.yml:md5,a17a10f6eb5e140e388b92d5f19680ae", + "versions.yml:md5,a17a10f6eb5e140e388b92d5f19680ae", + "versions.yml:md5,a17a10f6eb5e140e388b92d5f19680ae", + "versions.yml:md5,a17a10f6eb5e140e388b92d5f19680ae", + "versions.yml:md5,a17a10f6eb5e140e388b92d5f19680ae", + "versions.yml:md5,a17a10f6eb5e140e388b92d5f19680ae", + "versions.yml:md5,a17a10f6eb5e140e388b92d5f19680ae", + "versions.yml:md5,a17a10f6eb5e140e388b92d5f19680ae", + "versions.yml:md5,a17a10f6eb5e140e388b92d5f19680ae", + "versions.yml:md5,a17a10f6eb5e140e388b92d5f19680ae", + "versions.yml:md5,a17a10f6eb5e140e388b92d5f19680ae", + "versions.yml:md5,a17a10f6eb5e140e388b92d5f19680ae", + "versions.yml:md5,a17a10f6eb5e140e388b92d5f19680ae", + "versions.yml:md5,a17a10f6eb5e140e388b92d5f19680ae", + "versions.yml:md5,a17a10f6eb5e140e388b92d5f19680ae", + "versions.yml:md5,a17a10f6eb5e140e388b92d5f19680ae", + "versions.yml:md5,a17a10f6eb5e140e388b92d5f19680ae", + "versions.yml:md5,a17a10f6eb5e140e388b92d5f19680ae", + "versions.yml:md5,a17a10f6eb5e140e388b92d5f19680ae", + "versions.yml:md5,a17a10f6eb5e140e388b92d5f19680ae" + ] + ], + "timestamp": "2023-10-17T18:20:06.846882518" + }, + "merged": { + "content": [ + "chr21\t16799989\t21:16799989:T:C\tT\tC\t.\t.\tRAF=0.000468897;AF=0;INFO=1\tGT:DS:GP:HS\t0/0:0:1,0,0:0" + ], + "timestamp": "2023-10-17T18:20:19.789038503" + } +} \ No newline at end of file diff --git a/subworkflows/nf-core/vcf_impute_glimpse/tests/nextflow.config b/subworkflows/nf-core/vcf_impute_glimpse/tests/nextflow.config new file mode 100644 index 00000000..09ab6858 --- /dev/null +++ b/subworkflows/nf-core/vcf_impute_glimpse/tests/nextflow.config @@ -0,0 +1,12 @@ +process { + withName: GLIMPSE_CHUNK { + ext.prefix = { "${meta.id}_${meta.region}_chunk" } + ext.args = "--window-size 50000 --buffer-size 1000" + } + withName: GLIMPSE_PHASE { + ext.prefix = { "${meta.id}_${meta.region}_${meta.ref}_phase_${input_region.replace(":","_")}" } + } + withName: GLIMPSE_LIGATE { + ext.prefix = { "${meta.id}_${meta.chr}_${meta.ref}_ligate" } + } +} diff --git a/subworkflows/nf-core/vcf_impute_glimpse/tests/tags.yml b/subworkflows/nf-core/vcf_impute_glimpse/tests/tags.yml new file mode 100644 index 00000000..34d27725 --- /dev/null +++ b/subworkflows/nf-core/vcf_impute_glimpse/tests/tags.yml @@ -0,0 +1,2 @@ +vcf_impute_glimpse: + - subworkflows/nf-core/vcf_impute_glimpse/** diff --git a/workflows/phaseimpute.nf b/workflows/phaseimpute.nf index c7835ac0..69e1755d 100644 --- a/workflows/phaseimpute.nf +++ b/workflows/phaseimpute.nf @@ -7,13 +7,13 @@ // // MODULE: Installed directly from nf-core/modules // -include { MULTIQC } from '../modules/nf-core/multiqc/main' +include { MULTIQC } from '../modules/nf-core/multiqc/main' include { paramsSummaryMap } from 'plugin/nf-validation' include { paramsSummaryMultiqc } from '../subworkflows/nf-core/utils_nfcore_pipeline' include { softwareVersionsToYAML } from '../subworkflows/nf-core/utils_nfcore_pipeline' include { methodsDescriptionText } from '../subworkflows/local/utils_nfcore_phaseimpute_pipeline' -include { SAMTOOLS_FAIDX } from '../modules/nf-core/samtools/faidx/main' -include { BAM_REGION } from '../subworkflows/local/bam_region' +include { SAMTOOLS_FAIDX } from '../modules/nf-core/samtools/faidx/main' +include { BAM_REGION } from '../subworkflows/local/bam_region' // // SUBWORKFLOW: Consisting of a mix of local and nf-core/modules @@ -153,8 +153,8 @@ workflow PHASEIMPUTE { VCF_IMPUTE_GLIMPSE(impute_input, GET_PANEL.out.panel_phased, ch_map) - - ch_impute_output = ch_impute_output.mix(VCF_IMPUTE_GLIMPSE.out.) + + ch_impute_output = ch_impute_output.mix(VCF_IMPUTE_GLIMPSE.out.merged_variants) } if (params.tools.contains("glimpse2")){ print("Impute with Glimpse2")