|
| 1 | +nextflow_process { |
| 2 | + |
| 3 | + name "Test Process GCTA_GRMCUTOFF" |
| 4 | + script "../main.nf" |
| 5 | + process "GCTA_GRMCUTOFF" |
| 6 | + |
| 7 | + tag "modules" |
| 8 | + tag "modules_nfcore" |
| 9 | + tag "gcta" |
| 10 | + tag "gcta/grmcutoff" |
| 11 | + tag "gcta/makegrm" |
| 12 | + |
| 13 | + setup { |
| 14 | + run("GCTA_MAKEGRM", alias: "GCTA_MAKEGRM_CONTRACT") { |
| 15 | + script "../../makegrm/main.nf" |
| 16 | + process { |
| 17 | + """ |
| 18 | + file('tiny_dense.mbfile').text = 'plink_simulated\\n' |
| 19 | + |
| 20 | + input[0] = [ |
| 21 | + [ id:'tiny_dense' ], |
| 22 | + file('tiny_dense.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 | + """ |
| 34 | + } |
| 35 | + } |
| 36 | + |
| 37 | + run("GCTA_MAKEGRM", alias: "GCTA_MAKEGRM_STUB") { |
| 38 | + script "../../makegrm/main.nf" |
| 39 | + process { |
| 40 | + """ |
| 41 | + file('stub_dense.mbfile').text = 'plink_simulated\\n' |
| 42 | + |
| 43 | + input[0] = [ |
| 44 | + [ id:'stub_dense' ], |
| 45 | + file('stub_dense.mbfile'), |
| 46 | + [ |
| 47 | + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bed', checkIfExists: true) |
| 48 | + ], |
| 49 | + [ |
| 50 | + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true) |
| 51 | + ], |
| 52 | + [ |
| 53 | + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.fam', checkIfExists: true) |
| 54 | + ] |
| 55 | + ] |
| 56 | + """ |
| 57 | + } |
| 58 | + } |
| 59 | + } |
| 60 | + |
| 61 | + test("homo_sapiens popgen - apply GRM cutoff to dense GRM") { |
| 62 | + when { |
| 63 | + process { |
| 64 | + """ |
| 65 | + input[0] = GCTA_MAKEGRM_CONTRACT.out.grm_files |
| 66 | + input[1] = 0.05 |
| 67 | + """ |
| 68 | + } |
| 69 | + } |
| 70 | + |
| 71 | + then { |
| 72 | + assertAll( |
| 73 | + { assert process.success }, |
| 74 | + { assert process.out.grm_files.size() == 1 }, |
| 75 | + { assert process.out.keep_file.size() == 1 }, |
| 76 | + { assert process.out.grm_files.get(0).get(0).id == "tiny_dense" }, |
| 77 | + { |
| 78 | + def grm_row = process.out.grm_files.get(0) |
| 79 | + def expected_prefix = "${grm_row.get(0).id}_grmcutoff" |
| 80 | + assert grm_row.get(1).collect { file(it).name }.sort() == [ |
| 81 | + "${expected_prefix}.grm.N.bin", |
| 82 | + "${expected_prefix}.grm.bin", |
| 83 | + "${expected_prefix}.grm.id" |
| 84 | + ] |
| 85 | + assert file(process.out.keep_file.get(0).get(1)).name == "${expected_prefix}.grm.id" |
| 86 | + }, |
| 87 | + { |
| 88 | + assert snapshot(sanitizeOutput(process.out)).match() |
| 89 | + } |
| 90 | + ) |
| 91 | + } |
| 92 | + } |
| 93 | + |
| 94 | + test("homo_sapiens popgen - GRM cutoff fails when meta.id is not GRM basename") { |
| 95 | + when { |
| 96 | + process { |
| 97 | + """ |
| 98 | + input[0] = GCTA_MAKEGRM_CONTRACT.out.grm_files.map { meta, grm_files -> |
| 99 | + [[ id:'tiny_dense_mismatched' ], grm_files] |
| 100 | + } |
| 101 | + input[1] = 0.05 |
| 102 | + """ |
| 103 | + } |
| 104 | + } |
| 105 | + |
| 106 | + then { |
| 107 | + assertAll( |
| 108 | + { assert !process.success }, |
| 109 | + { assert process.exitStatus != 0 } |
| 110 | + ) |
| 111 | + } |
| 112 | + } |
| 113 | + |
| 114 | + test("homo_sapiens popgen - GRM cutoff fails for malformed GRM tuple") { |
| 115 | + when { |
| 116 | + process { |
| 117 | + """ |
| 118 | + input[0] = GCTA_MAKEGRM_CONTRACT.out.grm_files.map { meta, grm_files -> |
| 119 | + [[ id:meta.id ]] |
| 120 | + } |
| 121 | + input[1] = 0.05 |
| 122 | + """ |
| 123 | + } |
| 124 | + } |
| 125 | + |
| 126 | + then { |
| 127 | + assert !process.success |
| 128 | + } |
| 129 | + } |
| 130 | + |
| 131 | + test("homo_sapiens popgen - apply GRM cutoff to dense GRM - stub") { |
| 132 | + options "-stub" |
| 133 | + |
| 134 | + when { |
| 135 | + process { |
| 136 | + """ |
| 137 | + input[0] = GCTA_MAKEGRM_STUB.out.grm_files |
| 138 | + input[1] = 0.125 |
| 139 | + """ |
| 140 | + } |
| 141 | + } |
| 142 | + |
| 143 | + then { |
| 144 | + assertAll( |
| 145 | + { assert process.success }, |
| 146 | + { assert process.out.grm_files.get(0).get(0).id == "stub_dense" }, |
| 147 | + { |
| 148 | + def grm_row = process.out.grm_files.get(0) |
| 149 | + def expected_prefix = "${grm_row.get(0).id}_grmcutoff" |
| 150 | + assert grm_row.get(1).collect { file(it).name }.sort() == [ |
| 151 | + "${expected_prefix}.grm.N.bin", |
| 152 | + "${expected_prefix}.grm.bin", |
| 153 | + "${expected_prefix}.grm.id" |
| 154 | + ] |
| 155 | + assert file(process.out.keep_file.get(0).get(1)).name == "${expected_prefix}.grm.id" |
| 156 | + }, |
| 157 | + { |
| 158 | + assert snapshot(sanitizeOutput(process.out)).match() |
| 159 | + } |
| 160 | + ) |
| 161 | + } |
| 162 | + } |
| 163 | +} |
0 commit comments