99from mavedb .scripts .environment import with_database_session
1010from mavedb .models .score_set import ScoreSet
1111from mavedb .view_models .score_range import (
12- PillarProjectScoreRangeCreate ,
13- PillarProjectScoreRangesCreate ,
12+ ZeibergCalibrationScoreRangeCreate ,
13+ ZeibergCalibrationScoreRangesCreate ,
1414 ScoreSetRangesCreate ,
1515)
1616
@@ -47,7 +47,9 @@ def _collapse_duplicate_thresholds(m: dict[int, Optional[float]], comparator: Ca
4747 return collapsed
4848
4949
50- def build_pathogenic_ranges (thresholds : List [Optional [float ]], inverted : bool ) -> List [PillarProjectScoreRangeCreate ]:
50+ def build_pathogenic_ranges (
51+ thresholds : List [Optional [float ]], inverted : bool
52+ ) -> List [ZeibergCalibrationScoreRangeCreate ]:
5153 raw_mapping = {
5254 strength : thresholds [idx ]
5355 for idx , strength in enumerate (PATH_STRENGTHS )
@@ -61,7 +63,7 @@ def build_pathogenic_ranges(thresholds: List[Optional[float]], inverted: bool) -
6163 available = [s for s in PATH_STRENGTHS if s in mapping ]
6264 ordering = available [::- 1 ] if not inverted else available
6365
64- ranges : List [PillarProjectScoreRangeCreate ] = []
66+ ranges : List [ZeibergCalibrationScoreRangeCreate ] = []
6567 for i , s in enumerate (ordering ):
6668 lower : Optional [float ]
6769 upper : Optional [float ]
@@ -74,7 +76,7 @@ def build_pathogenic_ranges(thresholds: List[Optional[float]], inverted: bool) -
7476 upper = mapping [s ]
7577
7678 ranges .append (
77- PillarProjectScoreRangeCreate (
79+ ZeibergCalibrationScoreRangeCreate (
7880 label = str (s ),
7981 classification = "abnormal" ,
8082 evidence_strength = s ,
@@ -87,7 +89,7 @@ def build_pathogenic_ranges(thresholds: List[Optional[float]], inverted: bool) -
8789 return ranges
8890
8991
90- def build_benign_ranges (thresholds : List [Optional [float ]], inverted : bool ) -> List [PillarProjectScoreRangeCreate ]:
92+ def build_benign_ranges (thresholds : List [Optional [float ]], inverted : bool ) -> List [ZeibergCalibrationScoreRangeCreate ]:
9193 raw_mapping = {
9294 strength : thresholds [idx ]
9395 for idx , strength in enumerate (BENIGN_STRENGTHS )
@@ -101,7 +103,7 @@ def build_benign_ranges(thresholds: List[Optional[float]], inverted: bool) -> Li
101103 available = [s for s in BENIGN_STRENGTHS if s in mapping ]
102104 ordering = available [::- 1 ] if inverted else available
103105
104- ranges : List [PillarProjectScoreRangeCreate ] = []
106+ ranges : List [ZeibergCalibrationScoreRangeCreate ] = []
105107 for i , s in enumerate (ordering ):
106108 lower : Optional [float ]
107109 upper : Optional [float ]
@@ -114,7 +116,7 @@ def build_benign_ranges(thresholds: List[Optional[float]], inverted: bool) -> Li
114116 upper = mapping [s ]
115117
116118 ranges .append (
117- PillarProjectScoreRangeCreate (
119+ ZeibergCalibrationScoreRangeCreate (
118120 label = str (s ),
119121 classification = "normal" ,
120122 evidence_strength = s ,
@@ -133,12 +135,12 @@ def build_benign_ranges(thresholds: List[Optional[float]], inverted: bool) -> Li
133135@click .argument ("score_set_urn" , type = str )
134136@click .option ("--overwrite" , is_flag = True , default = False , help = "Overwrite existing score_ranges if present." )
135137def main (db : Session , json_path : str , score_set_urn : str , overwrite : bool ) -> None :
136- """Load pillar project calibration JSON into a score set's pillar_project score ranges."""
138+ """Load pillar project calibration JSON into a score set's zeiberg_calibration score ranges."""
137139 score_set : Optional [ScoreSet ] = db .query (ScoreSet ).filter (ScoreSet .urn == score_set_urn ).one_or_none ()
138140 if not score_set :
139141 raise click .ClickException (f"Score set with URN { score_set_urn } not found" )
140142
141- if score_set .score_ranges and score_set .score_ranges ["pillar_project " ] and not overwrite :
143+ if score_set .score_ranges and score_set .score_ranges ["zeiberg_calibration " ] and not overwrite :
142144 raise click .ClickException (
143145 "pillar project score ranges already present for this score set. Use --overwrite to replace them."
144146 )
@@ -162,7 +164,7 @@ def main(db: Session, json_path: str, score_set_urn: str, overwrite: bool) -> No
162164 if not path_ranges and not benign_ranges :
163165 raise click .ClickException ("No valid thresholds found to build ranges." )
164166
165- existing_score_ranges .pillar_project = PillarProjectScoreRangesCreate (ranges = path_ranges + benign_ranges )
167+ existing_score_ranges .zeiberg_calibration = ZeibergCalibrationScoreRangesCreate (ranges = path_ranges + benign_ranges )
166168 score_set .score_ranges = existing_score_ranges .model_dump (exclude_none = True )
167169
168170 db .add (score_set )
0 commit comments