Skip to content

Commit 7284bc8

Browse files
committed
test(gcta/addgrms): stabilize GRM fixture setup
1 parent 43681c3 commit 7284bc8

3 files changed

Lines changed: 102 additions & 79 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
process GCTA_TEST_MAKEGRM {
2+
tag "${meta.id}"
3+
label "process_medium"
4+
conda "${moduleDir}/../../../environment.yml"
5+
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
6+
'docker://community.wave.seqera.io/library/gcta:1.94.1--9bc35dc424fcf6e9' :
7+
'community.wave.seqera.io/library/gcta:1.94.1--9bc35dc424fcf6e9' }"
8+
9+
input:
10+
tuple val(meta), path(bed), path(bim), path(fam), path(extract_variants)
11+
12+
output:
13+
tuple val(meta), path("${meta.id}.part_1_1.grm.id"), path("${meta.id}.part_1_1.grm.bin"), path("${meta.id}.part_1_1.grm.N.bin"), emit: grm_files
14+
15+
script:
16+
def bfile_prefix = bed.name.replaceFirst(/\.bed$/, "")
17+
def out_prefix = "${meta.id}.part_1_1"
18+
19+
"""
20+
set -euo pipefail
21+
22+
gcta \\
23+
--bfile ${bfile_prefix} \\
24+
--extract ${extract_variants} \\
25+
--make-grm \\
26+
--out ${out_prefix} \\
27+
--thread-num ${task.cpus}
28+
"""
29+
30+
stub:
31+
def out_prefix = "${meta.id}.part_1_1"
32+
33+
"""
34+
touch ${out_prefix}.grm.id
35+
touch ${out_prefix}.grm.bin
36+
touch ${out_prefix}.grm.N.bin
37+
"""
38+
}

modules/nf-core/gcta/addgrms/tests/main.nf.test

