@@ -7,7 +7,7 @@ nextflow_process {
77 tag "modules_nfcore"
88 tag "gcta"
99 tag "gcta/bivariateremlldms"
10- tag "gcta/makegrmpart "
10+ tag "tests/helpers/makegrm "
1111 tag "gawk"
1212
1313 setup {
@@ -73,24 +73,15 @@ nextflow_process {
7373 }
7474 }
7575
76- run("GCTA_MAKEGRMPART ", alias: "GCTA_MAKEGRMPART_LDMS1 ") {
77- script "../../makegrmpart /main.nf"
76+ run("GCTA_MAKEGRM_HELPER ", alias: "GCTA_MAKEGRM_LDMS1 ") {
77+ script "../tests/helpers/makegrm /main.nf"
7878 process {
7979 """
80- file('plink_simulated.mbfile').text = 'plink_simulated\\n'
81-
8280 input[0] = [
83- [ id:'plink_simulated_ldms1', part_gcta_job:1, nparts_gcta:1 ],
84- file('plink_simulated.mbfile'),
85- [
86- file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bed', checkIfExists: true)
87- ],
88- [
89- file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true)
90- ],
91- [
92- file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.fam', checkIfExists: true)
93- ]
81+ [ id:'plink_simulated_ldms1.part_1_1' ],
82+ file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bed', checkIfExists: true),
83+ file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true),
84+ file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.fam', checkIfExists: true)
9485 ]
9586 input[1] = [
9687 [ id:'plink_random_selected_snp' ],
@@ -100,24 +91,15 @@ nextflow_process {
10091 }
10192 }
10293
103- run("GCTA_MAKEGRMPART ", alias: "GCTA_MAKEGRMPART_LDMS2 ") {
104- script "../../makegrmpart /main.nf"
94+ run("GCTA_MAKEGRM_HELPER ", alias: "GCTA_MAKEGRM_LDMS2 ") {
95+ script "../tests/helpers/makegrm /main.nf"
10596 process {
10697 """
107- file('plink_simulated.mbfile').text = 'plink_simulated\\n'
108-
10998 input[0] = [
110- [ id:'plink_simulated_ldms2', part_gcta_job:1, nparts_gcta:1 ],
111- file('plink_simulated.mbfile'),
112- [
113- file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bed', checkIfExists: true)
114- ],
115- [
116- file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true)
117- ],
118- [
119- file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.fam', checkIfExists: true)
120- ]
99+ [ id:'plink_simulated_ldms2.part_1_1' ],
100+ file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bed', checkIfExists: true),
101+ file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true),
102+ file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.fam', checkIfExists: true)
121103 ]
122104 input[1] = GAWK_COMPLEMENT_VARIANTS.out.output
123105 """
@@ -134,8 +116,8 @@ nextflow_process {
134116 .of('plink_simulated_ldms1.part_1_1\\nplink_simulated_ldms2.part_1_1')
135117 .collectFile(name:'plink_simulated_ldms.mgrm', newLine: true)
136118
137- ldms_grm_files = GCTA_MAKEGRMPART_LDMS1 .out.grm_files
138- .mix(GCTA_MAKEGRMPART_LDMS2 .out.grm_files)
119+ ldms_grm_files = GCTA_MAKEGRM_LDMS1 .out.grm_files
120+ .mix(GCTA_MAKEGRM_LDMS2 .out.grm_files)
139121 .map { meta, grm_id, grm_bin, grm_n_bin -> [grm_id, grm_bin, grm_n_bin] }
140122 .collect()
141123 .map { rows -> rows.flatten() }
@@ -156,16 +138,26 @@ nextflow_process {
156138 { assert process.out.bivariate_results.size() == 1 },
157139 { assert process.out.log_file.size() == 1 },
158140 { assert process.out.bivariate_results.get(0).get(0).id == "Trait1__Trait2" },
141+ { assert file(process.out.bivariate_results.get(0).get(1)).name == "Trait1__Trait2.hsq" },
159142 { assert file(process.out.log_file.get(0).get(1)).name == "Trait1__Trait2.log" },
160143 { assert file(process.out.log_file.get(0).get(1)).exists() },
161144 {
162145 def resultFile = file(process.out.bivariate_results.get(0).get(1))
146+ def parsedRows = resultFile.readLines()
147+ .collect { it.tokenize() }
148+ .findAll { row -> !row.isEmpty() && row[0] != 'Source' }
149+ .collect { row -> [row[0], row[1..-1]] }
150+ def valueBySource = parsedRows.collectEntries { row -> [(row[0]): row[1]] }
151+ assert valueBySource["V(G1)_tr1"] == ["0.000006", "0.210395"]
152+ assert valueBySource["C(G1)_tr12"] == ["0.607507", "0.601887"]
153+ assert valueBySource["logL"] == ["-844.942"]
154+ assert valueBySource["n"] == ["400"]
163155 assert snapshot(
164156 [
165157 [
166158 process.out.bivariate_results.get(0).get(0),
167159 resultFile.name,
168- resultFile.readLines().collect { it.tokenize()[0] }
160+ parsedRows
169161 ]
170162 ],
171163 process.out.findAll { key, val -> key.startsWith('versions') }
@@ -175,6 +167,39 @@ nextflow_process {
175167 }
176168 }
177169
170+ test("homo_sapiens popgen - bivariate phenotype fails when mgrm references missing GRM basename") {
171+ config "./nextflow.config"
172+ when {
173+ process {
174+ """
175+ broken_mgrm_file = Channel
176+ .of('plink_simulated_ldms_missing.part_1_1')
177+ .collectFile(name:'plink_simulated_ldms_broken.mgrm', newLine: true)
178+
179+ ldms_grm_files = GCTA_MAKEGRM_LDMS1.out.grm_files
180+ .mix(GCTA_MAKEGRM_LDMS2.out.grm_files)
181+ .map { meta, grm_id, grm_bin, grm_n_bin -> [grm_id, grm_bin, grm_n_bin] }
182+ .collect()
183+ .map { rows -> rows.flatten() }
184+
185+ input[0] = GAWK_BIVARIATE_PHENO.out.output
186+ input[1] = broken_mgrm_file
187+ .combine(ldms_grm_files)
188+ .map { row -> [[ id:'plink_simulated_ldms' ], row[0], row[1..-1]] }
189+ input[2] = [[ id:'covariates_quant' ], []]
190+ input[3] = [[ id:'covariates_cat' ], []]
191+ """
192+ }
193+ }
194+
195+ then {
196+ assertAll(
197+ { assert !process.success },
198+ { assert process.exitStatus != 0 }
199+ )
200+ }
201+ }
202+
178203 test("homo_sapiens popgen - bivariate phenotype with ldms mgrm - stub") {
179204 options "-stub"
180205 config "./nextflow.config"
@@ -186,8 +211,8 @@ nextflow_process {
186211 .of('plink_simulated_ldms1.part_1_1\\nplink_simulated_ldms2.part_1_1')
187212 .collectFile(name:'plink_simulated_ldms.mgrm', newLine: true)
188213
189- ldms_grm_files = GCTA_MAKEGRMPART_LDMS1 .out.grm_files
190- .mix(GCTA_MAKEGRMPART_LDMS2 .out.grm_files)
214+ ldms_grm_files = GCTA_MAKEGRM_LDMS1 .out.grm_files
215+ .mix(GCTA_MAKEGRM_LDMS2 .out.grm_files)
191216 .map { meta, grm_id, grm_bin, grm_n_bin -> [grm_id, grm_bin, grm_n_bin] }
192217 .collect()
193218 .map { rows -> rows.flatten() }
@@ -205,7 +230,16 @@ nextflow_process {
205230 then {
206231 assertAll(
207232 { assert process.success },
208- { assert snapshot(process.out).match() }
233+ { assert process.out.bivariate_results.get(0).get(0).id == "Trait1__Trait2" },
234+ { assert file(process.out.bivariate_results.get(0).get(1)).name == "Trait1__Trait2.hsq" },
235+ { assert file(process.out.log_file.get(0).get(1)).name == "Trait1__Trait2.log" },
236+ {
237+ assert snapshot(
238+ process.out.bivariate_results,
239+ process.out.log_file,
240+ process.out.findAll { key, val -> key.startsWith('versions') }
241+ ).match()
242+ }
209243 )
210244 }
211245 }
0 commit comments