Skip to content

Commit 6eac517

Browse files
authored
fix(grz-pydantic-models): Check for presence of necessary labData depending on the genomicStudySubtype (#443)
Resolves #441 Depends on #442
1 parent 253e618 commit 6eac517

12 files changed

Lines changed: 163 additions & 30 deletions

File tree

packages/grz-pydantic-models/src/grz_pydantic_models/submission/metadata/v1.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,6 +1176,47 @@ def ensure_all_donors_mv_consented_if_initial(self):
11761176
raise ValueError("All donors must consent to model project participation for initial submissions.")
11771177
return self
11781178

1179+
@model_validator(mode="after")
1180+
def ensure_index_has_correct_sequence_subtype(self):
1181+
# index donors must have sequence subtype depending on genomic study subtype
1182+
# TODO: Should "addition"-type submissions be skipped?
1183+
1184+
match self.submission.genomic_study_subtype:
1185+
case GenomicStudySubtype.tumor_only:
1186+
required_sequencing_subtypes = {
1187+
SequenceSubtype.somatic,
1188+
}
1189+
case GenomicStudySubtype.tumor_germline:
1190+
required_sequencing_subtypes = {
1191+
SequenceSubtype.somatic,
1192+
SequenceSubtype.germline,
1193+
}
1194+
case GenomicStudySubtype.germline_only:
1195+
required_sequencing_subtypes = {
1196+
SequenceSubtype.germline,
1197+
}
1198+
case _:
1199+
# unreachable code due to prior validation
1200+
raise ValueError("Unknown genomic study subtype. This should never happen.")
1201+
1202+
for donor in self.donors:
1203+
if donor.relation != Relation.index_:
1204+
# only validate index donor
1205+
continue
1206+
1207+
# get donor sequence subtypes
1208+
donor_sequence_subtypes = {datum.sequence_subtype for datum in donor.lab_data}
1209+
1210+
missing_subtypes = required_sequencing_subtypes - donor_sequence_subtypes
1211+
1212+
if missing_subtypes:
1213+
raise ValueError(
1214+
f"Index donor is missing sequence subtypes for submission type '{self.submission.genomic_study_subtype}': "
1215+
f"{', '.join(missing_subtypes)}."
1216+
)
1217+
1218+
return self
1219+
11791220
@model_validator(mode="after")
11801221
def check_for_tumor_cell_count(self):
11811222
"""

packages/grz-pydantic-models/tests/resources/example_metadata/panel/v1.2.1.json renamed to packages/grz-pydantic-models/tests/resources/example_metadata/panel_tumor_only/v1.2.1.json

File renamed without changes.

packages/grz-pydantic-models/tests/resources/example_metadata/panel/v1.3.0.json renamed to packages/grz-pydantic-models/tests/resources/example_metadata/panel_tumor_only/v1.3.0.json

File renamed without changes.

packages/grz-pydantic-models/tests/resources/example_metadata/wgs_lr/v1.2.1.json renamed to packages/grz-pydantic-models/tests/resources/example_metadata/wgs_lr_tumor_only/v1.2.1.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"submitterId": "123456789",
1010
"genomicDataCenterId": "GRZM00123",
1111
"clinicalDataNodeId": "KDKM00456",
12-
"diseaseType": "rare",
12+
"diseaseType": "oncological",
1313
"genomicStudyType": "single",
1414
"genomicStudySubtype": "tumor-only",
1515
"labName": "Genomics Lab Humangenetik MRI"
@@ -103,7 +103,7 @@
103103
],
104104
"labData": [
105105
{
106-
"labDataName": "Blood DNA normal",
106+
"labDataName": "Blood DNA tumor",
107107
"tissueOntology": {
108108
"name": "UBERON",
109109
"version": "1.5"
@@ -113,7 +113,7 @@
113113
"sampleDate": "2023-06-21",
114114
"sampleConservation": "cryo-frozen",
115115
"sequenceType": "dna",
116-
"sequenceSubtype": "other",
116+
"sequenceSubtype": "somatic",
117117
"fragmentationMethod": "none",
118118
"libraryType": "wgs_lr",
119119
"libraryPrepKit": "SMRTbell™ Express Template Prep Kit",
@@ -137,10 +137,10 @@
137137
"bioinformaticsPipelineVersion": "v3.4.1",
138138
"referenceGenome": "GRCh38",
139139
"percentBasesAboveQualityThreshold": {
140-
"minimumQuality": 50,
140+
"minimumQuality": 20,
141141
"percent": 88
142142
},
143-
"meanDepthOfCoverage": 40,
143+
"meanDepthOfCoverage": 100,
144144
"minCoverage": 30,
145145
"targetedRegionsAboveMinCoverage": 0.9,
146146
"nonCodingVariants": true,

packages/grz-pydantic-models/tests/resources/example_metadata/wgs_lr/v1.3.0.json renamed to packages/grz-pydantic-models/tests/resources/example_metadata/wgs_lr_tumor_only/v1.3.0.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"submitterId": "123456789",
1010
"genomicDataCenterId": "GRZM00123",
1111
"clinicalDataNodeId": "KDKM00456",
12-
"diseaseType": "rare",
12+
"diseaseType": "oncological",
1313
"genomicStudyType": "single",
1414
"genomicStudySubtype": "tumor-only",
1515
"labName": "Genomics Lab Humangenetik MRI"
@@ -103,7 +103,7 @@
103103
],
104104
"labData": [
105105
{
106-
"labDataName": "Blood DNA normal",
106+
"labDataName": "Blood DNA tumor",
107107
"tissueOntology": {
108108
"name": "UBERON",
109109
"version": "1.5"
@@ -113,7 +113,7 @@
113113
"sampleDate": "2023-06-21",
114114
"sampleConservation": "cryo-frozen",
115115
"sequenceType": "dna",
116-
"sequenceSubtype": "other",
116+
"sequenceSubtype": "somatic",
117117
"fragmentationMethod": "none",
118118
"libraryType": "wgs_lr",
119119
"libraryPrepKit": "SMRTbell™ Express Template Prep Kit",
@@ -137,10 +137,10 @@
137137
"bioinformaticsPipelineVersion": "v3.4.1",
138138
"referenceGenome": "GRCh38",
139139
"percentBasesAboveQualityThreshold": {
140-
"minimumQuality": 50,
140+
"minimumQuality": 20,
141141
"percent": 88
142142
},
143-
"meanDepthOfCoverage": 40,
143+
"meanDepthOfCoverage": 100,
144144
"minCoverage": 30,
145145
"targetedRegionsAboveMinCoverage": 0.9,
146146
"nonCodingVariants": true,

packages/grz-pydantic-models/tests/resources/failing_metadata/duplicate-run-id.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://raw.githubusercontent.com/BfArM-MVH/MVGenomseq/refs/tags/v1.1.1/GRZ/grz-schema.json",
2+
"$schema": "https://raw.githubusercontent.com/BfArM-MVH/MVGenomseq/refs/tags/v1.2.1/GRZ/grz-schema.json",
33
"submission": {
44
"submissionDate": "2024-07-15",
55
"submissionType": "initial",
@@ -10,9 +10,9 @@
1010
"genomicDataCenterId": "GRZK00007",
1111
"clinicalDataNodeId": "KDKK00007",
1212
"genomicStudyType": "single",
13-
"genomicStudySubtype": "tumor-only",
13+
"genomicStudySubtype": "germline-only",
1414
"coverageType": "GKV",
15-
"diseaseType": "oncological"
15+
"diseaseType": "rare"
1616
},
1717
"donors": [
1818
{

packages/grz-pydantic-models/tests/resources/failing_metadata/incompatible-reference-genomes.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://raw.githubusercontent.com/BfArM-MVH/MVGenomseq/refs/tags/v1.1.1/GRZ/grz-schema.json",
2+
"$schema": "https://raw.githubusercontent.com/BfArM-MVH/MVGenomseq/refs/tags/v1.2.1/GRZ/grz-schema.json",
33
"submission": {
44
"submissionDate": "2024-07-15",
55
"submissionType": "initial",
@@ -10,9 +10,9 @@
1010
"genomicDataCenterId": "GRZK00007",
1111
"clinicalDataNodeId": "KDKK00007",
1212
"genomicStudyType": "duo",
13-
"genomicStudySubtype": "tumor+germline",
13+
"genomicStudySubtype": "germline-only",
1414
"coverageType": "GKV",
15-
"diseaseType": "oncological"
15+
"diseaseType": "rare"
1616
},
1717
"donors": [
1818
{

packages/grz-pydantic-models/tests/resources/failing_metadata/missing-fastq-r2.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://raw.githubusercontent.com/BfArM-MVH/MVGenomseq/refs/tags/v1.1.1/GRZ/grz-schema.json",
2+
"$schema": "https://raw.githubusercontent.com/BfArM-MVH/MVGenomseq/refs/tags/v1.2.1/GRZ/grz-schema.json",
33
"submission": {
44
"submissionDate": "2024-07-15",
55
"submissionType": "initial",
@@ -10,9 +10,9 @@
1010
"genomicDataCenterId": "GRZK00007",
1111
"clinicalDataNodeId": "KDKK00007",
1212
"genomicStudyType": "single",
13-
"genomicStudySubtype": "tumor-only",
13+
"genomicStudySubtype": "germline-only",
1414
"coverageType": "GKV",
15-
"diseaseType": "oncological"
15+
"diseaseType": "rare"
1616
},
1717
"donors": [
1818
{

packages/grz-pydantic-models/tests/resources/failing_metadata/missing-read-order.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://raw.githubusercontent.com/BfArM-MVH/MVGenomseq/refs/tags/v1.1.1/GRZ/grz-schema.json",
2+
"$schema": "https://raw.githubusercontent.com/BfArM-MVH/MVGenomseq/refs/tags/v1.2.1/GRZ/grz-schema.json",
33
"submission": {
44
"submissionDate": "2024-07-15",
55
"submissionType": "initial",
@@ -10,9 +10,9 @@
1010
"genomicDataCenterId": "GRZK00007",
1111
"clinicalDataNodeId": "KDKK00007",
1212
"genomicStudyType": "single",
13-
"genomicStudySubtype": "tumor-only",
13+
"genomicStudySubtype": "germline-only",
1414
"coverageType": "GKV",
15-
"diseaseType": "oncological"
15+
"diseaseType": "rare"
1616
},
1717
"donors": [
1818
{

packages/grz-pydantic-models/tests/resources/failing_metadata/missing-target-regions.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://raw.githubusercontent.com/BfArM-MVH/MVGenomseq/refs/tags/v1.1.1/GRZ/grz-schema.json",
2+
"$schema": "https://raw.githubusercontent.com/BfArM-MVH/MVGenomseq/refs/tags/v1.2.1/GRZ/grz-schema.json",
33
"submission": {
44
"submissionDate": "2024-07-15",
55
"submissionType": "initial",
@@ -10,9 +10,9 @@
1010
"genomicDataCenterId": "GRZK00007",
1111
"clinicalDataNodeId": "KDKK00007",
1212
"genomicStudyType": "single",
13-
"genomicStudySubtype": "tumor-only",
13+
"genomicStudySubtype": "germline-only",
1414
"coverageType": "GKV",
15-
"diseaseType": "oncological"
15+
"diseaseType": "rare"
1616
},
1717
"donors": [
1818
{

0 commit comments

Comments
 (0)