Skip to content

Commit bdff7ab

Browse files
committed
Add Scott score range models
1 parent 86c3f74 commit bdff7ab

File tree

3 files changed

+62
-1
lines changed

3 files changed

+62
-1
lines changed

src/mavedb/view_models/score_range.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,33 @@ class InvestigatorScoreRanges(BrnichScoreRanges, SavedInvestigatorScoreRanges):
275275
pass
276276

277277

278+
##############################################################################################################
279+
# Scott score range models
280+
##############################################################################################################
281+
282+
283+
class ScottScoreRangesBase(BrnichScoreRangesBase):
284+
title: str = "Scott calibration"
285+
286+
287+
class ScottScoreRangesModify(BrnichScoreRangesModify, ScottScoreRangesBase):
288+
pass
289+
290+
291+
class ScottScoreRangesCreate(BrnichScoreRangesCreate, ScottScoreRangesModify):
292+
pass
293+
294+
295+
class SavedScottScoreRanges(SavedBrnichScoreRanges, ScottScoreRangesBase):
296+
record_type: str = None # type: ignore
297+
298+
_record_type_factory = record_type_validator()(set_record_type)
299+
300+
301+
class ScottScoreRanges(BrnichScoreRanges, SavedScottScoreRanges):
302+
pass
303+
304+
278305
##############################################################################################################
279306
# Zeiberg specific calibration models
280307
##############################################################################################################
@@ -378,13 +405,14 @@ class ZeibergCalibrationScoreRanges(ScoreRanges, SavedZeibergCalibrationScoreRan
378405

379406
class ScoreSetRangesBase(BaseModel):
380407
investigator_provided: Optional[InvestigatorScoreRangesBase] = None
408+
scott_calibration: Optional[ScottScoreRangesBase] = None
381409
zeiberg_calibration: Optional[ZeibergCalibrationScoreRangesBase] = None
382410

383411
_fields_to_exclude_for_validatation = {"record_type"}
384412

385413
@model_validator(mode="after")
386414
def score_range_labels_must_be_unique(self: "ScoreSetRangesBase") -> "ScoreSetRangesBase":
387-
for container in (self.investigator_provided, self.zeiberg_calibration):
415+
for container in (self.investigator_provided, self.zeiberg_calibration, self.scott_calibration):
388416
if container is None:
389417
continue
390418

@@ -405,23 +433,27 @@ def score_range_labels_must_be_unique(self: "ScoreSetRangesBase") -> "ScoreSetRa
405433

406434
class ScoreSetRangesModify(ScoreSetRangesBase):
407435
investigator_provided: Optional[InvestigatorScoreRangesModify] = None
436+
scott_calibration: Optional[ScottScoreRangesModify] = None
408437
zeiberg_calibration: Optional[ZeibergCalibrationScoreRangesModify] = None
409438

410439

411440
class ScoreSetRangesCreate(ScoreSetRangesModify):
412441
investigator_provided: Optional[InvestigatorScoreRangesCreate] = None
442+
scott_calibration: Optional[ScottScoreRangesCreate] = None
413443
zeiberg_calibration: Optional[ZeibergCalibrationScoreRangesCreate] = None
414444

415445

416446
class SavedScoreSetRanges(ScoreSetRangesBase):
417447
record_type: str = None # type: ignore
418448

419449
investigator_provided: Optional[SavedInvestigatorScoreRanges] = None
450+
scott_calibration: Optional[SavedScottScoreRanges] = None
420451
zeiberg_calibration: Optional[SavedZeibergCalibrationScoreRanges] = None
421452

422453
_record_type_factory = record_type_validator()(set_record_type)
423454

424455

425456
class ScoreSetRanges(SavedScoreSetRanges):
426457
investigator_provided: Optional[InvestigatorScoreRanges] = None
458+
scott_calibration: Optional[ScottScoreRanges] = None
427459
zeiberg_calibration: Optional[ZeibergCalibrationScoreRanges] = None

tests/routers/test_score_set.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
TEST_SAVED_SCORE_SET_RANGES_ONLY_INVESTIGATOR_PROVIDED,
5151
TEST_SCORE_SET_RANGES_ONLY_ZEIBERG_CALIBRATION,
5252
TEST_SAVED_SCORE_SET_RANGES_ONLY_ZEIBERG_CALIBRATION,
53+
TEST_SCORE_SET_RANGES_ONLY_SCOTT,
54+
TEST_SAVED_SCORE_SET_RANGES_ONLY_SCOTT,
5355
TEST_SCORE_SET_RANGES_ALL_SCHEMAS_PRESENT,
5456
TEST_SAVED_SCORE_SET_RANGES_ALL_SCHEMAS_PRESENT,
5557
TEST_GNOMAD_DATA_VERSION,
@@ -162,6 +164,7 @@ def test_create_score_set_with_contributor(client, setup_router_db):
162164
"score_ranges,saved_score_ranges",
163165
[
164166
(TEST_SCORE_SET_RANGES_ONLY_INVESTIGATOR_PROVIDED, TEST_SAVED_SCORE_SET_RANGES_ONLY_INVESTIGATOR_PROVIDED),
167+
(TEST_SCORE_SET_RANGES_ONLY_SCOTT, TEST_SAVED_SCORE_SET_RANGES_ONLY_SCOTT),
165168
(TEST_SCORE_SET_RANGES_ONLY_ZEIBERG_CALIBRATION, TEST_SAVED_SCORE_SET_RANGES_ONLY_ZEIBERG_CALIBRATION),
166169
(TEST_SCORE_SET_RANGES_ALL_SCHEMAS_PRESENT, TEST_SAVED_SCORE_SET_RANGES_ALL_SCHEMAS_PRESENT),
167170
],
@@ -210,6 +213,7 @@ def test_create_score_set_with_score_range(
210213
"score_ranges",
211214
[
212215
TEST_SCORE_SET_RANGES_ONLY_INVESTIGATOR_PROVIDED,
216+
TEST_SCORE_SET_RANGES_ONLY_SCOTT,
213217
TEST_SCORE_SET_RANGES_ONLY_ZEIBERG_CALIBRATION,
214218
TEST_SCORE_SET_RANGES_ALL_SCHEMAS_PRESENT,
215219
],
@@ -252,6 +256,7 @@ def test_cannot_create_score_set_with_nonexistent_contributor(client, setup_rout
252256
"score_ranges,saved_score_ranges",
253257
[
254258
(TEST_SCORE_SET_RANGES_ONLY_INVESTIGATOR_PROVIDED, TEST_SAVED_SCORE_SET_RANGES_ONLY_INVESTIGATOR_PROVIDED),
259+
(TEST_SCORE_SET_RANGES_ONLY_SCOTT, TEST_SAVED_SCORE_SET_RANGES_ONLY_SCOTT),
255260
(TEST_SCORE_SET_RANGES_ONLY_ZEIBERG_CALIBRATION, TEST_SAVED_SCORE_SET_RANGES_ONLY_ZEIBERG_CALIBRATION),
256261
(TEST_SCORE_SET_RANGES_ALL_SCHEMAS_PRESENT, TEST_SAVED_SCORE_SET_RANGES_ALL_SCHEMAS_PRESENT),
257262
],

tests/view_models/test_score_range.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
InvestigatorScoreRangesCreate,
1919
InvestigatorScoreRangesModify,
2020
InvestigatorScoreRanges,
21+
ScottScoreRangesCreate,
22+
ScottScoreRangesModify,
23+
ScottScoreRanges,
2124
ZeibergCalibrationScoreRangeCreate,
2225
ZeibergCalibrationScoreRangeModify,
2326
ZeibergCalibrationScoreRange,
@@ -354,6 +357,9 @@ def test_score_ranges_base_valid_range(ScoreRangesModel, score_ranges_data):
354357
InvestigatorScoreRanges,
355358
InvestigatorScoreRangesCreate,
356359
InvestigatorScoreRangesModify,
360+
ScottScoreRanges,
361+
ScottScoreRangesCreate,
362+
ScottScoreRangesModify,
357363
],
358364
)
359365
def test_score_ranges_brnich_valid_range(ScoreRangesModel, score_ranges_data):
@@ -413,6 +419,9 @@ def test_score_ranges_zeiberg_calibration_valid_range(ScoreRangesModel, score_ra
413419
(InvestigatorScoreRanges, BrnichScoreRange),
414420
(InvestigatorScoreRangesCreate, BrnichScoreRangeCreate),
415421
(InvestigatorScoreRangesModify, BrnichScoreRangeModify),
422+
(ScottScoreRanges, BrnichScoreRange),
423+
(ScottScoreRangesCreate, BrnichScoreRangeCreate),
424+
(ScottScoreRangesModify, BrnichScoreRangeModify),
416425
],
417426
)
418427
def test_score_ranges_ranges_may_not_overlap(ScoreRangesModel, ScoreRangeModel):
@@ -443,6 +452,9 @@ def test_score_ranges_ranges_may_not_overlap(ScoreRangesModel, ScoreRangeModel):
443452
(InvestigatorScoreRanges, BrnichScoreRange),
444453
(InvestigatorScoreRangesCreate, BrnichScoreRangeCreate),
445454
(InvestigatorScoreRangesModify, BrnichScoreRangeModify),
455+
(ScottScoreRanges, BrnichScoreRange),
456+
(ScottScoreRangesCreate, BrnichScoreRangeCreate),
457+
(ScottScoreRangesModify, BrnichScoreRangeModify),
446458
],
447459
)
448460
def test_score_ranges_ranges_may_not_overlap_via_inclusive_bounds(ScoreRangesModel, ScoreRangeModel):
@@ -485,6 +497,9 @@ def test_score_ranges_ranges_may_not_overlap_via_inclusive_bounds(ScoreRangesMod
485497
(InvestigatorScoreRanges, BrnichScoreRange),
486498
(InvestigatorScoreRangesCreate, BrnichScoreRangeCreate),
487499
(InvestigatorScoreRangesModify, BrnichScoreRangeModify),
500+
(ScottScoreRanges, BrnichScoreRange),
501+
(ScottScoreRangesCreate, BrnichScoreRangeCreate),
502+
(ScottScoreRangesModify, BrnichScoreRangeModify),
488503
],
489504
)
490505
@pytest.mark.parametrize(
@@ -638,6 +653,9 @@ def test_score_ranges_zeiberg_calibration_ranges_boundaries_may_be_adjacent(
638653
InvestigatorScoreRanges,
639654
InvestigatorScoreRangesCreate,
640655
InvestigatorScoreRangesModify,
656+
ScottScoreRanges,
657+
ScottScoreRangesCreate,
658+
ScottScoreRangesModify,
641659
],
642660
)
643661
def test_score_ranges_brnich_normal_classification_exists_if_baseline_score_provided(ScoreRangesModel):
@@ -659,6 +677,9 @@ def test_score_ranges_brnich_normal_classification_exists_if_baseline_score_prov
659677
InvestigatorScoreRanges,
660678
InvestigatorScoreRangesCreate,
661679
InvestigatorScoreRangesModify,
680+
ScottScoreRanges,
681+
ScottScoreRangesCreate,
682+
ScottScoreRangesModify,
662683
],
663684
)
664685
def test_score_ranges_brnich_baseline_score_within_normal_range(ScoreRangesModel):
@@ -684,6 +705,9 @@ def test_score_ranges_brnich_baseline_score_within_normal_range(ScoreRangesModel
684705
InvestigatorScoreRanges,
685706
InvestigatorScoreRangesCreate,
686707
InvestigatorScoreRangesModify,
708+
ScottScoreRanges,
709+
ScottScoreRangesCreate,
710+
ScottScoreRangesModify,
687711
],
688712
)
689713
def test_score_ranges_brnich_baseline_type_score_provided_if_normal_range_exists(ScoreRangesModel):

0 commit comments

Comments
 (0)