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

Commit

Permalink
Merge pull request #120 from awgymer/90-slow-samplesheet-validation-s…
Browse files Browse the repository at this point in the history
…ingle-end

slow validation caused by string replaceAll to remove nulls
  • Loading branch information
nvnieuwk authored Oct 23, 2023
2 parents ac5812a + 56755e8 commit 2abce0d
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package nextflow.validation

import groovy.json.JsonBuilder
import groovy.json.JsonSlurper
import groovy.json.JsonGenerator
import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j
import groovyx.gpars.dataflow.DataflowWriteChannel
Expand Down Expand Up @@ -531,14 +532,12 @@ class SchemaValidator extends PluginExtensionPoint {
.build()
final schema = schemaLoader.load().build()

// Convert the groovy object to a JSONArray
def jsonObj = new JsonBuilder(fileContent)
// Remove all null values from JSON object
jsonObj = jsonObj.toString()
while (jsonObj.contains("null")) {
jsonObj = jsonObj.replaceAll("(.*)(\".*?\":null,?)", '$1')
}
def JSONArray arrayJSON = new JSONArray(jsonObj)
// and convert the groovy object to a JSONArray
def jsonGenerator = new JsonGenerator.Options()
.excludeNulls()
.build()
def JSONArray arrayJSON = new JSONArray(jsonGenerator.toJson(fileContent))

//=====================================================================//
// Check for params with expected values
Expand Down

0 comments on commit 2abce0d

Please sign in to comment.