diff --git a/plugins/nf-schema/src/main/nextflow/validation/SamplesheetConverter.groovy b/plugins/nf-schema/src/main/nextflow/validation/SamplesheetConverter.groovy index b0767f5..3fbe3c2 100644 --- a/plugins/nf-schema/src/main/nextflow/validation/SamplesheetConverter.groovy +++ b/plugins/nf-schema/src/main/nextflow/validation/SamplesheetConverter.groovy @@ -82,6 +82,11 @@ class SamplesheetConverter { throw new SchemaValidationException(msg) } + if(!this.samplesheetFile.exists()) { + def msg = "${colors.red}Samplesheet file ${this.samplesheetFile.toString()} does not exist\n${colors.reset}\n" + throw new SchemaValidationException(msg) + } + // Validate final validator = new JsonSchemaValidator() def JSONArray samplesheet = Utils.fileToJsonArray(this.samplesheetFile, this.schemaFile) diff --git a/plugins/nf-schema/src/main/nextflow/validation/SchemaValidator.groovy b/plugins/nf-schema/src/main/nextflow/validation/SchemaValidator.groovy index eb5ee89..6ca776e 100644 --- a/plugins/nf-schema/src/main/nextflow/validation/SchemaValidator.groovy +++ b/plugins/nf-schema/src/main/nextflow/validation/SchemaValidator.groovy @@ -135,6 +135,45 @@ class SchemaValidator extends PluginExtensionPoint { m.findResult { k, v -> v instanceof Map ? findDeep(v, key) : null } } + @Function + public List samplesheetToList( + final String samplesheet, + final String schema, + final Map options = null + ) { + return samplesheetToList(samplesheet as Path, schema, options) + } + + @Function + public List samplesheetToList( + final Path samplesheet, + final String schema, + final Map options = null + ) { + def String fullPathSchema = Utils.getSchemaPath(session.baseDir.toString(), schema) + def Path schemaFile = Nextflow.file(fullPathSchema) as Path + return samplesheetToList(samplesheet, schemaFile, options) + } + + @Function + public List samplesheetToList( + final String samplesheet, + final Path schema, + final Map options = null + ) { + return samplesheetToList(samplesheet as Path, schema, options) + } + + @Function + public List samplesheetToList( + final Path samplesheet, + final Path schema, + final Map options = null + ) { + def SamplesheetConverter converter = new SamplesheetConverter(samplesheet, schema, session.params, options) + return converter.validateAndConvertToList() + } + @Operator public DataflowWriteChannel fromSamplesheet( final DataflowReadChannel source,