Skip to content

Commit c49fd05

Browse files
authored
Merge pull request #519 from VariantEffect/feature/bencap/517/additional-brnich-style-calibrations
Additional Brnich Style Calibrations
2 parents d088e1a + 20be535 commit c49fd05

20 files changed

+680
-303
lines changed

alembic/manual_migrations/migrate_consolidated_score_ranges_and_calibrations.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from sqlalchemy.orm import Session
1010

1111
from mavedb.models.score_set import ScoreSet
12-
from mavedb.view_models.score_range import ScoreSetRangesCreate, InvestigatorScoreRangesCreate, PillarProjectScoreRangesCreate, PillarProjectScoreRangeCreate
12+
from mavedb.view_models.score_range import ScoreSetRangesCreate, InvestigatorScoreRangesCreate, ZeibergCalibrationScoreRangesCreate, ZeibergCalibrationScoreRangeCreate
1313

1414

1515
from mavedb.db.session import SessionLocal
@@ -47,11 +47,11 @@ def do_migration(db: Session):
4747
investigator_ranges = None
4848

4949
if score_set.score_calibrations is not None:
50-
thresholds = score_set.score_calibrations.get("pillar_project", {}).get("thresholds", [])
51-
evidence_strengths = score_set.score_calibrations.get("pillar_project", {}).get("evidence_strengths", [])
52-
positive_likelihood_ratios = score_set.score_calibrations.get("pillar_project", {}).get("positive_likelihood_ratios", [])
53-
prior_probability_pathogenicity = score_set.score_calibrations.get("pillar_project", {}).get("prior_probability_pathogenicity", None)
54-
parameter_sets = score_set.score_calibrations.get("pillar_project", {}).get("parameter_sets", [])
50+
thresholds = score_set.score_calibrations.get("zeiberg_calibration", {}).get("thresholds", [])
51+
evidence_strengths = score_set.score_calibrations.get("zeiberg_calibration", {}).get("evidence_strengths", [])
52+
positive_likelihood_ratios = score_set.score_calibrations.get("zeiberg_calibration", {}).get("positive_likelihood_ratios", [])
53+
prior_probability_pathogenicity = score_set.score_calibrations.get("zeiberg_calibration", {}).get("prior_probability_pathogenicity", None)
54+
parameter_sets = score_set.score_calibrations.get("zeiberg_calibration", {}).get("parameter_sets", [])
5555

5656
ranges = []
5757
boundary_direction = -1 # Start with a negative sign to indicate the first range has the lower boundary appearing prior to the threshold
@@ -60,7 +60,7 @@ def do_migration(db: Session):
6060

