Skip to content

Commit fc20f40

Browse files
committed
feat: don't allow class-based calibrations during score set creatoin
1 parent c4f3a3f commit fc20f40

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

src/mavedb/routers/score_sets.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1551,7 +1551,20 @@ async def create_score_set(
15511551
score_calibrations: list[ScoreCalibration] = []
15521552
if item_create.score_calibrations:
15531553
for calibration_create in item_create.score_calibrations:
1554-
created_calibration_item = await create_score_calibration(db, calibration_create, user_data.user)
1554+
# TODO#592: Support for class-based calibrations on score set creation
1555+
if calibration_create.class_based:
1556+
logger.info(
1557+
msg="Failed to create score set; Class-based calibrations are not supported on score set creation.",
1558+
extra=logging_context(),
1559+
)
1560+
raise HTTPException(
1561+
status_code=409,
1562+
detail="Class-based calibrations are not supported on score set creation. Please create class-based calibrations after creating the score set.",
1563+
)
1564+
1565+
created_calibration_item = await create_score_calibration(
1566+
db, calibration_create, user_data.user, variant_classes=None
1567+
)
15551568
created_calibration_item.investigator_provided = True # necessarily true on score set creation
15561569
score_calibrations.append(created_calibration_item)
15571570

tests/routers/test_score_set.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
SAVED_PUBMED_PUBLICATION,
3636
SAVED_SHORT_EXTRA_LICENSE,
3737
TEST_BIORXIV_IDENTIFIER,
38+
TEST_BRNICH_SCORE_CALIBRATION_CLASS_BASED,
3839
TEST_BRNICH_SCORE_CALIBRATION_RANGE_BASED,
3940
TEST_CROSSREF_IDENTIFIER,
4041
TEST_GNOMAD_DATA_VERSION,
@@ -234,6 +235,34 @@ def test_create_score_set_with_score_calibration(client, mock_publication_fetch,
234235
assert response.status_code == 200
235236

236237

238+
@pytest.mark.parametrize(
239+
"mock_publication_fetch",
240+
[
241+
(
242+
[
243+
{"dbName": "PubMed", "identifier": f"{TEST_PUBMED_IDENTIFIER}"},
244+
{"dbName": "bioRxiv", "identifier": f"{TEST_BIORXIV_IDENTIFIER}"},
245+
]
246+
)
247+
],
248+
indirect=["mock_publication_fetch"],
249+
)
250+
def test_cannot_create_score_set_with_class_based_calibration(client, mock_publication_fetch, setup_router_db):
251+
experiment = create_experiment(client)
252+
score_set = deepcopy(TEST_MINIMAL_SEQ_SCORESET)
253+
score_set["experimentUrn"] = experiment["urn"]
254+
score_set.update(
255+
{
256+
"scoreCalibrations": [deepcamelize(TEST_BRNICH_SCORE_CALIBRATION_CLASS_BASED)],
257+
}
258+
)
259+
260+
response = client.post("/api/v1/score-sets/", json=score_set)
261+
assert response.status_code == 409
262+
response_data = response.json()
263+
assert "Class-based calibrations are not supported on score set creation" in response_data["detail"]
264+
265+
237266
@pytest.mark.parametrize(
238267
"mock_publication_fetch",
239268
[

0 commit comments

Comments
 (0)