Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

Commit

Permalink
add function equivalent to fromSamplesheet
Browse files Browse the repository at this point in the history
  • Loading branch information
nvnieuwk committed Mar 21, 2024
1 parent d28b63c commit 7da6e06
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 7da6e06

Please sign in to comment.