|
11 | 11 | include { UTILS_NFSCHEMA_PLUGIN } from '../../nf-core/utils_nfschema_plugin' |
12 | 12 | include { paramsSummaryMap } from 'plugin/nf-schema' |
13 | 13 | include { samplesheetToList } from 'plugin/nf-schema' |
| 14 | +include { readStructure } from 'plugin/nf-fgbio' |
14 | 15 | include { completionEmail } from '../../nf-core/utils_nfcore_pipeline' |
15 | 16 | include { completionSummary } from '../../nf-core/utils_nfcore_pipeline' |
16 | 17 | include { imNotification } from '../../nf-core/utils_nfcore_pipeline' |
@@ -177,6 +178,27 @@ def validateInputSamplesheetRow(row) { |
177 | 178 | else if (num_segments > num_fastqs) { |
178 | 179 | error("Please check input samplesheet -> Too many read structures (${num_segments}) for ${num_fastqs} FASTQs for ${meta.id}") |
179 | 180 | } |
| 181 | + |
| 182 | + // Validate the read structure |
| 183 | + meta.read_structure.tokenize(" ").each { rs-> |
| 184 | + // If parsing the read structure fails, then a java.lang.reflect.InvocationTargetException will be thrown, with |
| 185 | + // the cause containing the exception produced by fgbio. |
| 186 | + try { |
| 187 | + readStructure(rs) |
| 188 | + } catch (java.lang.reflect.InvocationTargetException ex) { |
| 189 | + def message = """ |
| 190 | + |Please check input samplesheet -> Read structure`${rs}` invalid |
| 191 | + | |
| 192 | + | ${ex.getCause().getMessage()} |
| 193 | + | |
| 194 | + | For more information on read structures, visit: https://github.com/fulcrumgenomics/fgbio/wiki/Read-Structures |
| 195 | + | |
| 196 | + | Validate your read structures here: https://fulcrumgenomics.github.io/fgbio/validate-read-structure.html |
| 197 | + |""".stripMargin() |
| 198 | + error(message) |
| 199 | + throw ex |
| 200 | + } |
| 201 | + } |
180 | 202 |
|
181 | 203 | // NB: the collect here doesn't care which FASTQ list is empty |
182 | 204 | return [row[0], row[1], row[2].findAll { it -> it.size() > 0 }] |
|
0 commit comments