Skip to content

Commit 268b5e9

Browse files
committed
feat: unbounded zeiberg ranges to infinity, inclusive boundary logic for lower points, citation information
1 parent 5326b5d commit 268b5e9

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

src/mavedb/scripts/load_pp_style_calibration.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
}
103103

104104
ALL_POINT_LABEL_MAPPINGS = {**POINT_LABEL_MAPPINGS, **{k * -1: v for k, v in POINT_LABEL_MAPPINGS.items()}}
105+
ZEIBERG_CALIBRATION_CITATION = {"identifier": "2025.04.29.651326", "db_name": "bioRxiv"}
105106

106107

107108
@click.command()
@@ -181,25 +182,45 @@ def main(db: Session, archive_path: str, dataset_map: str, overwrite: bool) -> N
181182
db.flush()
182183
click.echo(f" Overwriting existing '{calibration_name}' in Score Set {score_set.urn}")
183184

185+
benign_has_lower_functional_scores = calibration_data.get("scoreset_flipped", False)
184186
functional_ranges: List[score_calibration.FunctionalRangeCreate] = []
185187
for points, range_data in calibration_data.get("point_ranges", {}).items():
186188
if not range_data:
187189
continue
188190

189-
range_data = tuple(float(bound) for bound in range_data[0])
191+
lower_bound, upper_bound = range_data[0][0], range_data[0][1]
192+
193+
if lower_bound == float("-inf"):
194+
lower_bound = None
195+
if upper_bound == float("inf"):
196+
upper_bound = None
197+
198+
range_data = (lower_bound, upper_bound)
190199
points = int(points.strip())
191200
ps_or_bs = "PS3" if points > 0 else "BS3"
192201
strength_label = ALL_POINT_LABEL_MAPPINGS.get(points, "Unknown")
193202

203+
# The boundary of the functional range closest to the implied indeterminate range
204+
# will always be non-inclusive, as we assign any variants with this score to the
205+
# lowest points value.
206+
if (benign_has_lower_functional_scores and points < 0) or (
207+
not benign_has_lower_functional_scores and points > 0
208+
):
209+
inclusive_lower = True if lower_bound is not None else False
210+
inclusive_upper = False
211+
else:
212+
inclusive_lower = False
213+
inclusive_upper = True if upper_bound is not None else False
214+
194215
functional_range = score_calibration.FunctionalRangeCreate(
195216
label=f"{ps_or_bs} {strength_label} ({points})",
196217
classification="abnormal" if points > 0 else "normal",
197218
range=range_data,
198219
acmg_classification=acmg_classification.ACMGClassificationCreate(
199220
points=int(points),
200221
),
201-
inclusive_lower_bound=True,
202-
inclusive_upper_bound=False,
222+
inclusive_lower_bound=inclusive_lower,
223+
inclusive_upper_bound=inclusive_upper,
203224
)
204225
functional_ranges.append(functional_range)
205226

@@ -209,6 +230,7 @@ def main(db: Session, archive_path: str, dataset_map: str, overwrite: bool) -> N
209230
research_use_only=True,
210231
score_set_urn=score_set.urn,
211232
calibration_metadata={"prior_probability_pathogenicity": calibration_data.get("prior", None)},
233+
method_sources=[ZEIBERG_CALIBRATION_CITATION],
212234
)
213235

214236
new_calibration_object = asyncio.run(

0 commit comments

Comments
 (0)