Skip to content

Commit 47adbea

Browse files
committed
feat: validate read structures with the nf-fgbio plugin
1 parent deeca5a commit 47adbea

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

nextflow.config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,10 @@ manifest {
272272

273273
// Nextflow plugins
274274
// nf-schema: validation of pipeline parameters and creation of an input channel from a sample sheet
275+
// nf-fgbio: validation of read structure(s) passed as parameters
275276
plugins {
276277
id 'nf-schema@2.1.1'
278+
id 'nf-fgbio@1.0.0'
277279
}
278280

279281
validation {

subworkflows/local/utils_nfcore_fastquorum_pipeline/main.nf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
include { UTILS_NFSCHEMA_PLUGIN } from '../../nf-core/utils_nfschema_plugin'
1212
include { paramsSummaryMap } from 'plugin/nf-schema'
1313
include { samplesheetToList } from 'plugin/nf-schema'
14+
include { readStructure } from 'plugin/nf-fgbio'
1415
include { completionEmail } from '../../nf-core/utils_nfcore_pipeline'
1516
include { completionSummary } from '../../nf-core/utils_nfcore_pipeline'
1617
include { imNotification } from '../../nf-core/utils_nfcore_pipeline'
@@ -177,6 +178,27 @@ def validateInputSamplesheetRow(row) {
177178
else if (num_segments > num_fastqs) {
178179
error("Please check input samplesheet -> Too many read structures (${num_segments}) for ${num_fastqs} FASTQs for ${meta.id}")
179180
}
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+
}
180202

181203
// NB: the collect here doesn't care which FASTQ list is empty
182204
return [row[0], row[1], row[2].findAll { it -> it.size() > 0 }]

0 commit comments

Comments
 (0)