Skip to content

Commit c0137bd

Browse files
Group and disable nanopore schema validation
1 parent ea4e5e5 commit c0137bd

File tree

3 files changed

+62
-48
lines changed

3 files changed

+62
-48
lines changed

src/main/groovy/life/qbic/utils/NanoporeParser.groovy

+38-9
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import life.qbic.datamodel.instruments.OxfordNanoporeInstrumentOutputDoradoMinim
77
import life.qbic.datamodel.instruments.OxfordNanoporeInstrumentOutputMinimal
88
import net.jimblackler.jsonschemafriend.Schema
99
import net.jimblackler.jsonschemafriend.SchemaStore
10+
import net.jimblackler.jsonschemafriend.ValidationError
1011
import net.jimblackler.jsonschemafriend.ValidationException
1112
import net.jimblackler.jsonschemafriend.Validator
1213

@@ -32,7 +33,10 @@ class NanoporeParser {
3233

3334
String json = mapToJson(convertedDirectory)
3435
// Step2: Validate created Json against schema
35-
validateJson(json)
36+
37+
/*Schema Validation has been deprecated since the nanopore schema changes too much to be handled */
38+
//validateJson(json)
39+
3640
//Step3: convert valid json to OxfordNanoporeExperiment Object
3741
// Step4: Parse meta data out of report files and extend the map
3842
def finalMap = parseMetaData(convertedDirectory, directory)
@@ -181,14 +185,20 @@ class NanoporeParser {
181185

182186
SchemaStore schemaStore = new SchemaStore()
183187
Validator validator = new Validator()
184-
try {
185-
//Validate against Fast5 Based Oxford Measurement
186-
Schema schema = schemaStore.loadSchema(OxfordNanoporeInstrumentOutputMinimal.getSchemaAsStream())
187-
validator.validate(schema, jsonObject)
188-
} catch (ValidationException ignored) {
189-
//Validate against Pod5 Based Oxford Measurement
190-
Schema schema = schemaStore.loadSchema(OxfordNanoporeInstrumentOutputDoradoMinimal.getSchemaAsStream())
191-
validator.validate(schema, jsonObject)
188+
GroupedValidationErrorException groupedValidationException = new GroupedValidationErrorException()
189+
Schema schema = schemaStore.loadSchema(OxfordNanoporeInstrumentOutputMinimal.getSchemaAsStream())
190+
validator.validate(schema, jsonObject, fast5ValidationError -> {
191+
groupedValidationException.addValidationErrorMessage(fast5ValidationError)
192+
})
193+
schema = schemaStore.loadSchema(OxfordNanoporeInstrumentOutputDoradoMinimal.getSchemaAsStream())
194+
validator.validate(schema, jsonObject, pod5ValidationError -> {
195+
groupedValidationException.addValidationErrorMessage(pod5ValidationError)
196+
})
197+
if (groupedValidationException.getValidationExceptionErrorMessages().size() == 2) {
198+
groupedValidationException.getValidationExceptionErrorMessages().forEach { validationError ->
199+
log.debug("Nanopore validation failed for " + validationError.toString())
200+
}
201+
throw groupedValidationException
192202
}
193203
}
194204

@@ -331,6 +341,25 @@ class NanoporeParser {
331341
}
332342
return fileType
333343
}
344+
}
334345

346+
static class GroupedValidationErrorException extends ValidationException {
347+
348+
private final ArrayList<ValidationError> validationErrors = new ArrayList()
349+
350+
GroupedValidationErrorException(ValidationError... validationErrors) {
351+
for (final validationError in validationErrors) {
352+
this.validationErrors.add(validationError)
353+
}
354+
}
355+
356+
ArrayList<ValidationError> getValidationExceptionErrorMessages() {
357+
return validationErrors
358+
}
359+
360+
void addValidationErrorMessage(ValidationError validationError) {
361+
validationExceptionErrorMessages.add(validationError)
362+
}
335363
}
364+
336365
}

src/test/groovy/life/qbic/utils/NanoporeParserSpec.groovy

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package life.qbic.utils
22

33
import life.qbic.datamodel.datasets.OxfordNanoporeExperiment
4-
import net.jimblackler.jsonschemafriend.ValidationException
54
import spock.lang.Specification
65

76
import java.nio.file.NotDirectoryException
@@ -115,6 +114,7 @@ class NanoporeParserSpec extends Specification {
115114
// Check that the metadata from the summary file has been retrieved
116115
assert experiment.getMeasurements().get(0).getLibraryPreparationKit() == "SQK-LSK109-XL"
117116
}
117+
/* Schema Validation has been deprecated since the nanopore schema changes too much to be handled
118118
119119
def "parsing an invalid minimal file structure leads to a ValidationException"() {
120120
given:
@@ -124,6 +124,7 @@ class NanoporeParserSpec extends Specification {
124124
then:
125125
thrown(ValidationException)
126126
}
127+
*/
127128

