|
| 1 | +nextflow_process { |
| 2 | + |
| 3 | + name "Test Process PHARMCAT_PHENOTYPER" |
| 4 | + script "../main.nf" |
| 5 | + process "PHARMCAT_PHENOTYPER" |
| 6 | + |
| 7 | + tag "modules" |
| 8 | + tag "modules_nfcore" |
| 9 | + tag "pharmcat" |
| 10 | + tag "pharmcat/phenotyper" |
| 11 | + tag "pharmcat/matcher" |
| 12 | + |
| 13 | + config "./nextflow.config" |
| 14 | + |
| 15 | + |
| 16 | + setup { |
| 17 | + run("PHARMCAT_MATCHER") { |
| 18 | + script "../../matcher/main.nf" |
| 19 | + process { |
| 20 | + """ |
| 21 | + input[0] = Channel.fromList([ |
| 22 | + tuple([id: 'PharmCAT'], // meta map |
| 23 | + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/pharmcat/test.chr22.single.sample.vcf.gz', checkIfExists: true), |
| 24 | + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/pharmcat/test.chr22.single.sample.vcf.gz.tbi', checkIfExists: true)), |
| 25 | + ]) |
| 26 | + input[1] = Channel.of([]) |
| 27 | + """ |
| 28 | + } |
| 29 | + } |
| 30 | + } |
| 31 | + |
| 32 | + test("Phenotyper with pharmcat matcher JSON") { |
| 33 | + |
| 34 | + when { |
| 35 | + |
| 36 | + params { |
| 37 | + module_args = '' |
| 38 | + } |
| 39 | + |
| 40 | + process { |
| 41 | + """ |
| 42 | + input[0] = PHARMCAT_MATCHER.out.matcher_json.collect { |
| 43 | + meta, match_json -> match_json |
| 44 | + }.map { |
| 45 | + match_json -> [ |
| 46 | + [ id: 'test'], |
| 47 | + match_json, |
| 48 | + [] |
| 49 | + ] |
| 50 | + } |
| 51 | + """ |
| 52 | + } |
| 53 | + } |
| 54 | + |
| 55 | + then { |
| 56 | + assertAll( |
| 57 | + { assert process.success }, |
| 58 | + { assert snapshot( |
| 59 | + file(process.out.phenotyper_json[0][1]).name, |
| 60 | + process.out.findAll { key, val -> key.startsWith("versions") } |
| 61 | + ).match() } |
| 62 | + ) |
| 63 | + } |
| 64 | + } |
| 65 | + |
| 66 | + test("Phenotyper with outside calls JSON") { |
| 67 | + |
| 68 | + when { |
| 69 | + params { |
| 70 | + module_args = '' |
| 71 | + } |
| 72 | + |
| 73 | + process { |
| 74 | + """ |
| 75 | + input[0] = [ |
| 76 | + [ id:'test' ], // meta map |
| 77 | + [], |
| 78 | + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/pharmcat/test.chr22.outsideCall.tsv', checkIfExists: true), |
| 79 | + ] |
| 80 | + """ |
| 81 | + } |
| 82 | + } |
| 83 | + |
| 84 | + then { |
| 85 | + assertAll( |
| 86 | + { assert process.success }, |
| 87 | + { assert snapshot( |
| 88 | + file(process.out.phenotyper_json[0][1]).name, |
| 89 | + process.out.findAll { key, val -> key.startsWith("versions") } |
| 90 | + ).match() } |
| 91 | + ) |
| 92 | + } |
| 93 | + } |
| 94 | + |
| 95 | + test("Phenotyper with pharmcat matcher + outside calls JSON") { |
| 96 | + |
| 97 | + when { |
| 98 | + params { |
| 99 | + module_args = '' |
| 100 | + } |
| 101 | + |
| 102 | + process { |
| 103 | + """ |
| 104 | + input[0] = PHARMCAT_MATCHER.out.matcher_json.collect { |
| 105 | + meta, match_json -> match_json |
| 106 | + }.map { |
| 107 | + match_json -> [ |
| 108 | + [ id: 'test'], |
| 109 | + match_json, |
| 110 | + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/pharmcat/test.chr22.outsideCall.tsv', checkIfExists: true) |
| 111 | + ] |
| 112 | + } |
| 113 | + """ |
| 114 | + } |
| 115 | + } |
| 116 | + |
| 117 | + then { |
| 118 | + assertAll( |
| 119 | + { assert process.success }, |
| 120 | + { assert snapshot( |
| 121 | + file(process.out.phenotyper_json[0][1]).name, |
| 122 | + process.out.findAll { key, val -> key.startsWith("versions") } |
| 123 | + ).match() } |
| 124 | + ) |
| 125 | + } |
| 126 | + } |
| 127 | + |
| 128 | + |
| 129 | + test("Phenotyper - stub") { |
| 130 | + |
| 131 | + options "-stub" |
| 132 | + |
| 133 | + when { |
| 134 | + params { |
| 135 | + module_args = '' |
| 136 | + } |
| 137 | + |
| 138 | + process { |
| 139 | + """ |
| 140 | + input[0] = PHARMCAT_MATCHER.out.matcher_json.collect { |
| 141 | + meta, match_json -> match_json |
| 142 | + }.map { |
| 143 | + match_json -> [ |
| 144 | + [ id: 'test'], |
| 145 | + match_json, |
| 146 | + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/pharmcat/test.chr22.outsideCall.tsv', checkIfExists: true) |
| 147 | + ] |
| 148 | + } |
| 149 | + """ |
| 150 | + } |
| 151 | + } |
| 152 | + |
| 153 | + then { |
| 154 | + assertAll( |
| 155 | + { assert process.success }, |
| 156 | + { assert snapshot( |
| 157 | + sanitizeOutput(process.out) |
| 158 | + ).match() } |
| 159 | + ) |
| 160 | + } |
| 161 | + } |
| 162 | +} |
0 commit comments