6161
if idx == 0:
6262
calculated_range = (None, threshold)
63-
ranges.append(PillarProjectScoreRangeCreate(
63+
ranges.append(ZeibergCalibrationScoreRangeCreate(
6464
range=(None, threshold),
6565
classification="normal" if evidence_strength < 0 else "abnormal",
6666
label=str(evidence_strength),
@@ -71,7 +71,7 @@ def do_migration(db: Session):
7171
))
7272
elif idx == len(thresholds) - 1:
7373
calculated_range = (threshold, None)
74-
ranges.append(PillarProjectScoreRangeCreate(
74+
ranges.append(ZeibergCalibrationScoreRangeCreate(
7575
range=(threshold, None),
7676
classification="normal" if evidence_strength < 0 else "abnormal",
7777
evidence_strength=evidence_strength,
@@ -86,7 +86,7 @@ def do_migration(db: Session):
8686
else:
8787
calculated_range = (threshold, thresholds[idx + 1])
8888

89-
ranges.append(PillarProjectScoreRangeCreate(
89+
ranges.append(ZeibergCalibrationScoreRangeCreate(
9090
range=calculated_range,
9191
classification="normal" if evidence_strength < 0 else "abnormal",
9292
label=str(evidence_strength),
@@ -100,17 +100,17 @@ def do_migration(db: Session):
100100
if idx != len(evidence_strengths) - 1 and (evidence_strengths[idx + 1] * evidence_strength < 0):
101101
boundary_direction = -boundary_direction
102102

103-
pillar_project_ranges = PillarProjectScoreRangesCreate(
103+
zeiberg_calibration_ranges = ZeibergCalibrationScoreRangesCreate(
104104
prior_probability_pathogenicity=prior_probability_pathogenicity,
105105
parameter_sets=parameter_sets,
106106
ranges=ranges,
107107
)
108108
else:
109-
pillar_project_ranges = None
109+
zeiberg_calibration_ranges = None
110110

111111
score_set.score_ranges = ScoreSetRangesCreate(
112112
investigator_provided=investigator_ranges if investigator_ranges else None,
113-
pillar_project=pillar_project_ranges if pillar_project_ranges else None,
113+
zeiberg_calibration=zeiberg_calibration_ranges if zeiberg_calibration_ranges else None,
114114
).model_dump()
115115
db.add(score_set)
116116

src/mavedb/lib/annotation/agent.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ def mavedb_user_agent(user: User) -> Agent:
5858

5959

6060
# XXX: Ideally, this becomes versioned software.
61-
def pillar_project_calibration_agent() -> Agent:
61+
def zeiberg_calibration_agent() -> Agent:
6262
"""
6363
Create a [VA Agent](https://va-ga4gh.readthedocs.io/en/latest/core-information-model/entities/agent.html)
64-
object for the pillar project calibration software.
64+
object for the Zeiberg calibration software.
6565
"""
6666
return Agent(
67-
name="Pillar Project Variant Calibrator",
67+
name="Zeiberg Variant Calibrator",
6868
agentType="Software",
6969
# XXX - version?
70-
description="Pillar project variant calibrator, see https://github.com/Dzeiberg/mave_calibration",
70+
description="Zeiberg variant calibrator, see https://github.com/Dzeiberg/mave_calibration",
7171
)

src/mavedb/lib/annotation/classification.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from ga4gh.va_spec.base.enums import StrengthOfEvidenceProvided
77

88
from mavedb.models.mapped_variant import MappedVariant
9-
from mavedb.lib.annotation.constants import PILLAR_PROJECT_CALIBRATION_STRENGTH_OF_EVIDENCE_MAP
9+
from mavedb.lib.annotation.constants import ZEIBERG_CALIBRATION_CALIBRATION_STRENGTH_OF_EVIDENCE_MAP
1010
from mavedb.lib.validation.utilities import inf_or_float
1111
from mavedb.view_models.score_range import ScoreSetRanges
1212

@@ -60,7 +60,7 @@ def functional_classification_of_variant(
6060
return ExperimentalVariantFunctionalImpactClassification.INDETERMINATE
6161

6262

63-
def pillar_project_clinical_classification_of_variant(
63+
def zeiberg_calibration_clinical_classification_of_variant(
6464
mapped_variant: MappedVariant,
6565
) -> tuple[VariantPathogenicityEvidenceLine.Criterion, Optional[StrengthOfEvidenceProvided]]:
6666
if mapped_variant.variant.score_set.score_ranges is None:
@@ -69,7 +69,7 @@ def pillar_project_clinical_classification_of_variant(
6969
" Unable to classify clinical impact."
7070
)
7171

72-
score_ranges = ScoreSetRanges(**mapped_variant.variant.score_set.score_ranges).pillar_project
72+
score_ranges = ScoreSetRanges(**mapped_variant.variant.score_set.score_ranges).zeiberg_calibration
7373

7474
if not score_ranges:
7575
raise ValueError(
@@ -88,6 +88,6 @@ def pillar_project_clinical_classification_of_variant(
8888
for range in score_ranges.ranges:
8989
lower_bound, upper_bound = inf_or_float(range.range[0], lower=True), inf_or_float(range.range[1], lower=False)
9090
if functional_score > lower_bound and functional_score <= upper_bound:
91-
return PILLAR_PROJECT_CALIBRATION_STRENGTH_OF_EVIDENCE_MAP[range.evidence_strength]
91+
return ZEIBERG_CALIBRATION_CALIBRATION_STRENGTH_OF_EVIDENCE_MAP[range.evidence_strength]
9292

93-
return PILLAR_PROJECT_CALIBRATION_STRENGTH_OF_EVIDENCE_MAP[0]
93+
return ZEIBERG_CALIBRATION_CALIBRATION_STRENGTH_OF_EVIDENCE_MAP[0]

src/mavedb/lib/annotation/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
GENERIC_DISEASE_MEDGEN_CODE = "C0012634"
55
MEDGEN_SYSTEM = "https://www.ncbi.nlm.nih.gov/medgen/"
66

7-
PILLAR_PROJECT_CALIBRATION_STRENGTH_OF_EVIDENCE_MAP = {
7+
ZEIBERG_CALIBRATION_CALIBRATION_STRENGTH_OF_EVIDENCE_MAP = {
88
# No evidence
99
0: (VariantPathogenicityEvidenceLine.Criterion.PS3, None),
1010
# Supporting evidence
@@ -31,4 +31,4 @@
3131

3232
# TODO#493
3333
FUNCTIONAL_RANGES = ["investigator_provided"]
34-
CLINICAL_RANGES = ["pillar_project"]
34+
CLINICAL_RANGES = ["zeiberg_calibration"]

src/mavedb/lib/annotation/contribution.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
mavedb_api_agent,
1111
mavedb_vrs_agent,
1212
mavedb_user_agent,
13-
pillar_project_calibration_agent,
13+
zeiberg_calibration_agent,
1414
)
1515
from mavedb.lib.types.annotation import ResourceWithCreationModificationDates
1616

@@ -46,15 +46,15 @@ def mavedb_vrs_contribution(mapped_variant: MappedVariant) -> Contribution:
4646
)
4747

4848

49-
def pillar_project_calibration_contribution() -> Contribution:
49+
def zeiberg_calibration_contribution() -> Contribution:
5050
"""
5151
Create a [VA Contribution](https://va-ga4gh.readthedocs.io/en/latest/core-information-model/entities/activities/contribution.html#contribution)
5252
object for a sofware agent which performs calibrations on an arbitrary data set.
5353
"""
5454
return Contribution(
55-
name="MaveDB Pillar Project Calibration",
56-
description="Contribution from the MaveDB Pillar Project Calibration software",
57-
contributor=pillar_project_calibration_agent(),
55+
name="Zeiberg Calibration",
56+
description="Contribution from the Zeiberg Calibration software",
57+
contributor=zeiberg_calibration_agent(),
5858
activityType="variant specific calibration software",
5959
)
6060

src/mavedb/lib/annotation/evidence_line.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@
1212
VariantPathogenicityProposition,
1313
)
1414

15-
from mavedb.lib.annotation.classification import pillar_project_clinical_classification_of_variant
15+
from mavedb.lib.annotation.classification import zeiberg_calibration_clinical_classification_of_variant
1616
from mavedb.lib.annotation.contribution import (
1717
mavedb_api_contribution,
1818
mavedb_vrs_contribution,
19-
pillar_project_calibration_contribution,
19+
zeiberg_calibration_contribution,
2020
mavedb_creator_contribution,
2121
mavedb_modifier_contribution,
2222
)
2323
from mavedb.lib.annotation.document import score_set_to_document
2424
from mavedb.lib.annotation.method import (
25-
pillar_project_calibration_method,
25+
zeiberg_calibration_method,
2626
publication_identifiers_to_method,
2727
)
2828
from mavedb.models.mapped_variant import MappedVariant
@@ -33,7 +33,7 @@ def acmg_evidence_line(
3333
proposition: VariantPathogenicityProposition,
3434
evidence: list[Union[StudyResult, EvidenceLineType, StatementType, iriReference]],
3535
) -> Optional[VariantPathogenicityEvidenceLine]:
36-
evidence_outcome, evidence_strength = pillar_project_clinical_classification_of_variant(mapped_variant)
36+
evidence_outcome, evidence_strength = zeiberg_calibration_clinical_classification_of_variant(mapped_variant)
3737

3838
if not evidence_strength:
3939
evidence_outcome_code = f"{evidence_outcome.value}_not_met"
@@ -59,7 +59,7 @@ def acmg_evidence_line(
5959

6060
return VariantPathogenicityEvidenceLine(
6161
description=f"Pathogenicity evidence line {mapped_variant.variant.urn}.",
62-
specifiedBy=pillar_project_calibration_method(evidence_outcome),
62+
specifiedBy=zeiberg_calibration_method(evidence_outcome),
6363
evidenceOutcome={
6464
"primaryCoding": Coding(
6565
code=evidence_outcome_code,
@@ -72,7 +72,7 @@ def acmg_evidence_line(
7272
contributions=[
7373
mavedb_api_contribution(),
7474
mavedb_vrs_contribution(mapped_variant),
75-
pillar_project_calibration_contribution(),
75+
zeiberg_calibration_contribution(),
7676
mavedb_creator_contribution(mapped_variant.variant, mapped_variant.variant.score_set.created_by),
7777
mavedb_modifier_contribution(mapped_variant.variant, mapped_variant.variant.score_set.modified_by),
7878
],

src/mavedb/lib/annotation/method.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,22 +86,22 @@ def mavedb_vrs_as_method() -> Method:
8686
return Method(name="Software version", reportedIn=mavedb_vrs_releases_as_iri())
8787

8888

89-
def pillar_project_calibrations_as_iri() -> IRI:
89+
def zeiberg_calibrations_as_iri() -> IRI:
9090
"""
9191
Create an IRI as described in <https://datatracker.ietf.org/doc/html/rfc3986#section-4.1> for the software used to generate pillar project calibrations. Within
9292
the context of VA-Spec, this IRI can be used interchangeably with an equivalent method object for brevity.
9393
"""
9494
return IRI("https://github.com/Dzeiberg/mave_calibration")
9595

9696

97-
def pillar_project_calibration_method(method: Optional[VariantPathogenicityEvidenceLine.Criterion]) -> Method:
97+
def zeiberg_calibration_method(method: Optional[VariantPathogenicityEvidenceLine.Criterion]) -> Method:
9898
"""
9999
Generate a [VA Method](https://va-ga4gh.readthedocs.io/en/latest/core-information-model/entities/information-entities/method.html#method)
100100
object for the pillar project calibration software distribution.
101101
"""
102102
return Method(
103103
name="Software version",
104-
reportedIn=pillar_project_calibrations_as_iri(),
104+
reportedIn=zeiberg_calibrations_as_iri(),
105105
methodType=method.value if method else None,
106106
)
107107

src/mavedb/scripts/load_pp_style_calibration.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
from mavedb.scripts.environment import with_database_session
1010
from mavedb.models.score_set import ScoreSet
1111
from 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.")
135137
def 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

Comments
 (0)