@@ -8,62 +8,76 @@ nextflow_process {
88 tag "modules_nfcore"
99 tag "gcta"
1010 tag "gcta/makebksparse"
11- tag "gcta/makegrmpart"
1211
13- setup {
14- run("GCTA_MAKEGRMPART", alias: "GCTA_MAKEGRMPART_DENSE") {
15- script "../../makegrmpart/main.nf"
12+ test("homo_sapiens popgen - create sparse GRM") {
13+ config "./nextflow.config"
14+
15+ when {
1616 process {
1717 """
18- file('plink_simulated.mbfile').text = 'plink_simulated\\n'
19-
20- input[0] = [
21- [ id:'plink_simulated_dense', part_gcta_job:1, nparts_gcta:1 ],
22- file('plink_simulated.mbfile'),
23- [
24- file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bed', checkIfExists: true)
25- ],
26- [
27- file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true)
28- ],
29- [
30- file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.fam', checkIfExists: true)
31- ]
32- ]
33- input[1] = [[ id:'all_variants' ], []]
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+ ])
34+ input[1] = Channel.value(0.05)
3435 """
3536 }
3637 }
38+
39+ then {
40+ assertAll(
41+ { assert process.success },
42+ { assert process.out.sparse_grm_files.size() == 1 },
43+ { assert process.out.sparse_grm_files.get(0).get(0).id == "contract_dense" },
44+ { assert snapshot(process.out.sparse_grm_files).match("sparse_grm_files") },
45+ { assert snapshot(process.out.findAll { key, val -> key.startsWith('versions') }).match("versions") }
46+ )
47+ }
3748 }
3849
39- test("homo_sapiens popgen - create sparse GRM") {
50+ test("homo_sapiens popgen - fail when meta id does not match dense GRM basename ") {
4051 config "./nextflow.config"
4152
4253 when {
4354 process {
4455 """
45- dense_grm = GCTA_MAKEGRMPART_DENSE.out.grm_files.map { meta, grm_id, grm_bin, grm_n_bin ->
46- def prefix = meta.id + '.part_' + meta.nparts_gcta + '_' + meta.part_gcta_job
47- [[ id:prefix ], grm_id, grm_bin, grm_n_bin]
48- }
56+ file('contract_dense.grm.id').text = "fid1 iid1\\n"
4957
50- input[0] = dense_grm
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+ ])
5172 input[1] = Channel.value(0.05)
5273 """
5374 }
5475 }
5576
5677 then {
5778 assertAll(
58- { assert process.success },
59- { assert process.out.sparse_grm_files.size() == 1 },
60- { assert process.out.sparse_grm_files.get(0).get(0).id == "plink_simulated_dense.part_1_1" },
61- {
62- assert snapshot(
63- process.out.sparse_grm_files,
64- process.out.findAll { key, val -> key.startsWith('versions') }
65- ).match()
66- }
79+ { assert !process.success },
80+ { assert process.exitStatus != 0 }
6781 )
6882 }
6983 }
@@ -75,12 +89,16 @@ nextflow_process {
7589 when {
7690 process {
7791 """
78- dense_grm = GCTA_MAKEGRMPART_DENSE.out.grm_files.map { meta, grm_id, grm_bin, grm_n_bin ->
79- def prefix = meta.id + '.part_' + meta.nparts_gcta + '_' + meta.part_gcta_job
80- [[ id:prefix ], grm_id, grm_bin, grm_n_bin]
81- }
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 = []
8295
83- input[0] = dense_grm
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+ ])
84102 input[1] = Channel.value(0.05)
85103 """
86104 }
@@ -89,7 +107,10 @@ nextflow_process {
89107 then {
90108 assertAll(
91109 { assert process.success },
92- { assert snapshot(process.out).match() }
110+ { assert process.out.sparse_grm_files.size() == 1 },
111+ { assert process.out.sparse_grm_files.get(0).get(0).id == "stub_dense" },
112+ { assert snapshot(process.out.sparse_grm_files).match("stub_sparse_grm_files") },
113+ { assert snapshot(process.out.findAll { key, val -> key.startsWith('versions') }).match("stub_versions") }
93114 )
94115 }
95116 }
0 commit comments