Lines changed: 51 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -8,74 +8,68 @@ nextflow_process {
88
tag "modules_nfcore"
99
tag "gcta"
1010
tag "gcta/addgrms"
11-
tag "gcta/makegrmpart"
1211
tag "gawk"
12+
tag "gcta/testhelpers"
1313

1414
setup {
15-
run("GAWK", alias: "GAWK_COMPLEMENT_VARIANTS") {
15+
run("GAWK", alias: "GAWK_VARIANTS_LDMS1") {
1616
script "../../../gawk/main.nf"
1717
process {
1818
"""
1919
input[0] = [
20-
[ id:'plink_simulated_complement' ],
21-
[
22-
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_random_selected_snp.txt', checkIfExists: true),
23-
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true)
24-
]
20+
[ id:'plink_simulated_ldms1_variants' ],
21+
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true)
2522
]
26-
input[1] = Channel.of('FNR == NR { keep[\$1] = 1; next } !(\$2 in keep) { print \$2 }').collectFile(name:'complement_variants.awk')
23+
input[1] = Channel.of('NR <= 110 { print \$2 }').collectFile(name:'ldms1_variants.awk')
2724
input[2] = false
2825
"""
2926
}
3027
}
3128

32-
run("GCTA_MAKEGRMPART", alias: "GCTA_MAKEGRMPART_LDMS1") {
33-
script "../../makegrmpart/main.nf"
29+
run("GAWK", alias: "GAWK_VARIANTS_LDMS2") {
30+
script "../../../gawk/main.nf"
3431
process {
3532
"""
36-
file('plink_simulated.mbfile').text = 'plink_simulated\\n'
37-
3833
input[0] = [
39-
[ id:'plink_simulated_ldms1', part_gcta_job:1, nparts_gcta:1 ],
40-
file('plink_simulated.mbfile'),
41-
[
42-
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bed', checkIfExists: true)
43-
],
44-
[
45-
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true)
46-
],
47-
[
48-
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.fam', checkIfExists: true)
49-
]
50-
]
51-
input[1] = [
52-
[ id:'plink_random_selected_snp' ],
53-
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_random_selected_snp.txt', checkIfExists: true)
34+
[ id:'plink_simulated_ldms2_variants' ],
35+
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true)
5436
]
37+
input[1] = Channel.of('NR > 110 { print \$2 }').collectFile(name:'ldms2_variants.awk')
38+
input[2] = false
5539
"""
5640
}
5741
}
5842

59-
run("GCTA_MAKEGRMPART", alias: "GCTA_MAKEGRMPART_LDMS2") {
60-
script "../../makegrmpart/main.nf"
43+
run("GCTA_TEST_MAKEGRM", alias: "GCTA_TEST_MAKEGRM_LDMS1") {
44+
script "./helpers/gcta_makegrm/main.nf"
6145
process {
6246
"""
63-
file('plink_simulated.mbfile').text = 'plink_simulated\\n'
64-
65-
input[0] = [
66-
[ id:'plink_simulated_ldms2', part_gcta_job:1, nparts_gcta:1 ],
67-
file('plink_simulated.mbfile'),
47+
input[0] = GAWK_VARIANTS_LDMS1.out.output.map { meta, ldms1_variants_file ->
6848
[
69-
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bed', checkIfExists: true)
70-
],
71-
[
72-
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true)
73-
],
49+
[ id:'plink_simulated_ldms1' ],
50+
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bed', checkIfExists: true),
51+
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true),
52+
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.fam', checkIfExists: true),
53+
ldms1_variants_file
54+
]
55+
}
56+
"""
57+
}
58+
}
59+
60+
run("GCTA_TEST_MAKEGRM", alias: "GCTA_TEST_MAKEGRM_LDMS2") {
61+
script "./helpers/gcta_makegrm/main.nf"
62+
process {
63+
"""
64+
input[0] = GAWK_VARIANTS_LDMS2.out.output.map { meta, ldms2_variants_file ->
7465
[
75-
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.fam', checkIfExists: true)
66+
[ id:'plink_simulated_ldms2' ],
67+
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bed', checkIfExists: true),
68+
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true),
69+
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.fam', checkIfExists: true),
70+
ldms2_variants_file
7671
]
77-
]
78-
input[1] = GAWK_COMPLEMENT_VARIANTS.out.output
72+
}
7973
"""
8074
}
8175
}
@@ -91,11 +85,11 @@ nextflow_process {
9185
.of('plink_simulated_ldms1.part_1_1\\nplink_simulated_ldms2.part_1_1')
9286
.collectFile(name:'plink_simulated_ldms.mgrm', newLine: true)
9387

94-
grm_files = GCTA_MAKEGRMPART_LDMS1.out.grm_files
95-
.mix(GCTA_MAKEGRMPART_LDMS2.out.grm_files)
88+
grm_files = GCTA_TEST_MAKEGRM_LDMS1.out.grm_files
89+
.mix(GCTA_TEST_MAKEGRM_LDMS2.out.grm_files)
9690
.map { meta, grm_id, grm_bin, grm_n_bin -> [grm_id, grm_bin, grm_n_bin] }
9791
.collect()
98-
.map { rows -> rows.flatten() }
92+
.map { rows -> rows.sort { left, right -> left[0].name <=> right[0].name }.flatten() }
9993

10094
input[0] = mgrm_file
10195
.combine(grm_files)
@@ -109,6 +103,7 @@ nextflow_process {
109103
{ assert process.success },
110104
{ assert process.out.combined_grm.size() == 1 },
111105
{ assert process.out.combined_grm.get(0).get(0).id == "plink_simulated_ldms" },
106+
{ assert file(process.out.combined_grm.get(0).get(1)).name == "plink_simulated_ldms.grm.id" },
112107
{
113108
assert snapshot(
114109
process.out.combined_grm,
@@ -130,11 +125,11 @@ nextflow_process {
130125
.of('plink_simulated_ldms1.part_1_1\\nplink_simulated_ldms2.part_1_1')
131126
.collectFile(name:'plink_simulated_ldms.mgrm', newLine: true)
132127

133-
grm_files = GCTA_MAKEGRMPART_LDMS1.out.grm_files
134-
.mix(GCTA_MAKEGRMPART_LDMS2.out.grm_files)
128+
grm_files = GCTA_TEST_MAKEGRM_LDMS1.out.grm_files
129+
.mix(GCTA_TEST_MAKEGRM_LDMS2.out.grm_files)
135130
.map { meta, grm_id, grm_bin, grm_n_bin -> [grm_id, grm_bin, grm_n_bin] }
136131
.collect()
137-
.map { rows -> rows.flatten() }
132+
.map { rows -> rows.sort { left, right -> left[0].name <=> right[0].name }.flatten() }
138133

139134
input[0] = mgrm_file
140135
.combine(grm_files)
@@ -146,7 +141,14 @@ nextflow_process {
146141
then {
147142
assertAll(
148143
{ assert process.success },
149-
{ assert snapshot(process.out).match() }
144+
{ assert process.out.combined_grm.size() == 1 },
145+
{ assert process.out.combined_grm.get(0).get(0).id == "plink_simulated_ldms" },
146+
{
147+
assert snapshot(
148+
process.out.combined_grm,
149+
process.out.findAll { key, val -> key.startsWith('versions') }
150+
).match()
151+
}
150152
)
151153
}
152154
}
Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,17 @@
11
{
22
"homo_sapiens popgen - merge dense GRMs from mgrm - stub": {
33
"content": [
4+
[
5+
[
6+
{
7+
"id": "plink_simulated_ldms"
8+
},
9+
"plink_simulated_ldms.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e",
10+
"plink_simulated_ldms.grm.bin:md5,d41d8cd98f00b204e9800998ecf8427e",
11+
"plink_simulated_ldms.grm.N.bin:md5,d41d8cd98f00b204e9800998ecf8427e"
12+
]
13+
],
414
{
5-
"0": [
6-
[
7-
{
8-
"id": "plink_simulated_ldms"
9-
},
10-
"plink_simulated_ldms.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e",
11-
"plink_simulated_ldms.grm.bin:md5,d41d8cd98f00b204e9800998ecf8427e",
12-
"plink_simulated_ldms.grm.N.bin:md5,d41d8cd98f00b204e9800998ecf8427e"
13-
]
14-
],
15-
"1": [
16-
[
17-
"GCTA_ADDGRMS",
18-
"gcta",
19-
"1.94.1"
20-
]
21-
],
22-
"combined_grm": [
23-
[
24-
{
25-
"id": "plink_simulated_ldms"
26-
},
27-
"plink_simulated_ldms.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e",
28-
"plink_simulated_ldms.grm.bin:md5,d41d8cd98f00b204e9800998ecf8427e",
29-
"plink_simulated_ldms.grm.N.bin:md5,d41d8cd98f00b204e9800998ecf8427e"
30-
]
31-
],
3215
"versions_gcta": [
3316
[
3417
"GCTA_ADDGRMS",
@@ -42,7 +25,7 @@
4225
"nf-test": "0.9.3",
4326
"nextflow": "25.10.4"
4427
},
45-
"timestamp": "2026-03-13T14:16:18.17102219"
28+
"timestamp": "2026-03-21T00:42:02.641342626"
4629
},
4730
"homo_sapiens popgen - merge dense GRMs from mgrm": {
4831
"content": [
@@ -52,7 +35,7 @@
5235
"id": "plink_simulated_ldms"
5336
},
5437
"plink_simulated_ldms.grm.id:md5,4f9aa36c44a417ff6d7caa9841e66ad9",
55-
"plink_simulated_ldms.grm.bin:md5,e6a56e44acd03f87043435c382fe0149",
38+
"plink_simulated_ldms.grm.bin:md5,59a9d628e3fb4b9488244048c952b2ca",
5639
"plink_simulated_ldms.grm.N.bin:md5,acaa43bbbf2253d392537a178ecf09a4"
5740
]
5841
],
@@ -70,6 +53,6 @@
7053
"nf-test": "0.9.3",
7154
"nextflow": "25.10.4"
7255
},
73-
"timestamp": "2026-03-13T15:38:05.74494821"
56+
"timestamp": "2026-03-21T00:41:50.805078215"
7457
}
7558
}

0 commit comments

Comments
 (0)