From bba558944a41c0d7f83cecf472f999cfb13ac9e3 Mon Sep 17 00:00:00 2001 From: lyh970817 Date: Fri, 20 Mar 2026 23:12:14 +0800 Subject: [PATCH 1/5] feat: add gcta/removerelatedsubjects module --- .../removerelatedsubjects/environment.yml | 7 ++ .../gcta/removerelatedsubjects/main.nf | 41 ++++++++ .../gcta/removerelatedsubjects/meta.yml | 96 ++++++++++++++++++ .../removerelatedsubjects/tests/main.nf.test | 96 ++++++++++++++++++ .../tests/main.nf.test.snap | 99 +++++++++++++++++++ .../tests/nextflow.config | 3 + 6 files changed, 342 insertions(+) create mode 100644 modules/nf-core/gcta/removerelatedsubjects/environment.yml create mode 100644 modules/nf-core/gcta/removerelatedsubjects/main.nf create mode 100644 modules/nf-core/gcta/removerelatedsubjects/meta.yml create mode 100644 modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test create mode 100644 modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test.snap create mode 100644 modules/nf-core/gcta/removerelatedsubjects/tests/nextflow.config diff --git a/modules/nf-core/gcta/removerelatedsubjects/environment.yml b/modules/nf-core/gcta/removerelatedsubjects/environment.yml new file mode 100644 index 000000000000..3e22ea7b9f20 --- /dev/null +++ b/modules/nf-core/gcta/removerelatedsubjects/environment.yml @@ -0,0 +1,7 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json +channels: + - conda-forge + - bioconda +dependencies: + - bioconda::gcta=1.94.1 diff --git a/modules/nf-core/gcta/removerelatedsubjects/main.nf b/modules/nf-core/gcta/removerelatedsubjects/main.nf new file mode 100644 index 000000000000..c1e3e3862af5 --- /dev/null +++ b/modules/nf-core/gcta/removerelatedsubjects/main.nf @@ -0,0 +1,41 @@ +process GCTA_REMOVERELATEDSUBJECTS { + tag "${meta.id}" + label 'process_medium' + conda "${moduleDir}/environment.yml" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'docker://community.wave.seqera.io/library/gcta:1.94.1--9bc35dc424fcf6e9' : + 'community.wave.seqera.io/library/gcta:1.94.1--9bc35dc424fcf6e9' }" + + input: + tuple val(meta), path(grm_id), path(grm_bin), path(grm_n_bin) + + output: + tuple val(meta), path("*_unrel05.grm.id"), path("*_unrel05.grm.bin"), path("*_unrel05.grm.N.bin"), emit: grm_files + tuple val(meta), path("*_unrel05.grm.id"), emit: keep_file + tuple val("${task.process}"), val("gcta"), eval("gcta --version 2>&1 | grep 'version v' | tr -s ' ' | cut -d' ' -f3 | sed 's/^v//'"), emit: versions_gcta, topic: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + + """ + gcta \\ + --grm ${meta.id} \\ + --grm-cutoff 0.05 \\ + --make-grm \\ + --out ${prefix}_unrel05 \\ + --thread-num ${task.cpus} \\ + ${args} + """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + """ + touch ${prefix}_unrel05.grm.id + touch ${prefix}_unrel05.grm.bin + touch ${prefix}_unrel05.grm.N.bin + """ +} diff --git a/modules/nf-core/gcta/removerelatedsubjects/meta.yml b/modules/nf-core/gcta/removerelatedsubjects/meta.yml new file mode 100644 index 000000000000..1e29d68b6c4b --- /dev/null +++ b/modules/nf-core/gcta/removerelatedsubjects/meta.yml @@ -0,0 +1,96 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json +name: "gcta_removerelatedsubjects" +description: Remove related individuals from a dense GRM using `gcta --grm-cutoff` +keywords: + - gcta + - grm + - genetics +tools: + - "gcta": + description: "Genome-wide Complex Trait Analysis (GCTA) estimates genetic relationships, variance components, and association statistics from genome-wide data." + homepage: "https://yanglab.westlake.edu.cn/software/gcta/" + documentation: "https://yanglab.westlake.edu.cn/software/gcta/static/gcta_doc_latest.pdf" + tool_dev_url: "https://yanglab.westlake.edu.cn/software/gcta/" + +input: + - - meta: + type: map + description: | + Groovy map containing dense GRM metadata + e.g. `[ id:'plink_simulated' ]` + - grm_id: + type: file + description: Dense GRM sample identifier file + pattern: "*.grm.id" + ontologies: [] + - grm_bin: + type: file + description: Dense GRM binary matrix file + pattern: "*.grm.bin" + ontologies: [] + - grm_n_bin: + type: file + description: Dense GRM sample-count matrix file + pattern: "*.grm.N.bin" + ontologies: [] + +output: + grm_files: + - - meta: + type: map + description: | + Groovy map containing dense GRM metadata + e.g. `[ id:'plink_simulated' ]` + - "*_unrel05.grm.id": + type: file + description: Relatedness-filtered GRM sample identifier file + pattern: "*_unrel05.grm.id" + ontologies: [] + - "*_unrel05.grm.bin": + type: file + description: Relatedness-filtered GRM binary matrix file + pattern: "*_unrel05.grm.bin" + ontologies: [] + - "*_unrel05.grm.N.bin": + type: file + description: Relatedness-filtered GRM sample-count matrix file + pattern: "*_unrel05.grm.N.bin" + ontologies: [] + keep_file: + - - meta: + type: map + description: | + Groovy map containing dense GRM metadata + e.g. `[ id:'plink_simulated' ]` + - "*_unrel05.grm.id": + type: file + description: Keep file of unrelated individuals emitted by GCTA + pattern: "*_unrel05.grm.id" + ontologies: [] + versions_gcta: + - - "${task.process}": + type: string + description: The process the version was collected from + - "gcta": + type: string + description: The tool name + - "gcta --version 2>&1 | grep 'version v' | tr -s ' ' | cut -d' ' -f3 | sed 's/^v//'": + type: eval + description: The command used to retrieve the GCTA version + +topics: + versions: + - - ${task.process}: + type: string + description: The process the version was collected from + - gcta: + type: string + description: The tool name + - gcta --version 2>&1 | grep 'version v' | tr -s ' ' | cut -d' ' -f3 | sed 's/^v//': + type: eval + description: The command used to retrieve the GCTA version + +authors: + - "@andongni" +maintainers: + - "@andongni" diff --git a/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test b/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test new file mode 100644 index 000000000000..2716ea7a9970 --- /dev/null +++ b/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test @@ -0,0 +1,96 @@ +nextflow_process { + + name "Test Process GCTA_REMOVERELATEDSUBJECTS" + script "../main.nf" + process "GCTA_REMOVERELATEDSUBJECTS" + + tag "modules" + tag "modules_nfcore" + tag "gcta" + tag "gcta/removerelatedsubjects" + tag "gcta/makegrmpart" + + setup { + run("GCTA_MAKEGRMPART", alias: "GCTA_MAKEGRMPART_DENSE") { + script "../../makegrmpart/main.nf" + process { + """ + file('plink_simulated.mbfile').text = 'plink_simulated\\n' + + input[0] = [ + [ id:'plink_simulated_dense', part_gcta_job:1, nparts_gcta:1 ], + file('plink_simulated.mbfile'), + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bed', checkIfExists: true) + ], + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true) + ], + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.fam', checkIfExists: true) + ] + ] + input[1] = [[ id:'all_variants' ], []] + """ + } + } + } + + test("homo_sapiens popgen - remove related individuals from dense GRM") { + config "./nextflow.config" + + when { + process { + """ + dense_grm = GCTA_MAKEGRMPART_DENSE.out.grm_files.map { meta, grm_id, grm_bin, grm_n_bin -> + def prefix = meta.id + '.part_' + meta.nparts_gcta + '_' + meta.part_gcta_job + [[ id:prefix ], grm_id, grm_bin, grm_n_bin] + } + + input[0] = dense_grm + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert process.out.grm_files.size() == 1 }, + { assert process.out.keep_file.size() == 1 }, + { assert process.out.grm_files.get(0).get(0).id == "plink_simulated_dense.part_1_1" }, + { + assert snapshot( + process.out.grm_files, + process.out.keep_file, + process.out.findAll { key, val -> key.startsWith('versions') } + ).match() + } + ) + } + } + + test("homo_sapiens popgen - remove related individuals from dense GRM - stub") { + options "-stub" + config "./nextflow.config" + + when { + process { + """ + dense_grm = GCTA_MAKEGRMPART_DENSE.out.grm_files.map { meta, grm_id, grm_bin, grm_n_bin -> + def prefix = meta.id + '.part_' + meta.nparts_gcta + '_' + meta.part_gcta_job + [[ id:prefix ], grm_id, grm_bin, grm_n_bin] + } + + input[0] = dense_grm + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } +} diff --git a/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test.snap b/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test.snap new file mode 100644 index 000000000000..0751d240524d --- /dev/null +++ b/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test.snap @@ -0,0 +1,99 @@ +{ + "homo_sapiens popgen - remove related individuals from dense GRM": { + "content": [ + [ + [ + { + "id": "plink_simulated_dense.part_1_1" + }, + "plink_simulated_dense.part_1_1_unrel05.grm.id:md5,ca8c0bded6951fdd3bf0dddc97b6df6b", + "plink_simulated_dense.part_1_1_unrel05.grm.bin:md5,b1f124463eecbae86840a6651eec372d", + "plink_simulated_dense.part_1_1_unrel05.grm.N.bin:md5,06b73ea8bae8f1e5f5d4de33dbd2c75e" + ] + ], + [ + [ + { + "id": "plink_simulated_dense.part_1_1" + }, + "plink_simulated_dense.part_1_1_unrel05.grm.id:md5,ca8c0bded6951fdd3bf0dddc97b6df6b" + ] + ], + { + "versions_gcta": [ + [ + "GCTA_REMOVERELATEDSUBJECTS", + "gcta", + "1.94.1" + ] + ] + } + ], + "meta": { + "nf-test": "0.9.3", + "nextflow": "25.10.4" + }, + "timestamp": "2026-03-13T15:36:41.961471309" + }, + "homo_sapiens popgen - remove related individuals from dense GRM - stub": { + "content": [ + { + "0": [ + [ + { + "id": "plink_simulated_dense.part_1_1" + }, + "plink_simulated_dense.part_1_1_unrel05.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e", + "plink_simulated_dense.part_1_1_unrel05.grm.bin:md5,d41d8cd98f00b204e9800998ecf8427e", + "plink_simulated_dense.part_1_1_unrel05.grm.N.bin:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + [ + { + "id": "plink_simulated_dense.part_1_1" + }, + "plink_simulated_dense.part_1_1_unrel05.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "2": [ + [ + "GCTA_REMOVERELATEDSUBJECTS", + "gcta", + "1.94.1" + ] + ], + "grm_files": [ + [ + { + "id": "plink_simulated_dense.part_1_1" + }, + "plink_simulated_dense.part_1_1_unrel05.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e", + "plink_simulated_dense.part_1_1_unrel05.grm.bin:md5,d41d8cd98f00b204e9800998ecf8427e", + "plink_simulated_dense.part_1_1_unrel05.grm.N.bin:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "keep_file": [ + [ + { + "id": "plink_simulated_dense.part_1_1" + }, + "plink_simulated_dense.part_1_1_unrel05.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions_gcta": [ + [ + "GCTA_REMOVERELATEDSUBJECTS", + "gcta", + "1.94.1" + ] + ] + } + ], + "meta": { + "nf-test": "0.9.3", + "nextflow": "25.10.4" + }, + "timestamp": "2026-03-13T15:36:48.571305038" + } +} \ No newline at end of file diff --git a/modules/nf-core/gcta/removerelatedsubjects/tests/nextflow.config b/modules/nf-core/gcta/removerelatedsubjects/tests/nextflow.config new file mode 100644 index 000000000000..de31e0218829 --- /dev/null +++ b/modules/nf-core/gcta/removerelatedsubjects/tests/nextflow.config @@ -0,0 +1,3 @@ +params { + modules_testdata_base_path = System.getenv("NF_MODULES_TESTDATA_BASE_PATH") ?: "https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/" +} From d90c103c7e8f9622819957568335e5bebcb4e88c Mon Sep 17 00:00:00 2001 From: lyh970817 Date: Sat, 21 Mar 2026 15:53:17 +0800 Subject: [PATCH 2/5] test(gcta/removerelatedsubjects): harden basename contract coverage --- .../gcta/removerelatedsubjects/meta.yml | 21 ++-- .../removerelatedsubjects/tests/main.nf.test | 114 ++++++++++++------ .../tests/main.nf.test.snap | 77 ++++-------- 3 files changed, 113 insertions(+), 99 deletions(-) diff --git a/modules/nf-core/gcta/removerelatedsubjects/meta.yml b/modules/nf-core/gcta/removerelatedsubjects/meta.yml index 1e29d68b6c4b..666490912aad 100644 --- a/modules/nf-core/gcta/removerelatedsubjects/meta.yml +++ b/modules/nf-core/gcta/removerelatedsubjects/meta.yml @@ -16,21 +16,24 @@ input: - - meta: type: map description: | - Groovy map containing dense GRM metadata - e.g. `[ id:'plink_simulated' ]` + Groovy map containing dense GRM metadata. + `meta.id` is the required GRM basename consumed by `--grm` and must match + the staged dense GRM files. + e.g. `[ id:'tiny_dense' ]` requires + `tiny_dense.grm.id`, `tiny_dense.grm.bin`, and `tiny_dense.grm.N.bin`. - grm_id: type: file - description: Dense GRM sample identifier file + description: Dense GRM sample identifier file with basename `${meta.id}` pattern: "*.grm.id" ontologies: [] - grm_bin: type: file - description: Dense GRM binary matrix file + description: Dense GRM binary matrix file with basename `${meta.id}` pattern: "*.grm.bin" ontologies: [] - grm_n_bin: type: file - description: Dense GRM sample-count matrix file + description: Dense GRM sample-count matrix file with basename `${meta.id}` pattern: "*.grm.N.bin" ontologies: [] @@ -39,8 +42,8 @@ output: - - meta: type: map description: | - Groovy map containing dense GRM metadata - e.g. `[ id:'plink_simulated' ]` + Groovy map containing dense GRM metadata. + `meta.id` remains the dense-GRM basename contract used for `--grm`. - "*_unrel05.grm.id": type: file description: Relatedness-filtered GRM sample identifier file @@ -60,8 +63,8 @@ output: - - meta: type: map description: | - Groovy map containing dense GRM metadata - e.g. `[ id:'plink_simulated' ]` + Groovy map containing dense GRM metadata. + `meta.id` remains the dense-GRM basename contract used for `--grm`. - "*_unrel05.grm.id": type: file description: Keep file of unrelated individuals emitted by GCTA diff --git a/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test b/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test index 2716ea7a9970..d66368284ae3 100644 --- a/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test +++ b/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test @@ -8,33 +8,6 @@ nextflow_process { tag "modules_nfcore" tag "gcta" tag "gcta/removerelatedsubjects" - tag "gcta/makegrmpart" - - setup { - run("GCTA_MAKEGRMPART", alias: "GCTA_MAKEGRMPART_DENSE") { - script "../../makegrmpart/main.nf" - process { - """ - file('plink_simulated.mbfile').text = 'plink_simulated\\n' - - input[0] = [ - [ id:'plink_simulated_dense', part_gcta_job:1, nparts_gcta:1 ], - file('plink_simulated.mbfile'), - [ - file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bed', checkIfExists: true) - ], - [ - file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true) - ], - [ - file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.fam', checkIfExists: true) - ] - ] - input[1] = [[ id:'all_variants' ], []] - """ - } - } - } test("homo_sapiens popgen - remove related individuals from dense GRM") { config "./nextflow.config" @@ -42,12 +15,11 @@ nextflow_process { when { process { """ - dense_grm = GCTA_MAKEGRMPART_DENSE.out.grm_files.map { meta, grm_id, grm_bin, grm_n_bin -> - def prefix = meta.id + '.part_' + meta.nparts_gcta + '_' + meta.part_gcta_job - [[ id:prefix ], grm_id, grm_bin, grm_n_bin] - } + file('tiny_dense.grm.id').text = 'sample1 sample1\\n' + file('tiny_dense.grm.bin').bytes = java.nio.ByteBuffer.allocate(4).order(java.nio.ByteOrder.LITTLE_ENDIAN).putFloat(1.0f).array() + file('tiny_dense.grm.N.bin').bytes = java.nio.ByteBuffer.allocate(4).order(java.nio.ByteOrder.LITTLE_ENDIAN).putFloat(100.0f).array() - input[0] = dense_grm + input[0] = [[ id:'tiny_dense' ], file('tiny_dense.grm.id'), file('tiny_dense.grm.bin'), file('tiny_dense.grm.N.bin')] """ } } @@ -57,7 +29,15 @@ nextflow_process { { assert process.success }, { assert process.out.grm_files.size() == 1 }, { assert process.out.keep_file.size() == 1 }, - { assert process.out.grm_files.get(0).get(0).id == "plink_simulated_dense.part_1_1" }, + { assert process.out.grm_files.get(0).get(0).id == "tiny_dense" }, + { + def grm_row = process.out.grm_files.get(0) + def expected_prefix = "${grm_row.get(0).id}_unrel05" + assert file(grm_row.get(1)).name == "${expected_prefix}.grm.id" + assert file(grm_row.get(2)).name == "${expected_prefix}.grm.bin" + assert file(grm_row.get(3)).name == "${expected_prefix}.grm.N.bin" + assert file(process.out.keep_file.get(0).get(1)).name == "${expected_prefix}.grm.id" + }, { assert snapshot( process.out.grm_files, @@ -69,6 +49,48 @@ nextflow_process { } } + test("homo_sapiens popgen - remove related individuals fails when meta.id is not GRM basename") { + config "./nextflow.config" + + when { + process { + """ + file('tiny_dense.grm.id').text = 'sample1 sample1\\n' + file('tiny_dense.grm.bin').bytes = java.nio.ByteBuffer.allocate(4).order(java.nio.ByteOrder.LITTLE_ENDIAN).putFloat(1.0f).array() + file('tiny_dense.grm.N.bin').bytes = java.nio.ByteBuffer.allocate(4).order(java.nio.ByteOrder.LITTLE_ENDIAN).putFloat(100.0f).array() + + input[0] = [[ id:'tiny_dense_mismatched' ], file('tiny_dense.grm.id'), file('tiny_dense.grm.bin'), file('tiny_dense.grm.N.bin')] + """ + } + } + + then { + assertAll( + { assert !process.success }, + { assert process.exitStatus != 0 } + ) + } + } + + test("homo_sapiens popgen - remove related individuals fails for malformed GRM tuple") { + config "./nextflow.config" + + when { + process { + """ + file('tiny_dense.grm.id').text = 'sample1 sample1\\n' + file('tiny_dense.grm.bin').bytes = java.nio.ByteBuffer.allocate(4).order(java.nio.ByteOrder.LITTLE_ENDIAN).putFloat(1.0f).array() + + input[0] = [[ id:'tiny_dense' ], file('tiny_dense.grm.id'), file('tiny_dense.grm.bin')] + """ + } + } + + then { + assert !process.success + } + } + test("homo_sapiens popgen - remove related individuals from dense GRM - stub") { options "-stub" config "./nextflow.config" @@ -76,12 +98,11 @@ nextflow_process { when { process { """ - dense_grm = GCTA_MAKEGRMPART_DENSE.out.grm_files.map { meta, grm_id, grm_bin, grm_n_bin -> - def prefix = meta.id + '.part_' + meta.nparts_gcta + '_' + meta.part_gcta_job - [[ id:prefix ], grm_id, grm_bin, grm_n_bin] - } + file('tiny_dense.grm.id').text = 'sample1 sample1\\n' + file('tiny_dense.grm.bin').bytes = java.nio.ByteBuffer.allocate(4).order(java.nio.ByteOrder.LITTLE_ENDIAN).putFloat(1.0f).array() + file('tiny_dense.grm.N.bin').bytes = java.nio.ByteBuffer.allocate(4).order(java.nio.ByteOrder.LITTLE_ENDIAN).putFloat(100.0f).array() - input[0] = dense_grm + input[0] = [[ id:'tiny_dense' ], file('tiny_dense.grm.id'), file('tiny_dense.grm.bin'), file('tiny_dense.grm.N.bin')] """ } } @@ -89,7 +110,22 @@ nextflow_process { then { assertAll( { assert process.success }, - { assert snapshot(process.out).match() } + { assert process.out.grm_files.get(0).get(0).id == "tiny_dense" }, + { + def grm_row = process.out.grm_files.get(0) + def expected_prefix = "${grm_row.get(0).id}_unrel05" + assert file(grm_row.get(1)).name == "${expected_prefix}.grm.id" + assert file(grm_row.get(2)).name == "${expected_prefix}.grm.bin" + assert file(grm_row.get(3)).name == "${expected_prefix}.grm.N.bin" + assert file(process.out.keep_file.get(0).get(1)).name == "${expected_prefix}.grm.id" + }, + { + assert snapshot( + process.out.grm_files, + process.out.keep_file, + process.out.findAll { key, val -> key.startsWith('versions') } + ).match() + } ) } } diff --git a/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test.snap b/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test.snap index 0751d240524d..63ca0c5f97ae 100644 --- a/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test.snap +++ b/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test.snap @@ -4,19 +4,19 @@ [ [ { - "id": "plink_simulated_dense.part_1_1" + "id": "tiny_dense" }, - "plink_simulated_dense.part_1_1_unrel05.grm.id:md5,ca8c0bded6951fdd3bf0dddc97b6df6b", - "plink_simulated_dense.part_1_1_unrel05.grm.bin:md5,b1f124463eecbae86840a6651eec372d", - "plink_simulated_dense.part_1_1_unrel05.grm.N.bin:md5,06b73ea8bae8f1e5f5d4de33dbd2c75e" + "tiny_dense_unrel05.grm.id:md5,822e827e7c1bf900290ef807f514b94d", + "tiny_dense_unrel05.grm.bin:md5,429d81ed2795e3c586906c6c335aa136", + "tiny_dense_unrel05.grm.N.bin:md5,a5d1e9463fae706307f90b05e9e6db9a" ] ], [ [ { - "id": "plink_simulated_dense.part_1_1" + "id": "tiny_dense" }, - "plink_simulated_dense.part_1_1_unrel05.grm.id:md5,ca8c0bded6951fdd3bf0dddc97b6df6b" + "tiny_dense_unrel05.grm.id:md5,822e827e7c1bf900290ef807f514b94d" ] ], { @@ -33,54 +33,29 @@ "nf-test": "0.9.3", "nextflow": "25.10.4" }, - "timestamp": "2026-03-13T15:36:41.961471309" + "timestamp": "2026-03-21T00:36:33.212296305" }, "homo_sapiens popgen - remove related individuals from dense GRM - stub": { "content": [ + [ + [ + { + "id": "tiny_dense" + }, + "tiny_dense_unrel05.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e", + "tiny_dense_unrel05.grm.bin:md5,d41d8cd98f00b204e9800998ecf8427e", + "tiny_dense_unrel05.grm.N.bin:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + [ + [ + { + "id": "tiny_dense" + }, + "tiny_dense_unrel05.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], { - "0": [ - [ - { - "id": "plink_simulated_dense.part_1_1" - }, - "plink_simulated_dense.part_1_1_unrel05.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e", - "plink_simulated_dense.part_1_1_unrel05.grm.bin:md5,d41d8cd98f00b204e9800998ecf8427e", - "plink_simulated_dense.part_1_1_unrel05.grm.N.bin:md5,d41d8cd98f00b204e9800998ecf8427e" - ] - ], - "1": [ - [ - { - "id": "plink_simulated_dense.part_1_1" - }, - "plink_simulated_dense.part_1_1_unrel05.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e" - ] - ], - "2": [ - [ - "GCTA_REMOVERELATEDSUBJECTS", - "gcta", - "1.94.1" - ] - ], - "grm_files": [ - [ - { - "id": "plink_simulated_dense.part_1_1" - }, - "plink_simulated_dense.part_1_1_unrel05.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e", - "plink_simulated_dense.part_1_1_unrel05.grm.bin:md5,d41d8cd98f00b204e9800998ecf8427e", - "plink_simulated_dense.part_1_1_unrel05.grm.N.bin:md5,d41d8cd98f00b204e9800998ecf8427e" - ] - ], - "keep_file": [ - [ - { - "id": "plink_simulated_dense.part_1_1" - }, - "plink_simulated_dense.part_1_1_unrel05.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e" - ] - ], "versions_gcta": [ [ "GCTA_REMOVERELATEDSUBJECTS", @@ -94,6 +69,6 @@ "nf-test": "0.9.3", "nextflow": "25.10.4" }, - "timestamp": "2026-03-13T15:36:48.571305038" + "timestamp": "2026-03-21T00:37:24.069976205" } } \ No newline at end of file From fd57c542ef5e8c96531ec7bf451b3d2c303f7276 Mon Sep 17 00:00:00 2001 From: lyh970817 Date: Sat, 21 Mar 2026 18:47:04 +0800 Subject: [PATCH 3/5] test(gcta/removerelatedsubjects): generate GRM inputs in setup --- .../tests/helpers/dense_grm/main.nf | 33 ++++++++++ .../removerelatedsubjects/tests/main.nf.test | 60 ++++++++++++------- .../tests/main.nf.test.snap | 24 ++++---- 3 files changed, 85 insertions(+), 32 deletions(-) create mode 100644 modules/nf-core/gcta/removerelatedsubjects/tests/helpers/dense_grm/main.nf diff --git a/modules/nf-core/gcta/removerelatedsubjects/tests/helpers/dense_grm/main.nf b/modules/nf-core/gcta/removerelatedsubjects/tests/helpers/dense_grm/main.nf new file mode 100644 index 000000000000..590013f60e0d --- /dev/null +++ b/modules/nf-core/gcta/removerelatedsubjects/tests/helpers/dense_grm/main.nf @@ -0,0 +1,33 @@ +process GCTA_TEST_DENSE_GRM { + tag "${meta.id}" + label "process_medium" + conda "${projectDir}/modules/nf-core/gcta/removerelatedsubjects/environment.yml" + container "${workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'docker://community.wave.seqera.io/library/gcta:1.94.1--9bc35dc424fcf6e9' : + 'community.wave.seqera.io/library/gcta:1.94.1--9bc35dc424fcf6e9'}" + + input: + tuple val(meta), path(bed), path(bim), path(fam) + + output: + tuple val(meta), path("${meta.id}.grm.id"), path("${meta.id}.grm.bin"), path("${meta.id}.grm.N.bin"), emit: dense_grm + + script: + def bfile_prefix = bed.baseName + """ + set -euo pipefail + + gcta \\ + --bfile "${bfile_prefix}" \\ + --make-grm \\ + --out "${meta.id}" \\ + --thread-num ${task.cpus} + """ + + stub: + """ + touch "${meta.id}.grm.id" + touch "${meta.id}.grm.bin" + touch "${meta.id}.grm.N.bin" + """ +} diff --git a/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test b/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test index d66368284ae3..491cc5502ccf 100644 --- a/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test +++ b/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test @@ -8,6 +8,37 @@ nextflow_process { tag "modules_nfcore" tag "gcta" tag "gcta/removerelatedsubjects" + tag "tests/helpers/dense_grm" + + setup { + run("GCTA_TEST_DENSE_GRM", alias: "GCTA_TEST_DENSE_GRM_CONTRACT") { + script "../tests/helpers/dense_grm/main.nf" + process { + """ + input[0] = [ + [ id:'tiny_dense' ], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bed', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.fam', checkIfExists: true) + ] + """ + } + } + + run("GCTA_TEST_DENSE_GRM", alias: "GCTA_TEST_DENSE_GRM_STUB") { + script "../tests/helpers/dense_grm/main.nf" + process { + """ + input[0] = [ + [ id:'stub_dense' ], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bed', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.fam', checkIfExists: true) + ] + """ + } + } + } test("homo_sapiens popgen - remove related individuals from dense GRM") { config "./nextflow.config" @@ -15,11 +46,7 @@ nextflow_process { when { process { """ - file('tiny_dense.grm.id').text = 'sample1 sample1\\n' - file('tiny_dense.grm.bin').bytes = java.nio.ByteBuffer.allocate(4).order(java.nio.ByteOrder.LITTLE_ENDIAN).putFloat(1.0f).array() - file('tiny_dense.grm.N.bin').bytes = java.nio.ByteBuffer.allocate(4).order(java.nio.ByteOrder.LITTLE_ENDIAN).putFloat(100.0f).array() - - input[0] = [[ id:'tiny_dense' ], file('tiny_dense.grm.id'), file('tiny_dense.grm.bin'), file('tiny_dense.grm.N.bin')] + input[0] = GCTA_TEST_DENSE_GRM_CONTRACT.out.dense_grm """ } } @@ -55,11 +82,9 @@ nextflow_process { when { process { """ - file('tiny_dense.grm.id').text = 'sample1 sample1\\n' - file('tiny_dense.grm.bin').bytes = java.nio.ByteBuffer.allocate(4).order(java.nio.ByteOrder.LITTLE_ENDIAN).putFloat(1.0f).array() - file('tiny_dense.grm.N.bin').bytes = java.nio.ByteBuffer.allocate(4).order(java.nio.ByteOrder.LITTLE_ENDIAN).putFloat(100.0f).array() - - input[0] = [[ id:'tiny_dense_mismatched' ], file('tiny_dense.grm.id'), file('tiny_dense.grm.bin'), file('tiny_dense.grm.N.bin')] + input[0] = GCTA_TEST_DENSE_GRM_CONTRACT.out.dense_grm.map { meta, grm_id, grm_bin, grm_n_bin -> + [[ id:'tiny_dense_mismatched' ], grm_id, grm_bin, grm_n_bin] + } """ } } @@ -78,10 +103,9 @@ nextflow_process { when { process { """ - file('tiny_dense.grm.id').text = 'sample1 sample1\\n' - file('tiny_dense.grm.bin').bytes = java.nio.ByteBuffer.allocate(4).order(java.nio.ByteOrder.LITTLE_ENDIAN).putFloat(1.0f).array() - - input[0] = [[ id:'tiny_dense' ], file('tiny_dense.grm.id'), file('tiny_dense.grm.bin')] + input[0] = GCTA_TEST_DENSE_GRM_CONTRACT.out.dense_grm.map { meta, grm_id, grm_bin, grm_n_bin -> + [[ id:meta.id ], grm_id, grm_bin] + } """ } } @@ -98,11 +122,7 @@ nextflow_process { when { process { """ - file('tiny_dense.grm.id').text = 'sample1 sample1\\n' - file('tiny_dense.grm.bin').bytes = java.nio.ByteBuffer.allocate(4).order(java.nio.ByteOrder.LITTLE_ENDIAN).putFloat(1.0f).array() - file('tiny_dense.grm.N.bin').bytes = java.nio.ByteBuffer.allocate(4).order(java.nio.ByteOrder.LITTLE_ENDIAN).putFloat(100.0f).array() - - input[0] = [[ id:'tiny_dense' ], file('tiny_dense.grm.id'), file('tiny_dense.grm.bin'), file('tiny_dense.grm.N.bin')] + input[0] = GCTA_TEST_DENSE_GRM_STUB.out.dense_grm """ } } @@ -110,7 +130,7 @@ nextflow_process { then { assertAll( { assert process.success }, - { assert process.out.grm_files.get(0).get(0).id == "tiny_dense" }, + { assert process.out.grm_files.get(0).get(0).id == "stub_dense" }, { def grm_row = process.out.grm_files.get(0) def expected_prefix = "${grm_row.get(0).id}_unrel05" diff --git a/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test.snap b/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test.snap index 63ca0c5f97ae..e48e0d4e2d1d 100644 --- a/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test.snap +++ b/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test.snap @@ -6,9 +6,9 @@ { "id": "tiny_dense" }, - "tiny_dense_unrel05.grm.id:md5,822e827e7c1bf900290ef807f514b94d", - "tiny_dense_unrel05.grm.bin:md5,429d81ed2795e3c586906c6c335aa136", - "tiny_dense_unrel05.grm.N.bin:md5,a5d1e9463fae706307f90b05e9e6db9a" + "tiny_dense_unrel05.grm.id:md5,ca8c0bded6951fdd3bf0dddc97b6df6b", + "tiny_dense_unrel05.grm.bin:md5,b1f124463eecbae86840a6651eec372d", + "tiny_dense_unrel05.grm.N.bin:md5,06b73ea8bae8f1e5f5d4de33dbd2c75e" ] ], [ @@ -16,7 +16,7 @@ { "id": "tiny_dense" }, - "tiny_dense_unrel05.grm.id:md5,822e827e7c1bf900290ef807f514b94d" + "tiny_dense_unrel05.grm.id:md5,ca8c0bded6951fdd3bf0dddc97b6df6b" ] ], { @@ -33,26 +33,26 @@ "nf-test": "0.9.3", "nextflow": "25.10.4" }, - "timestamp": "2026-03-21T00:36:33.212296305" + "timestamp": "2026-03-21T18:41:51.827057425" }, "homo_sapiens popgen - remove related individuals from dense GRM - stub": { "content": [ [ [ { - "id": "tiny_dense" + "id": "stub_dense" }, - "tiny_dense_unrel05.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e", - "tiny_dense_unrel05.grm.bin:md5,d41d8cd98f00b204e9800998ecf8427e", - "tiny_dense_unrel05.grm.N.bin:md5,d41d8cd98f00b204e9800998ecf8427e" + "stub_dense_unrel05.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e", + "stub_dense_unrel05.grm.bin:md5,d41d8cd98f00b204e9800998ecf8427e", + "stub_dense_unrel05.grm.N.bin:md5,d41d8cd98f00b204e9800998ecf8427e" ] ], [ [ { - "id": "tiny_dense" + "id": "stub_dense" }, - "tiny_dense_unrel05.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e" + "stub_dense_unrel05.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e" ] ], { @@ -69,6 +69,6 @@ "nf-test": "0.9.3", "nextflow": "25.10.4" }, - "timestamp": "2026-03-21T00:37:24.069976205" + "timestamp": "2026-03-21T18:42:16.0502909" } } \ No newline at end of file From f49316f26329f2525b89b3d06f59b8c711926b01 Mon Sep 17 00:00:00 2001 From: lyh970817 Date: Sat, 21 Mar 2026 20:35:27 +0800 Subject: [PATCH 4/5] Use real makegrmpart in removerelatedsubjects tests --- .../tests/helpers/dense_grm/main.nf | 33 --------- .../removerelatedsubjects/tests/main.nf.test | 70 ++++++++++++++----- .../tests/main.nf.test.snap | 28 ++++---- 3 files changed, 65 insertions(+), 66 deletions(-) delete mode 100644 modules/nf-core/gcta/removerelatedsubjects/tests/helpers/dense_grm/main.nf diff --git a/modules/nf-core/gcta/removerelatedsubjects/tests/helpers/dense_grm/main.nf b/modules/nf-core/gcta/removerelatedsubjects/tests/helpers/dense_grm/main.nf deleted file mode 100644 index 590013f60e0d..000000000000 --- a/modules/nf-core/gcta/removerelatedsubjects/tests/helpers/dense_grm/main.nf +++ /dev/null @@ -1,33 +0,0 @@ -process GCTA_TEST_DENSE_GRM { - tag "${meta.id}" - label "process_medium" - conda "${projectDir}/modules/nf-core/gcta/removerelatedsubjects/environment.yml" - container "${workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? - 'docker://community.wave.seqera.io/library/gcta:1.94.1--9bc35dc424fcf6e9' : - 'community.wave.seqera.io/library/gcta:1.94.1--9bc35dc424fcf6e9'}" - - input: - tuple val(meta), path(bed), path(bim), path(fam) - - output: - tuple val(meta), path("${meta.id}.grm.id"), path("${meta.id}.grm.bin"), path("${meta.id}.grm.N.bin"), emit: dense_grm - - script: - def bfile_prefix = bed.baseName - """ - set -euo pipefail - - gcta \\ - --bfile "${bfile_prefix}" \\ - --make-grm \\ - --out "${meta.id}" \\ - --thread-num ${task.cpus} - """ - - stub: - """ - touch "${meta.id}.grm.id" - touch "${meta.id}.grm.bin" - touch "${meta.id}.grm.N.bin" - """ -} diff --git a/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test b/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test index 491cc5502ccf..291a8ee2331e 100644 --- a/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test +++ b/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test @@ -8,33 +8,53 @@ nextflow_process { tag "modules_nfcore" tag "gcta" tag "gcta/removerelatedsubjects" - tag "tests/helpers/dense_grm" + tag "gcta/makegrmpart" setup { - run("GCTA_TEST_DENSE_GRM", alias: "GCTA_TEST_DENSE_GRM_CONTRACT") { - script "../tests/helpers/dense_grm/main.nf" + run("GCTA_MAKEGRMPART", alias: "GCTA_MAKEGRMPART_CONTRACT") { + script "../../makegrmpart/main.nf" process { """ + file('tiny_dense.mbfile').text = 'plink_simulated\\n' + input[0] = [ - [ id:'tiny_dense' ], - file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bed', checkIfExists: true), - file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true), - file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.fam', checkIfExists: true) + [ id:'tiny_dense', part_gcta_job:1, nparts_gcta:1 ], + file('tiny_dense.mbfile'), + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bed', checkIfExists: true) + ], + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true) + ], + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.fam', checkIfExists: true) + ] ] + input[1] = [[ id:'all_variants' ], []] """ } } - run("GCTA_TEST_DENSE_GRM", alias: "GCTA_TEST_DENSE_GRM_STUB") { - script "../tests/helpers/dense_grm/main.nf" + run("GCTA_MAKEGRMPART", alias: "GCTA_MAKEGRMPART_STUB") { + script "../../makegrmpart/main.nf" process { """ + file('stub_dense.mbfile').text = 'plink_simulated\\n' + input[0] = [ - [ id:'stub_dense' ], - file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bed', checkIfExists: true), - file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true), - file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.fam', checkIfExists: true) + [ id:'stub_dense', part_gcta_job:1, nparts_gcta:1 ], + file('stub_dense.mbfile'), + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bed', checkIfExists: true) + ], + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true) + ], + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.fam', checkIfExists: true) + ] ] + input[1] = [[ id:'all_variants' ], []] """ } } @@ -46,7 +66,10 @@ nextflow_process { when { process { """ - input[0] = GCTA_TEST_DENSE_GRM_CONTRACT.out.dense_grm + input[0] = GCTA_MAKEGRMPART_CONTRACT.out.grm_files.map { meta, grm_id, grm_bin, grm_n_bin -> + def prefix = meta.id + '.part_' + meta.nparts_gcta + '_' + meta.part_gcta_job + [[ id:prefix ], grm_id, grm_bin, grm_n_bin] + } """ } } @@ -56,7 +79,7 @@ nextflow_process { { assert process.success }, { assert process.out.grm_files.size() == 1 }, { assert process.out.keep_file.size() == 1 }, - { assert process.out.grm_files.get(0).get(0).id == "tiny_dense" }, + { assert process.out.grm_files.get(0).get(0).id == "tiny_dense.part_1_1" }, { def grm_row = process.out.grm_files.get(0) def expected_prefix = "${grm_row.get(0).id}_unrel05" @@ -82,7 +105,10 @@ nextflow_process { when { process { """ - input[0] = GCTA_TEST_DENSE_GRM_CONTRACT.out.dense_grm.map { meta, grm_id, grm_bin, grm_n_bin -> + input[0] = GCTA_MAKEGRMPART_CONTRACT.out.grm_files.map { meta, grm_id, grm_bin, grm_n_bin -> + def prefix = meta.id + '.part_' + meta.nparts_gcta + '_' + meta.part_gcta_job + [[ id:prefix ], grm_id, grm_bin, grm_n_bin] + }.map { meta, grm_id, grm_bin, grm_n_bin -> [[ id:'tiny_dense_mismatched' ], grm_id, grm_bin, grm_n_bin] } """ @@ -103,7 +129,10 @@ nextflow_process { when { process { """ - input[0] = GCTA_TEST_DENSE_GRM_CONTRACT.out.dense_grm.map { meta, grm_id, grm_bin, grm_n_bin -> + input[0] = GCTA_MAKEGRMPART_CONTRACT.out.grm_files.map { meta, grm_id, grm_bin, grm_n_bin -> + def prefix = meta.id + '.part_' + meta.nparts_gcta + '_' + meta.part_gcta_job + [[ id:prefix ], grm_id, grm_bin, grm_n_bin] + }.map { meta, grm_id, grm_bin, grm_n_bin -> [[ id:meta.id ], grm_id, grm_bin] } """ @@ -122,7 +151,10 @@ nextflow_process { when { process { """ - input[0] = GCTA_TEST_DENSE_GRM_STUB.out.dense_grm + input[0] = GCTA_MAKEGRMPART_STUB.out.grm_files.map { meta, grm_id, grm_bin, grm_n_bin -> + def prefix = meta.id + '.part_' + meta.nparts_gcta + '_' + meta.part_gcta_job + [[ id:prefix ], grm_id, grm_bin, grm_n_bin] + } """ } } @@ -130,7 +162,7 @@ nextflow_process { then { assertAll( { assert process.success }, - { assert process.out.grm_files.get(0).get(0).id == "stub_dense" }, + { assert process.out.grm_files.get(0).get(0).id == "stub_dense.part_1_1" }, { def grm_row = process.out.grm_files.get(0) def expected_prefix = "${grm_row.get(0).id}_unrel05" diff --git a/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test.snap b/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test.snap index e48e0d4e2d1d..9d0a7d2e6874 100644 --- a/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test.snap +++ b/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test.snap @@ -4,19 +4,19 @@ [ [ { - "id": "tiny_dense" + "id": "tiny_dense.part_1_1" }, - "tiny_dense_unrel05.grm.id:md5,ca8c0bded6951fdd3bf0dddc97b6df6b", - "tiny_dense_unrel05.grm.bin:md5,b1f124463eecbae86840a6651eec372d", - "tiny_dense_unrel05.grm.N.bin:md5,06b73ea8bae8f1e5f5d4de33dbd2c75e" + "tiny_dense.part_1_1_unrel05.grm.id:md5,ca8c0bded6951fdd3bf0dddc97b6df6b", + "tiny_dense.part_1_1_unrel05.grm.bin:md5,b1f124463eecbae86840a6651eec372d", + "tiny_dense.part_1_1_unrel05.grm.N.bin:md5,06b73ea8bae8f1e5f5d4de33dbd2c75e" ] ], [ [ { - "id": "tiny_dense" + "id": "tiny_dense.part_1_1" }, - "tiny_dense_unrel05.grm.id:md5,ca8c0bded6951fdd3bf0dddc97b6df6b" + "tiny_dense.part_1_1_unrel05.grm.id:md5,ca8c0bded6951fdd3bf0dddc97b6df6b" ] ], { @@ -33,26 +33,26 @@ "nf-test": "0.9.3", "nextflow": "25.10.4" }, - "timestamp": "2026-03-21T18:41:51.827057425" + "timestamp": "2026-03-21T20:33:54.318908345" }, "homo_sapiens popgen - remove related individuals from dense GRM - stub": { "content": [ [ [ { - "id": "stub_dense" + "id": "stub_dense.part_1_1" }, - "stub_dense_unrel05.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e", - "stub_dense_unrel05.grm.bin:md5,d41d8cd98f00b204e9800998ecf8427e", - "stub_dense_unrel05.grm.N.bin:md5,d41d8cd98f00b204e9800998ecf8427e" + "stub_dense.part_1_1_unrel05.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e", + "stub_dense.part_1_1_unrel05.grm.bin:md5,d41d8cd98f00b204e9800998ecf8427e", + "stub_dense.part_1_1_unrel05.grm.N.bin:md5,d41d8cd98f00b204e9800998ecf8427e" ] ], [ [ { - "id": "stub_dense" + "id": "stub_dense.part_1_1" }, - "stub_dense_unrel05.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e" + "stub_dense.part_1_1_unrel05.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e" ] ], { @@ -69,6 +69,6 @@ "nf-test": "0.9.3", "nextflow": "25.10.4" }, - "timestamp": "2026-03-21T18:42:16.0502909" + "timestamp": "2026-03-21T20:34:22.18319806" } } \ No newline at end of file From 920fa15fa626ae84ebb61210d78abc057161d9e9 Mon Sep 17 00:00:00 2001 From: lyh970817 Date: Sat, 16 May 2026 15:51:56 +0800 Subject: [PATCH 5/5] Use makegrm setup for gcta/removerelatedsubjects --- modules/nf-core/gcta/makegrm/environment.yml | 7 + modules/nf-core/gcta/makegrm/main.nf | 42 ++++++ modules/nf-core/gcta/makegrm/meta.yml | 91 +++++++++++ .../nf-core/gcta/makegrm/tests/main.nf.test | 142 ++++++++++++++++++ .../gcta/makegrm/tests/main.nf.test.snap | 111 ++++++++++++++ .../gcta/makegrm/tests/nextflow.config | 3 + .../gcta/removerelatedsubjects/main.nf | 17 ++- .../gcta/removerelatedsubjects/meta.yml | 44 ++---- .../removerelatedsubjects/tests/main.nf.test | 60 +++----- .../tests/main.nf.test.snap | 32 ++-- 10 files changed, 462 insertions(+), 87 deletions(-) create mode 100644 modules/nf-core/gcta/makegrm/environment.yml create mode 100644 modules/nf-core/gcta/makegrm/main.nf create mode 100644 modules/nf-core/gcta/makegrm/meta.yml create mode 100644 modules/nf-core/gcta/makegrm/tests/main.nf.test create mode 100644 modules/nf-core/gcta/makegrm/tests/main.nf.test.snap create mode 100644 modules/nf-core/gcta/makegrm/tests/nextflow.config diff --git a/modules/nf-core/gcta/makegrm/environment.yml b/modules/nf-core/gcta/makegrm/environment.yml new file mode 100644 index 000000000000..3e22ea7b9f20 --- /dev/null +++ b/modules/nf-core/gcta/makegrm/environment.yml @@ -0,0 +1,7 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json +channels: + - conda-forge + - bioconda +dependencies: + - bioconda::gcta=1.94.1 diff --git a/modules/nf-core/gcta/makegrm/main.nf b/modules/nf-core/gcta/makegrm/main.nf new file mode 100644 index 000000000000..0bb78639e361 --- /dev/null +++ b/modules/nf-core/gcta/makegrm/main.nf @@ -0,0 +1,42 @@ +process GCTA_MAKEGRM { + tag "${meta.id}" + label 'process_medium' + conda "${moduleDir}/environment.yml" + container "${workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container + ? 'https://community-cr-prod.seqera.io/docker/registry/v2/blobs/sha256/46/46b0d05f0daa47561d87d2a9cac5e51edc2c78e26f1bbab439c688386241a274/data' + : 'community.wave.seqera.io/library/gcta:1.94.1--9bc35dc424fcf6e9'}" + + input: + tuple val(meta), path(mfile), path(bed_pgen), path(bim_pvar), path(fam_psam) + + output: + tuple val(meta), path("*.grm.*"), emit: grm_files + tuple val("${task.process}"), val("gcta"), eval("gcta --version | sed -En 's/^[*] version v([0-9.]*).*/\\1/p'"), emit: versions_gcta, topic: versions + + when: + task.ext.when == null || task.ext.when + + script: + def extra_args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + def genotype_files = bed_pgen instanceof List ? bed_pgen : [bed_pgen] + def genotype_extension = genotype_files[0].name.tokenize('.').last() + def multi_file_flag = genotype_extension == 'pgen' ? '--mpfile' : '--mbfile' + + """ + + gcta \\ + ${multi_file_flag} ${mfile} \\ + --make-grm \\ + --thread-num ${task.cpus} \\ + --out ${prefix} ${extra_args} + """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + """ + touch ${prefix}.grm.id + touch ${prefix}.grm.bin + touch ${prefix}.grm.N.bin + """ +} diff --git a/modules/nf-core/gcta/makegrm/meta.yml b/modules/nf-core/gcta/makegrm/meta.yml new file mode 100644 index 000000000000..0c813dadada6 --- /dev/null +++ b/modules/nf-core/gcta/makegrm/meta.yml @@ -0,0 +1,91 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json +name: "gcta_makegrm" +description: Compute a whole dense GRM with GCTA +keywords: + - gcta + - genome-wide complex trait analysis + - grm + - genetic relationship matrix + - genetics +tools: + - "gcta": + description: "GCTA is a tool for genome-wide complex trait analysis." + homepage: "https://yanglab.westlake.edu.cn/software/gcta/" + documentation: "https://yanglab.westlake.edu.cn/software/gcta/static/gcta_doc_latest.pdf" + tool_dev_url: "https://github.com/jianyangqt/gcta" + licence: + - "GPL-3.0-only" + identifier: biotools:gcta + +input: + - - meta: + type: map + description: | + Groovy Map containing GRM sample metadata + e.g. `[ id:'gcta_grm' ]` + - mfile: + type: file + description: GCTA multi-input manifest consumed by `--mbfile` or + `--mpfile` + pattern: "*.{mbfile,mpfile,txt}" + ontologies: + - edam: "http://edamontology.org/format_2330" + - bed_pgen: + type: file + description: Collection of PLINK primary genotype files referenced by the + multi-input manifest + pattern: "*.{bed,pgen}" + ontologies: + - edam: "http://edamontology.org/format_3003" + - bim_pvar: + type: file + description: Collection of PLINK variant metadata files referenced by the + multi-input manifest + pattern: "*.{bim,pvar}" + ontologies: [] + - fam_psam: + type: file + description: Collection of PLINK sample metadata files referenced by the + multi-input manifest + pattern: "*.{fam,psam}" + ontologies: [] + +output: + grm_files: + - - meta: + type: map + description: | + Groovy Map containing GRM sample metadata + e.g. `[ id:'gcta_grm' ]` + - "*.grm.*": + type: file + description: Dense GRM sidecar files + pattern: "*.grm.{id,bin,N.bin}" + ontologies: [] + versions_gcta: + - - ${task.process}: + type: string + description: The process the version was collected from + - gcta: + type: string + description: The tool name + - "gcta --version | sed -En 's/^[*] version v([0-9.]*).*/\\1/p'": + type: eval + description: The command used to generate the version of the tool + +topics: + versions: + - - ${task.process}: + type: string + description: The process the versions were collected from + - gcta: + type: string + description: The tool name + - "gcta --version | sed -En 's/^[*] version v([0-9.]*).*/\\1/p'": + type: eval + description: The command used to generate the version of the tool + +authors: + - "@lyh970817" +maintainers: + - "@lyh970817" diff --git a/modules/nf-core/gcta/makegrm/tests/main.nf.test b/modules/nf-core/gcta/makegrm/tests/main.nf.test new file mode 100644 index 000000000000..e5c63233678b --- /dev/null +++ b/modules/nf-core/gcta/makegrm/tests/main.nf.test @@ -0,0 +1,142 @@ +nextflow_process { + + name "Test Process GCTA_MAKEGRM" + script "../main.nf" + process "GCTA_MAKEGRM" + + tag "modules" + tag "modules_nfcore" + tag "gcta" + tag "gcta/makegrm" + + test("homo_sapiens popgen - plink2") { + when { + process { + """ + file('gcta_grm.mpfile').text = 'plink_simulated plink_simulated.pgen plink_simulated.psam plink_simulated.pvar\\n' + + input[0] = [ + [ id:'gcta_grm' ], + file('gcta_grm.mpfile'), + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.pgen', checkIfExists: true) + ], + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.pvar', checkIfExists: true) + ], + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.psam', checkIfExists: true) + ] + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert process.out.grm_files.size() == 1 }, + { assert process.out.grm_files.get(0).get(0).id == 'gcta_grm' }, + { assert process.out.grm_files.get(0).get(0).keySet() == ['id'] as Set }, + { assert process.out.grm_files.get(0).get(1).size() == 3 }, + { + assert process.out.grm_files.get(0).get(1).collect { file(it).name }.toSet() == [ + 'gcta_grm.grm.id', + 'gcta_grm.grm.bin', + 'gcta_grm.grm.N.bin' + ] as Set + }, + { assert file(path(process.out.grm_files.get(0).get(1)[0]).parent.toString() + '/.command.sh').text.contains('--make-grm') }, + { assert file(path(process.out.grm_files.get(0).get(1)[0]).parent.toString() + '/.command.sh').text.contains('--mpfile') }, + { + assert snapshot( + process.out.grm_files, + process.out.findAll { key, val -> key.startsWith('versions') } + ).match() + } + ) + } + } + + test("homo_sapiens popgen - plink1") { + when { + process { + """ + file('gcta_grm.mbfile').text = 'plink_simulated\\n' + + input[0] = [ + [ id:'gcta_grm_bed' ], + file('gcta_grm.mbfile'), + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bed', checkIfExists: true) + ], + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true) + ], + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.fam', checkIfExists: true) + ] + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert process.out.grm_files.size() == 1 }, + { assert process.out.grm_files.get(0).get(0).id == 'gcta_grm_bed' }, + { assert process.out.grm_files.get(0).get(0).keySet() == ['id'] as Set }, + { assert process.out.grm_files.get(0).get(1).size() == 3 }, + { + assert process.out.grm_files.get(0).get(1).collect { file(it).name }.toSet() == [ + 'gcta_grm_bed.grm.id', + 'gcta_grm_bed.grm.bin', + 'gcta_grm_bed.grm.N.bin' + ] as Set + }, + { assert file(path(process.out.grm_files.get(0).get(1)[0]).parent.toString() + '/.command.sh').text.contains('--make-grm') }, + { assert file(path(process.out.grm_files.get(0).get(1)[0]).parent.toString() + '/.command.sh').text.contains('--mbfile') }, + { + assert snapshot( + process.out.grm_files, + process.out.findAll { key, val -> key.startsWith('versions') } + ).match() + } + ) + } + } + + test("homo_sapiens popgen - plink1 - stub") { + options "-stub" + + when { + process { + """ + file('gcta_grm.mbfile').text = 'plink_simulated\\n' + + input[0] = [ + [ id:'gcta_grm_bed' ], + file('gcta_grm.mbfile'), + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bed', checkIfExists: true) + ], + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true) + ], + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.fam', checkIfExists: true) + ] + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } +} diff --git a/modules/nf-core/gcta/makegrm/tests/main.nf.test.snap b/modules/nf-core/gcta/makegrm/tests/main.nf.test.snap new file mode 100644 index 000000000000..f8fbe133d5a2 --- /dev/null +++ b/modules/nf-core/gcta/makegrm/tests/main.nf.test.snap @@ -0,0 +1,111 @@ +{ + "homo_sapiens popgen - plink2": { + "content": [ + [ + [ + { + "id": "gcta_grm" + }, + [ + "gcta_grm.grm.N.bin:md5,acaa43bbbf2253d392537a178ecf09a4", + "gcta_grm.grm.bin:md5,45f8dff14bda17d50009a21050572228", + "gcta_grm.grm.id:md5,4f9aa36c44a417ff6d7caa9841e66ad9" + ] + ] + ], + { + "versions_gcta": [ + [ + "GCTA_MAKEGRM", + "gcta", + "1.94.1" + ] + ] + } + ], + "meta": { + "nf-test": "0.9.3", + "nextflow": "25.10.4" + }, + "timestamp": "2026-05-15T21:08:43.209734458" + }, + "homo_sapiens popgen - plink1": { + "content": [ + [ + [ + { + "id": "gcta_grm_bed" + }, + [ + "gcta_grm_bed.grm.N.bin:md5,acaa43bbbf2253d392537a178ecf09a4", + "gcta_grm_bed.grm.bin:md5,45f8dff14bda17d50009a21050572228", + "gcta_grm_bed.grm.id:md5,4f9aa36c44a417ff6d7caa9841e66ad9" + ] + ] + ], + { + "versions_gcta": [ + [ + "GCTA_MAKEGRM", + "gcta", + "1.94.1" + ] + ] + } + ], + "meta": { + "nf-test": "0.9.3", + "nextflow": "25.10.4" + }, + "timestamp": "2026-05-15T21:09:34.058651287" + }, + "homo_sapiens popgen - plink1 - stub": { + "content": [ + { + "0": [ + [ + { + "id": "gcta_grm_bed" + }, + [ + "gcta_grm_bed.grm.N.bin:md5,d41d8cd98f00b204e9800998ecf8427e", + "gcta_grm_bed.grm.bin:md5,d41d8cd98f00b204e9800998ecf8427e", + "gcta_grm_bed.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ] + ], + "1": [ + [ + "GCTA_MAKEGRM", + "gcta", + "1.94.1" + ] + ], + "grm_files": [ + [ + { + "id": "gcta_grm_bed" + }, + [ + "gcta_grm_bed.grm.N.bin:md5,d41d8cd98f00b204e9800998ecf8427e", + "gcta_grm_bed.grm.bin:md5,d41d8cd98f00b204e9800998ecf8427e", + "gcta_grm_bed.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ] + ], + "versions_gcta": [ + [ + "GCTA_MAKEGRM", + "gcta", + "1.94.1" + ] + ] + } + ], + "meta": { + "nf-test": "0.9.3", + "nextflow": "25.10.4" + }, + "timestamp": "2026-05-15T21:10:21.024687128" + } +} \ No newline at end of file diff --git a/modules/nf-core/gcta/makegrm/tests/nextflow.config b/modules/nf-core/gcta/makegrm/tests/nextflow.config new file mode 100644 index 000000000000..de31e0218829 --- /dev/null +++ b/modules/nf-core/gcta/makegrm/tests/nextflow.config @@ -0,0 +1,3 @@ +params { + modules_testdata_base_path = System.getenv("NF_MODULES_TESTDATA_BASE_PATH") ?: "https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/" +} diff --git a/modules/nf-core/gcta/removerelatedsubjects/main.nf b/modules/nf-core/gcta/removerelatedsubjects/main.nf index c1e3e3862af5..539e2cf4ae69 100644 --- a/modules/nf-core/gcta/removerelatedsubjects/main.nf +++ b/modules/nf-core/gcta/removerelatedsubjects/main.nf @@ -2,33 +2,34 @@ process GCTA_REMOVERELATEDSUBJECTS { tag "${meta.id}" label 'process_medium' conda "${moduleDir}/environment.yml" - container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? - 'docker://community.wave.seqera.io/library/gcta:1.94.1--9bc35dc424fcf6e9' : - 'community.wave.seqera.io/library/gcta:1.94.1--9bc35dc424fcf6e9' }" + container "${workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container + ? 'https://community-cr-prod.seqera.io/docker/registry/v2/blobs/sha256/46/46b0d05f0daa47561d87d2a9cac5e51edc2c78e26f1bbab439c688386241a274/data' + : 'community.wave.seqera.io/library/gcta:1.94.1--9bc35dc424fcf6e9'}" input: - tuple val(meta), path(grm_id), path(grm_bin), path(grm_n_bin) + tuple val(meta), path(grm_files) output: - tuple val(meta), path("*_unrel05.grm.id"), path("*_unrel05.grm.bin"), path("*_unrel05.grm.N.bin"), emit: grm_files + tuple val(meta), path("*_unrel05.grm.*"), emit: grm_files tuple val(meta), path("*_unrel05.grm.id"), emit: keep_file - tuple val("${task.process}"), val("gcta"), eval("gcta --version 2>&1 | grep 'version v' | tr -s ' ' | cut -d' ' -f3 | sed 's/^v//'"), emit: versions_gcta, topic: versions + tuple val("${task.process}"), val("gcta"), eval("gcta --version | sed -En 's/^[*] version v([0-9.]*).*/\\1/p'"), emit: versions_gcta, topic: versions when: task.ext.when == null || task.ext.when script: - def args = task.ext.args ?: '' + def extra_args = task.ext.args ?: '' def prefix = task.ext.prefix ?: "${meta.id}" """ + gcta \\ --grm ${meta.id} \\ --grm-cutoff 0.05 \\ --make-grm \\ --out ${prefix}_unrel05 \\ --thread-num ${task.cpus} \\ - ${args} + ${extra_args} """ stub: diff --git a/modules/nf-core/gcta/removerelatedsubjects/meta.yml b/modules/nf-core/gcta/removerelatedsubjects/meta.yml index 666490912aad..17b4ff7f298a 100644 --- a/modules/nf-core/gcta/removerelatedsubjects/meta.yml +++ b/modules/nf-core/gcta/removerelatedsubjects/meta.yml @@ -3,7 +3,9 @@ name: "gcta_removerelatedsubjects" description: Remove related individuals from a dense GRM using `gcta --grm-cutoff` keywords: - gcta + - genome-wide complex trait analysis - grm + - genetic relationship matrix - genetics tools: - "gcta": @@ -11,6 +13,8 @@ tools: homepage: "https://yanglab.westlake.edu.cn/software/gcta/" documentation: "https://yanglab.westlake.edu.cn/software/gcta/static/gcta_doc_latest.pdf" tool_dev_url: "https://yanglab.westlake.edu.cn/software/gcta/" + licence: ["GPL-3.0-only"] + identifier: "biotools:gcta" input: - - meta: @@ -21,20 +25,10 @@ input: the staged dense GRM files. e.g. `[ id:'tiny_dense' ]` requires `tiny_dense.grm.id`, `tiny_dense.grm.bin`, and `tiny_dense.grm.N.bin`. - - grm_id: + - grm_files: type: file - description: Dense GRM sample identifier file with basename `${meta.id}` - pattern: "*.grm.id" - ontologies: [] - - grm_bin: - type: file - description: Dense GRM binary matrix file with basename `${meta.id}` - pattern: "*.grm.bin" - ontologies: [] - - grm_n_bin: - type: file - description: Dense GRM sample-count matrix file with basename `${meta.id}` - pattern: "*.grm.N.bin" + description: Dense GRM file bundle with basename `${meta.id}` + pattern: "*.grm.*" ontologies: [] output: @@ -44,20 +38,10 @@ output: description: | Groovy map containing dense GRM metadata. `meta.id` remains the dense-GRM basename contract used for `--grm`. - - "*_unrel05.grm.id": - type: file - description: Relatedness-filtered GRM sample identifier file - pattern: "*_unrel05.grm.id" - ontologies: [] - - "*_unrel05.grm.bin": - type: file - description: Relatedness-filtered GRM binary matrix file - pattern: "*_unrel05.grm.bin" - ontologies: [] - - "*_unrel05.grm.N.bin": + - "*_unrel05.grm.*": type: file - description: Relatedness-filtered GRM sample-count matrix file - pattern: "*_unrel05.grm.N.bin" + description: Relatedness-filtered GRM file bundle + pattern: "*_unrel05.grm.*" ontologies: [] keep_file: - - meta: @@ -77,7 +61,7 @@ output: - "gcta": type: string description: The tool name - - "gcta --version 2>&1 | grep 'version v' | tr -s ' ' | cut -d' ' -f3 | sed 's/^v//'": + - "gcta --version | sed -En 's/^[*] version v([0-9.]*).*/\\1/p'": type: eval description: The command used to retrieve the GCTA version @@ -89,11 +73,11 @@ topics: - gcta: type: string description: The tool name - - gcta --version 2>&1 | grep 'version v' | tr -s ' ' | cut -d' ' -f3 | sed 's/^v//': + - "gcta --version | sed -En 's/^[*] version v([0-9.]*).*/\\1/p'": type: eval description: The command used to retrieve the GCTA version authors: - - "@andongni" + - "@lyh970817" maintainers: - - "@andongni" + - "@lyh970817" diff --git a/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test b/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test index 291a8ee2331e..722026e4c982 100644 --- a/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test +++ b/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test @@ -8,17 +8,17 @@ nextflow_process { tag "modules_nfcore" tag "gcta" tag "gcta/removerelatedsubjects" - tag "gcta/makegrmpart" + tag "gcta/makegrm" setup { - run("GCTA_MAKEGRMPART", alias: "GCTA_MAKEGRMPART_CONTRACT") { - script "../../makegrmpart/main.nf" + run("GCTA_MAKEGRM", alias: "GCTA_MAKEGRM_CONTRACT") { + script "../../makegrm/main.nf" process { """ file('tiny_dense.mbfile').text = 'plink_simulated\\n' input[0] = [ - [ id:'tiny_dense', part_gcta_job:1, nparts_gcta:1 ], + [ id:'tiny_dense' ], file('tiny_dense.mbfile'), [ file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bed', checkIfExists: true) @@ -30,19 +30,18 @@ nextflow_process { file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.fam', checkIfExists: true) ] ] - input[1] = [[ id:'all_variants' ], []] """ } } - run("GCTA_MAKEGRMPART", alias: "GCTA_MAKEGRMPART_STUB") { - script "../../makegrmpart/main.nf" + run("GCTA_MAKEGRM", alias: "GCTA_MAKEGRM_STUB") { + script "../../makegrm/main.nf" process { """ file('stub_dense.mbfile').text = 'plink_simulated\\n' input[0] = [ - [ id:'stub_dense', part_gcta_job:1, nparts_gcta:1 ], + [ id:'stub_dense' ], file('stub_dense.mbfile'), [ file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bed', checkIfExists: true) @@ -54,7 +53,6 @@ nextflow_process { file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.fam', checkIfExists: true) ] ] - input[1] = [[ id:'all_variants' ], []] """ } } @@ -66,10 +64,7 @@ nextflow_process { when { process { """ - input[0] = GCTA_MAKEGRMPART_CONTRACT.out.grm_files.map { meta, grm_id, grm_bin, grm_n_bin -> - def prefix = meta.id + '.part_' + meta.nparts_gcta + '_' + meta.part_gcta_job - [[ id:prefix ], grm_id, grm_bin, grm_n_bin] - } + input[0] = GCTA_MAKEGRM_CONTRACT.out.grm_files """ } } @@ -79,13 +74,15 @@ nextflow_process { { assert process.success }, { assert process.out.grm_files.size() == 1 }, { assert process.out.keep_file.size() == 1 }, - { assert process.out.grm_files.get(0).get(0).id == "tiny_dense.part_1_1" }, + { assert process.out.grm_files.get(0).get(0).id == "tiny_dense" }, { def grm_row = process.out.grm_files.get(0) def expected_prefix = "${grm_row.get(0).id}_unrel05" - assert file(grm_row.get(1)).name == "${expected_prefix}.grm.id" - assert file(grm_row.get(2)).name == "${expected_prefix}.grm.bin" - assert file(grm_row.get(3)).name == "${expected_prefix}.grm.N.bin" + assert grm_row.get(1).collect { file(it).name }.sort() == [ + "${expected_prefix}.grm.N.bin", + "${expected_prefix}.grm.bin", + "${expected_prefix}.grm.id" + ] assert file(process.out.keep_file.get(0).get(1)).name == "${expected_prefix}.grm.id" }, { @@ -105,11 +102,8 @@ nextflow_process { when { process { """ - input[0] = GCTA_MAKEGRMPART_CONTRACT.out.grm_files.map { meta, grm_id, grm_bin, grm_n_bin -> - def prefix = meta.id + '.part_' + meta.nparts_gcta + '_' + meta.part_gcta_job - [[ id:prefix ], grm_id, grm_bin, grm_n_bin] - }.map { meta, grm_id, grm_bin, grm_n_bin -> - [[ id:'tiny_dense_mismatched' ], grm_id, grm_bin, grm_n_bin] + input[0] = GCTA_MAKEGRM_CONTRACT.out.grm_files.map { meta, grm_files -> + [[ id:'tiny_dense_mismatched' ], grm_files] } """ } @@ -129,11 +123,8 @@ nextflow_process { when { process { """ - input[0] = GCTA_MAKEGRMPART_CONTRACT.out.grm_files.map { meta, grm_id, grm_bin, grm_n_bin -> - def prefix = meta.id + '.part_' + meta.nparts_gcta + '_' + meta.part_gcta_job - [[ id:prefix ], grm_id, grm_bin, grm_n_bin] - }.map { meta, grm_id, grm_bin, grm_n_bin -> - [[ id:meta.id ], grm_id, grm_bin] + input[0] = GCTA_MAKEGRM_CONTRACT.out.grm_files.map { meta, grm_files -> + [[ id:meta.id ]] } """ } @@ -151,10 +142,7 @@ nextflow_process { when { process { """ - input[0] = GCTA_MAKEGRMPART_STUB.out.grm_files.map { meta, grm_id, grm_bin, grm_n_bin -> - def prefix = meta.id + '.part_' + meta.nparts_gcta + '_' + meta.part_gcta_job - [[ id:prefix ], grm_id, grm_bin, grm_n_bin] - } + input[0] = GCTA_MAKEGRM_STUB.out.grm_files """ } } @@ -162,13 +150,15 @@ nextflow_process { then { assertAll( { assert process.success }, - { assert process.out.grm_files.get(0).get(0).id == "stub_dense.part_1_1" }, + { assert process.out.grm_files.get(0).get(0).id == "stub_dense" }, { def grm_row = process.out.grm_files.get(0) def expected_prefix = "${grm_row.get(0).id}_unrel05" - assert file(grm_row.get(1)).name == "${expected_prefix}.grm.id" - assert file(grm_row.get(2)).name == "${expected_prefix}.grm.bin" - assert file(grm_row.get(3)).name == "${expected_prefix}.grm.N.bin" + assert grm_row.get(1).collect { file(it).name }.sort() == [ + "${expected_prefix}.grm.N.bin", + "${expected_prefix}.grm.bin", + "${expected_prefix}.grm.id" + ] assert file(process.out.keep_file.get(0).get(1)).name == "${expected_prefix}.grm.id" }, { diff --git a/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test.snap b/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test.snap index 9d0a7d2e6874..1c3d480ba739 100644 --- a/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test.snap +++ b/modules/nf-core/gcta/removerelatedsubjects/tests/main.nf.test.snap @@ -4,19 +4,21 @@ [ [ { - "id": "tiny_dense.part_1_1" + "id": "tiny_dense" }, - "tiny_dense.part_1_1_unrel05.grm.id:md5,ca8c0bded6951fdd3bf0dddc97b6df6b", - "tiny_dense.part_1_1_unrel05.grm.bin:md5,b1f124463eecbae86840a6651eec372d", - "tiny_dense.part_1_1_unrel05.grm.N.bin:md5,06b73ea8bae8f1e5f5d4de33dbd2c75e" + [ + "tiny_dense_unrel05.grm.N.bin:md5,06b73ea8bae8f1e5f5d4de33dbd2c75e", + "tiny_dense_unrel05.grm.bin:md5,b1f124463eecbae86840a6651eec372d", + "tiny_dense_unrel05.grm.id:md5,ca8c0bded6951fdd3bf0dddc97b6df6b" + ] ] ], [ [ { - "id": "tiny_dense.part_1_1" + "id": "tiny_dense" }, - "tiny_dense.part_1_1_unrel05.grm.id:md5,ca8c0bded6951fdd3bf0dddc97b6df6b" + "tiny_dense_unrel05.grm.id:md5,ca8c0bded6951fdd3bf0dddc97b6df6b" ] ], { @@ -33,26 +35,28 @@ "nf-test": "0.9.3", "nextflow": "25.10.4" }, - "timestamp": "2026-03-21T20:33:54.318908345" + "timestamp": "2026-05-15T22:50:50.597885689" }, "homo_sapiens popgen - remove related individuals from dense GRM - stub": { "content": [ [ [ { - "id": "stub_dense.part_1_1" + "id": "stub_dense" }, - "stub_dense.part_1_1_unrel05.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e", - "stub_dense.part_1_1_unrel05.grm.bin:md5,d41d8cd98f00b204e9800998ecf8427e", - "stub_dense.part_1_1_unrel05.grm.N.bin:md5,d41d8cd98f00b204e9800998ecf8427e" + [ + "stub_dense_unrel05.grm.N.bin:md5,d41d8cd98f00b204e9800998ecf8427e", + "stub_dense_unrel05.grm.bin:md5,d41d8cd98f00b204e9800998ecf8427e", + "stub_dense_unrel05.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e" + ] ] ], [ [ { - "id": "stub_dense.part_1_1" + "id": "stub_dense" }, - "stub_dense.part_1_1_unrel05.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e" + "stub_dense_unrel05.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e" ] ], { @@ -69,6 +73,6 @@ "nf-test": "0.9.3", "nextflow": "25.10.4" }, - "timestamp": "2026-03-21T20:34:22.18319806" + "timestamp": "2026-05-15T22:55:53.542534458" } } \ No newline at end of file