Skip to content

Commit cc1241a

Browse files
committed
test(gcta/makebksparse): generate GRM inputs in setup
1 parent fdea447 commit cc1241a

3 files changed

Lines changed: 72 additions & 45 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
process GCTA_TEST_DENSE_GRM {
2+
tag "${meta.id}"
3+
label "process_medium"
4+
conda "${projectDir}/modules/nf-core/gcta/makebksparse/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)
11+
12+
output:
13+
tuple val(meta), path("${meta.id}.grm.id"), path("${meta.id}.grm.bin"), path("${meta.id}.grm.N.bin"), emit: dense_grm
14+
15+
script:
16+
def bfile_prefix = bed.baseName
17+
"""
18+
set -euo pipefail
19+
20+
gcta \\
21+
--bfile "${bfile_prefix}" \\
22+
--make-grm \\
23+
--out "${meta.id}" \\
24+
--thread-num ${task.cpus}
25+
"""
26+
27+
stub:
28+
"""
29+
touch "${meta.id}.grm.id"
30+
touch "${meta.id}.grm.bin"
31+
touch "${meta.id}.grm.N.bin"
32+
"""
33+
}

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

Lines changed: 36 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,45 @@ nextflow_process {
88
tag "modules_nfcore"
99
tag "gcta"
1010
tag "gcta/makebksparse"
11+
tag "tests/helpers/dense_grm"
12+
13+
setup {
14+
run("GCTA_TEST_DENSE_GRM", alias: "GCTA_TEST_DENSE_GRM_CONTRACT") {
15+
script "../tests/helpers/dense_grm/main.nf"
16+
process {
17+
"""
18+
input[0] = [
19+
[ id:'contract_dense' ],
20+
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bed', checkIfExists: true),
21+
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true),
22+
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.fam', checkIfExists: true)
23+
]
24+
"""
25+
}
26+
}
27+
28+
run("GCTA_TEST_DENSE_GRM", alias: "GCTA_TEST_DENSE_GRM_STUB") {
29+
script "../tests/helpers/dense_grm/main.nf"
30+
process {
31+
"""
32+
input[0] = [
33+
[ id:'stub_dense' ],
34+
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bed', checkIfExists: true),
35+
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true),
36+
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.fam', checkIfExists: true)
37+
]
38+
"""
39+
}
40+
}
41+
}
1142

1243
test("homo_sapiens popgen - create sparse GRM") {
1344
config "./nextflow.config"
1445

1546
when {
1647
process {
1748
"""
18-
file('contract_dense.grm.id').text = "fid1 iid1\\n"
19-
20-
grmBuffer = java.nio.ByteBuffer.allocate(4).order(java.nio.ByteOrder.LITTLE_ENDIAN)
21-
grmBuffer.putFloat(1.0f)
22-
file('contract_dense.grm.bin').bytes = grmBuffer.array()
23-
24-
grmNBuffer = java.nio.ByteBuffer.allocate(4).order(java.nio.ByteOrder.LITTLE_ENDIAN)
25-
grmNBuffer.putFloat(100.0f)
26-
file('contract_dense.grm.N.bin').bytes = grmNBuffer.array()
27-
28-
input[0] = Channel.value([
29-
[ id:'contract_dense' ],
30-
file('contract_dense.grm.id'),
31-
file('contract_dense.grm.bin'),
32-
file('contract_dense.grm.N.bin')
33-
])
49+
input[0] = GCTA_TEST_DENSE_GRM_CONTRACT.out.dense_grm
3450
input[1] = Channel.value(0.05)
3551
"""
3652
}
@@ -53,22 +69,9 @@ nextflow_process {
5369
when {
5470
process {
5571
"""
56-
file('contract_dense.grm.id').text = "fid1 iid1\\n"
57-
58-
grmBuffer = java.nio.ByteBuffer.allocate(4).order(java.nio.ByteOrder.LITTLE_ENDIAN)
59-
grmBuffer.putFloat(1.0f)
60-
file('contract_dense.grm.bin').bytes = grmBuffer.array()
61-
62-
grmNBuffer = java.nio.ByteBuffer.allocate(4).order(java.nio.ByteOrder.LITTLE_ENDIAN)
63-
grmNBuffer.putFloat(100.0f)
64-
file('contract_dense.grm.N.bin').bytes = grmNBuffer.array()
65-
66-
input[0] = Channel.value([
67-
[ id:'contract_dense_mismatch' ],
68-
file('contract_dense.grm.id'),
69-
file('contract_dense.grm.bin'),
70-
file('contract_dense.grm.N.bin')
71-
])
72+
input[0] = GCTA_TEST_DENSE_GRM_CONTRACT.out.dense_grm.map { meta, grm_id, grm_bin, grm_n_bin ->
73+
[[ id:'contract_dense_mismatch' ], grm_id, grm_bin, grm_n_bin]
74+
}
7275
input[1] = Channel.value(0.05)
7376
"""
7477
}
@@ -89,16 +92,7 @@ nextflow_process {
8992
when {
9093
process {
9194
"""
92-
file('stub_dense.grm.id').text = "fid1 iid1\\n"
93-
file('stub_dense.grm.bin').bytes = []
94-
file('stub_dense.grm.N.bin').bytes = []
95-
96-
input[0] = Channel.value([
97-
[ id:'stub_dense' ],
98-
file('stub_dense.grm.id'),
99-
file('stub_dense.grm.bin'),
100-
file('stub_dense.grm.N.bin')
101-
])
95+
input[0] = GCTA_TEST_DENSE_GRM_STUB.out.dense_grm
10296
input[1] = Channel.value(0.05)
10397
"""
10498
}

modules/nf-core/gcta/makebksparse/tests/main.nf.test.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@
4242
{
4343
"id": "contract_dense"
4444
},
45-
"contract_dense_sp.grm.id:md5,c1fd3a827b108cf8b749e4fced7b7a52",
46-
"contract_dense_sp.grm.sp:md5,9c1256f576632d254861b63586e7a3da"
45+
"contract_dense_sp.grm.id:md5,4f9aa36c44a417ff6d7caa9841e66ad9",
46+
"contract_dense_sp.grm.sp:md5,1b78fe4b14c8690943d7687dd22ba85a"
4747
]
4848
]
4949
],
5050
"meta": {
5151
"nf-test": "0.9.3",
5252
"nextflow": "25.10.4"
5353
},
54-
"timestamp": "2026-03-21T00:30:38.025448523"
54+
"timestamp": "2026-03-21T18:40:37.776832502"
5555
},
5656
"stub_versions": {
5757
"content": [

0 commit comments

Comments
 (0)