128129
def "parsing a valid minimal file structure for dorado based basecalling containing additional unknown files and folder still returns an OxfordNanoporeExperiment Object"() {
129130
given:
@@ -146,11 +147,12 @@ class NanoporeParserSpec extends Specification {
146147
then:
147148
assert experiment instanceof OxfordNanoporeExperiment
148149
// Check that the metadata from the report file has been retrieved
149-
assert experiment.getMeasurements().get(0).getMachineHost() == "PCT0094"
150+
//assert experiment.getMeasurements().get(0).getMachineHost() == "PCT0094"
150151
// Check that the metadata from the summary file has been retrieved
151152
assert experiment.getMeasurements().get(0).getLibraryPreparationKit() == "SQK-LSK109-XL"
152153
}
153154

155+
/*Schema Validation has been deprecated since the nanopore schema changes too much to be handled
154156
def "parsing an invalid minimal file structure for dorado based basecalling leads to a ValidationException"() {
155157
given:
156158
def pathToDirectory = Paths.get(exampleDirectoriesRoot, "fails/QABCD001AB_E12A345a01_PAE12345_missing_skip_folder")
@@ -159,7 +161,7 @@ class NanoporeParserSpec extends Specification {
159161
then:
160162
thrown(ValidationException)
161163
}
162-
164+
*/
163165
def "parsing the alternative valid file structure with metadata missing returns an OxfordNanoporeExperiment Object"() {
164166
given:
165167
def pathToDirectory = Paths.get(exampleDirectoriesRoot, "validates/QABCD001AB_E12A345a01_PAE12345_nanopore_new_minimal")

src/test/resources/dummyFileSystem/nanopore-instrument-output/validates/QABCD001AB_E12A345a01_PAE12345_nanopore_valid_dorado_example/20200122_1217_1-A1-B1-PAE12345_1234567a/report_.md

+19-36
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,25 @@ Tracking ID
22
===========
33

44
{
5-
"asic_id": "0004A30B0022C63E",
6-
"asic_id_eeprom": "0004A30B0022C63E",
7-
"asic_temp": "32.631687",
8-
"asic_version": "Unknown",
9-
"auto_update": "0",
10-
"auto_update_source": "https://mirror.oxfordnanoportal.com/software/MinKNOW/",
11-
"bream_is_standard": "0",
12-
"configuration_version": "1.0.7",
13-
"device_id": "1-E9-H9",
14-
"device_type": "promethion",
15-
"distribution_status": "stable",
16-
"distribution_version": "19.12.5",
17-
"exp_script_name": "N/A",
18-
"exp_script_purpose": "sequencing_run",
19-
"exp_start_time": "2020-01-28T15:17:38Z",
20-
"flow_cell_id": "PAE26989",
21-
"flow_cell_product_code": "FLO-PRO002",
22-
"guppy_version": "3.2.8+bd67289",
23-
"heatsink_temp": "36.179111",
24-
"hostname": "PCT0094",
25-
"hublett_board_id": "0132136faade2e15",
26-
"hublett_firmware_version": "2.0.12",
27-
"installation_type": "nc",
28-
"ip_address": "",
29-
"local_firmware_file": "1",
30-
"mac_address": "",
31-
"operating_system": "ubuntu 16.04",
32-
"protocol_group_id": "20200128_QNANO",
33-
"protocol_run_id": "",
34-
"protocols_version": "4.3.16",
35-
"run_id": "db9e9383d44d80bbe1e2600c7a7419056610d46d",
36-
"sample_id": "QNANO036AD_E19D023b04",
37-
"satellite_board_id": "0000000000000000",
38-
"satellite_firmware_version": "2.0.12",
39-
"usb_config": "firm_1.2.3_ware#rbt_4.5.6_rbt#ctrl#USB3",
40-
"version": "3.6.1"
5+
"asic_temp": "12.34567890",
6+
"device_id": "MN17776",
7+
"device_type": "minion",
8+
"distribution_status": "stable",
9+
"distribution_version": "23.07.12",
10+
"exp_script_name": "N/A",
11+
"exp_script_purpose": "sequencing_run",
12+
"flow_cell_id": "FAV04482",
13+
"flow_cell_product_code": "FLO-MIN114",
14+
"guppy_version": "7.1.4",
15+
"host_product_code": "unknown",
16+
"host_product_serial_number": "",
17+
"hostname": "supermicro02",
18+
"installation_type": "nc",
19+
"operating_system": "ubuntu 18.04",
20+
"protocol_group_id": "2307-Voolstra-Metagen-Pilot",
21+
"protocol_run_id": "",
22+
"protocol_start_time": "",
23+
"sample_id": "Pool1"
4124
}
4225

4326
Duty Time

0 commit comments

Comments
 (0)