@@ -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 }
0 commit comments