|
| 1 | +nextflow_process { |
| 2 | + |
| 3 | + name "Test Process GCTA_ADDGRMS" |
| 4 | + script "../main.nf" |
| 5 | + process "GCTA_ADDGRMS" |
| 6 | + |
| 7 | + tag "modules" |
| 8 | + tag "modules_nfcore" |
| 9 | + tag "gcta" |
| 10 | + tag "gcta/addgrms" |
| 11 | + tag "gcta/makegrmpart" |
| 12 | + |
| 13 | + setup { |
| 14 | + run("GCTA_MAKEGRMPART", alias: "GCTA_MAKEGRMPART_LDMS1") { |
| 15 | + script "../../makegrmpart/main.nf" |
| 16 | + process { |
| 17 | + """ |
| 18 | + file('plink_simulated_ldms1.mbfile').text = 'plink_simulated\\n' |
| 19 | + |
| 20 | + def ldms1BimFile = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true) |
| 21 | + def ldms1ExtractSnps = ldms1BimFile.readLines() |
| 22 | + .take(10) |
| 23 | + .collect { row -> row.trim().split(/\\s+/)[1] } |
| 24 | + .join('\\n') + '\\n' |
| 25 | + file('plink_simulated_ldms1.snps.txt').text = ldms1ExtractSnps |
| 26 | + |
| 27 | + input[0] = [ |
| 28 | + [ id:'plink_simulated_ldms1' ], |
| 29 | + 1, |
| 30 | + 1, |
| 31 | + file('plink_simulated_ldms1.mbfile'), |
| 32 | + [ |
| 33 | + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bed', checkIfExists: true) |
| 34 | + ], |
| 35 | + [ |
| 36 | + ldms1BimFile |
| 37 | + ], |
| 38 | + [ |
| 39 | + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.fam', checkIfExists: true) |
| 40 | + ] |
| 41 | + ] |
| 42 | + input[1] = [[ id:'plink_simulated_ldms1' ], file('plink_simulated_ldms1.snps.txt')] |
| 43 | + """ |
| 44 | + } |
| 45 | + } |
| 46 | + |
| 47 | + run("GCTA_MAKEGRMPART", alias: "GCTA_MAKEGRMPART_LDMS2") { |
| 48 | + script "../../makegrmpart/main.nf" |
| 49 | + process { |
| 50 | + """ |
| 51 | + file('plink_simulated_ldms2.mbfile').text = 'plink_simulated\\n' |
| 52 | + |
| 53 | + def ldms2BimFile = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true) |
| 54 | + def ldms2ExtractSnps = ldms2BimFile.readLines() |
| 55 | + .drop(10) |
| 56 | + .take(10) |
| 57 | + .collect { row -> row.trim().split(/\\s+/)[1] } |
| 58 | + .join('\\n') + '\\n' |
| 59 | + file('plink_simulated_ldms2.snps.txt').text = ldms2ExtractSnps |
| 60 | + |
| 61 | + input[0] = [ |
| 62 | + [ id:'plink_simulated_ldms2' ], |
| 63 | + 1, |
| 64 | + 1, |
| 65 | + file('plink_simulated_ldms2.mbfile'), |
| 66 | + [ |
| 67 | + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bed', checkIfExists: true) |
| 68 | + ], |
| 69 | + [ |
| 70 | + ldms2BimFile |
| 71 | + ], |
| 72 | + [ |
| 73 | + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.fam', checkIfExists: true) |
| 74 | + ] |
| 75 | + ] |
| 76 | + input[1] = [[ id:'plink_simulated_ldms2' ], file('plink_simulated_ldms2.snps.txt')] |
| 77 | + """ |
| 78 | + } |
| 79 | + } |
| 80 | + } |
| 81 | + |
| 82 | + test("homo_sapiens popgen - merge dense GRMs from mgrm") { |
| 83 | + when { |
| 84 | + process { |
| 85 | + """ |
| 86 | + mgrm_file = Channel |
| 87 | + .of('plink_simulated_ldms1.part_1_1\\nplink_simulated_ldms2.part_1_1') |
| 88 | + .collectFile(name:'plink_simulated_ldms.mgrm', newLine: true) |
| 89 | + |
| 90 | + grm_files = GCTA_MAKEGRMPART_LDMS1.out.grm_files |
| 91 | + .mix(GCTA_MAKEGRMPART_LDMS2.out.grm_files) |
| 92 | + .map { meta, grm_files, nparts_gcta, part_gcta_job -> grm_files } |
| 93 | + .collect() |
| 94 | + .map { bundles -> bundles.flatten().sort { it.name } } |
| 95 | + |
| 96 | + input[0] = mgrm_file |
| 97 | + .combine(grm_files) |
| 98 | + .map { row -> [[ id:'plink_simulated_ldms' ], row[0], row[1..-1]] } |
| 99 | + """ |
| 100 | + } |
| 101 | + } |
| 102 | + |
| 103 | + then { |
| 104 | + assertAll( |
| 105 | + { assert process.success }, |
| 106 | + { assert process.out.combined_grm.size() == 1 }, |
| 107 | + { assert process.out.combined_grm.get(0).get(0).id == "plink_simulated_ldms" }, |
| 108 | + { |
| 109 | + assert process.out.combined_grm.get(0).get(1).collect { file(it).name }.toSet() == [ |
| 110 | + 'plink_simulated_ldms.grm.id', |
| 111 | + 'plink_simulated_ldms.grm.bin', |
| 112 | + 'plink_simulated_ldms.grm.N.bin' |
| 113 | + ] as Set |
| 114 | + }, |
| 115 | + { |
| 116 | + assert snapshot(sanitizeOutput(process.out)).match() |
| 117 | + } |
| 118 | + ) |
| 119 | + } |
| 120 | + } |
| 121 | + |
| 122 | + test("homo_sapiens popgen - merge dense GRMs from mgrm - stub") { |
| 123 | + options "-stub" |
| 124 | + |
| 125 | + when { |
| 126 | + process { |
| 127 | + """ |
| 128 | + mgrm_file = Channel |
| 129 | + .of('plink_simulated_ldms1.part_1_1\\nplink_simulated_ldms2.part_1_1') |
| 130 | + .collectFile(name:'plink_simulated_ldms.mgrm', newLine: true) |
| 131 | + |
| 132 | + grm_files = GCTA_MAKEGRMPART_LDMS1.out.grm_files |
| 133 | + .mix(GCTA_MAKEGRMPART_LDMS2.out.grm_files) |
| 134 | + .map { meta, grm_files, nparts_gcta, part_gcta_job -> grm_files } |
| 135 | + .collect() |
| 136 | + .map { bundles -> bundles.flatten().sort { it.name } } |
| 137 | + |
| 138 | + input[0] = mgrm_file |
| 139 | + .combine(grm_files) |
| 140 | + .map { row -> [[ id:'plink_simulated_ldms' ], row[0], row[1..-1]] } |
| 141 | + """ |
| 142 | + } |
| 143 | + } |
| 144 | + |
| 145 | + then { |
| 146 | + assertAll( |
| 147 | + { assert process.success }, |
| 148 | + { assert process.out.combined_grm.size() == 1 }, |
| 149 | + { assert process.out.combined_grm.get(0).get(0).id == "plink_simulated_ldms" }, |
| 150 | + { |
| 151 | + assert snapshot(sanitizeOutput(process.out)).match() |
| 152 | + } |
| 153 | + ) |
| 154 | + } |
| 155 | + } |
| 156 | +} |
0 commit comments