-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Estelle/test meta analysis #365
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1256,6 +1256,119 @@ def test_multiple_score_set_meta_analysis_multiple_experiment_sets_different_sco | |
assert meta_score_set_3["urn"] == "urn:mavedb:00000003-0-3" | ||
|
||
|
||
def test_cannot_add_score_set_to_meta_analysis_experiment(session, data_provider, client, setup_router_db, data_files): | ||
experiment = create_experiment(client) | ||
score_set_1 = create_seq_score_set_with_variants( | ||
client, session, data_provider, experiment["urn"], data_files / "scores.csv" | ||
) | ||
|
||
score_set_1 = (client.post(f"/api/v1/score-sets/{score_set_1['urn']}/publish")).json() | ||
meta_score_set_1 = create_seq_score_set_with_variants( | ||
client, | ||
session, | ||
data_provider, | ||
None, | ||
data_files / "scores.csv", | ||
update={"title": "Test Meta Analysis", "metaAnalyzesScoreSetUrns": [score_set_1["urn"]]}, | ||
) | ||
|
||
meta_score_set_1 = (client.post(f"/api/v1/score-sets/{meta_score_set_1['urn']}/publish")).json() | ||
assert isinstance(MAVEDB_SCORE_SET_URN_RE.fullmatch(meta_score_set_1["urn"]), re.Match) | ||
score_set_2 = deepcopy(TEST_MINIMAL_SEQ_SCORESET) | ||
score_set_2["experimentUrn"] = meta_score_set_1['experiment']['urn'] | ||
jsonschema.validate(instance=score_set_2, schema=ScoreSetCreate.schema()) | ||
|
||
response = client.post("/api/v1/score-sets/", json=score_set_2) | ||
response_data = response.json() | ||
assert response.status_code == 403 | ||
assert "Score sets may not be added to a meta-analysis experiment." in response_data["detail"] | ||
|
||
|
||
def test_create_single_score_set_meta_analysis_to_others_score_set(session, data_provider, client, setup_router_db, data_files): | ||
experiment = create_experiment(client) | ||
score_set = create_seq_score_set_with_variants( | ||
client, session, data_provider, experiment["urn"], data_files / "scores.csv" | ||
) | ||
|
||
score_set = (client.post(f"/api/v1/score-sets/{score_set['urn']}/publish")).json() | ||
change_ownership(session, score_set["urn"], ScoreSetDbModel) | ||
meta_score_set = create_seq_score_set_with_variants( | ||
client, | ||
session, | ||
data_provider, | ||
None, | ||
data_files / "scores.csv", | ||
update={"title": "Test Meta Analysis", "metaAnalyzesScoreSetUrns": [score_set["urn"]]}, | ||
) | ||
|
||
score_set_refresh = (client.get(f"/api/v1/score-sets/{score_set['urn']}")).json() | ||
assert meta_score_set["metaAnalyzesScoreSetUrns"] == [score_set["urn"]] | ||
assert score_set_refresh["metaAnalyzedByScoreSetUrns"] == [meta_score_set["urn"]] | ||
assert isinstance(MAVEDB_TMP_URN_RE.fullmatch(meta_score_set["urn"]), re.Match) | ||
|
||
|
||
def test_multiple_score_set_meta_analysis_single_experiment_with_different_creator( | ||
session, data_provider, client, setup_router_db, data_files | ||
): | ||
experiment = create_experiment(client) | ||
score_set_1 = create_seq_score_set_with_variants( | ||
client, session, data_provider, experiment["urn"], data_files / "scores.csv", update={"title": "Score Set 1"} | ||
) | ||
score_set_2 = create_seq_score_set_with_variants( | ||
client, session, data_provider, experiment["urn"], data_files / "scores.csv", update={"title": "Score Set 2"} | ||
) | ||
|
||
score_set_1 = (client.post(f"/api/v1/score-sets/{score_set_1['urn']}/publish")).json() | ||
score_set_2 = (client.post(f"/api/v1/score-sets/{score_set_2['urn']}/publish")).json() | ||
|
||
change_ownership(session, score_set_2["urn"], ScoreSetDbModel) | ||
meta_score_set = create_seq_score_set_with_variants( | ||
client, | ||
session, | ||
data_provider, | ||
None, | ||
data_files / "scores.csv", | ||
update={"title": "Test Meta Analysis", "metaAnalyzesScoreSetUrns": [score_set_1["urn"], score_set_2["urn"]]}, | ||
) | ||
score_set_1_refresh = (client.get(f"/api/v1/score-sets/{score_set_1['urn']}")).json() | ||
assert meta_score_set["metaAnalyzesScoreSetUrns"] == sorted([score_set_1["urn"], score_set_2["urn"]]) | ||
assert score_set_1_refresh["metaAnalyzedByScoreSetUrns"] == [meta_score_set["urn"]] | ||
|
||
meta_score_set = (client.post(f"/api/v1/score-sets/{meta_score_set['urn']}/publish")).json() | ||
assert meta_score_set["urn"] == "urn:mavedb:00000001-0-1" | ||
|
||
|
||
def test_multiple_score_set_meta_analysis_multiple_experiment_sets_with_different_creator( | ||
session, data_provider, client, setup_router_db, data_files | ||
): | ||
experiment_1 = create_experiment(client, {"title": "Experiment 1"}) | ||
experiment_2 = create_experiment(client, {"title": "Experiment 2"}) | ||
score_set_1 = create_seq_score_set_with_variants( | ||
client, session, data_provider, experiment_1["urn"], data_files / "scores.csv", update={"title": "Score Set 1"} | ||
) | ||
score_set_2 = create_seq_score_set_with_variants( | ||
client, session, data_provider, experiment_2["urn"], data_files / "scores.csv", update={"title": "Score Set 2"} | ||
) | ||
|
||
score_set_1 = (client.post(f"/api/v1/score-sets/{score_set_1['urn']}/publish")).json() | ||
score_set_2 = (client.post(f"/api/v1/score-sets/{score_set_2['urn']}/publish")).json() | ||
|
||
change_ownership(session, score_set_2["urn"], ScoreSetDbModel) | ||
meta_score_set = create_seq_score_set_with_variants( | ||
client, | ||
session, | ||
data_provider, | ||
None, | ||
data_files / "scores.csv", | ||
update={"title": "Test Meta Analysis", "metaAnalyzesScoreSetUrns": [score_set_1["urn"], score_set_2["urn"]]}, | ||
) | ||
score_set_1_refresh = (client.get(f"/api/v1/score-sets/{score_set_1['urn']}")).json() | ||
assert meta_score_set["metaAnalyzesScoreSetUrns"] == sorted([score_set_1["urn"], score_set_2["urn"]]) | ||
assert score_set_1_refresh["metaAnalyzedByScoreSetUrns"] == [meta_score_set["urn"]] | ||
|
||
meta_score_set = (client.post(f"/api/v1/score-sets/{meta_score_set['urn']}/publish")).json() | ||
assert meta_score_set["urn"] == "urn:mavedb:00000003-0-1" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same RegEx comment as above. |
||
|
||
######################################################################################################################## | ||
# Score set search | ||
######################################################################################################################## | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In so far as we check the URNs of test objects, I think we only need to check that the URN matches the URN RegEx.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the RegEx checks to all meta-analysis tests, but I support keeping them cause the meta-analysis urn is more special. This way is more accurate. RegEx only confirms they match the basic rules, but can't make sure the middle one is number 0 or letters.