|
69 | 69 | create_seq_score_set_with_variants, |
70 | 70 | ) |
71 | 71 | from tests.helpers.util.user import change_ownership |
72 | | -from tests.helpers.util.variant import create_mapped_variants_for_score_set, mock_worker_variant_insertion |
| 72 | +from tests.helpers.util.variant import ( |
| 73 | + create_mapped_variants_for_score_set, |
| 74 | + mock_worker_variant_insertion, |
| 75 | + clear_first_mapped_variant_post_mapped, |
| 76 | +) |
73 | 77 |
|
74 | 78 |
|
75 | 79 | ######################################################################################################################## |
@@ -2839,6 +2843,42 @@ def test_nonetype_annotated_pathogenicity_evidence_lines_for_score_set_when_thre |
2839 | 2843 | assert annotated_variant is None |
2840 | 2844 |
|
2841 | 2845 |
|
| 2846 | +@pytest.mark.parametrize( |
| 2847 | + "mock_publication_fetch", |
| 2848 | + [({"dbName": "PubMed", "identifier": f"{TEST_PUBMED_IDENTIFIER}"})], |
| 2849 | + indirect=["mock_publication_fetch"], |
| 2850 | +) |
| 2851 | +def test_get_annotated_pathogenicity_evidence_lines_for_score_set_when_some_variants_were_not_mapped( |
| 2852 | + client, session, data_provider, data_files, setup_router_db, admin_app_overrides, mock_publication_fetch |
| 2853 | +): |
| 2854 | + experiment = create_experiment(client) |
| 2855 | + score_set = create_seq_score_set_with_mapped_variants( |
| 2856 | + client, |
| 2857 | + session, |
| 2858 | + data_provider, |
| 2859 | + experiment["urn"], |
| 2860 | + data_files / "scores.csv", |
| 2861 | + update={ |
| 2862 | + "secondaryPublicationIdentifiers": [{"dbName": "PubMed", "identifier": f"{TEST_PUBMED_IDENTIFIER}"}], |
| 2863 | + "scoreRanges": camelize(TEST_SCORE_SET_RANGES_ONLY_PILLAR_PROJECT), |
| 2864 | + }, |
| 2865 | + ) |
| 2866 | + |
| 2867 | + first_var = clear_first_mapped_variant_post_mapped(session, score_set["urn"]) |
| 2868 | + |
| 2869 | + response = client.get(f"/api/v1/score-sets/{score_set['urn']}/annotated-variants/pathogenicity-evidence-line") |
| 2870 | + response_data = response.json() |
| 2871 | + |
| 2872 | + assert response.status_code == 200 |
| 2873 | + assert len(response_data) == score_set["numVariants"] |
| 2874 | + |
| 2875 | + for annotated_variant_urn, annotated_variant in response_data.items(): |
| 2876 | + if annotated_variant_urn == first_var.urn: |
| 2877 | + assert annotated_variant is None |
| 2878 | + else: |
| 2879 | + assert f"Pathogenicity evidence line {annotated_variant_urn}" in annotated_variant.get("description") |
| 2880 | + |
| 2881 | + |
2842 | 2882 | @pytest.mark.parametrize( |
2843 | 2883 | "mock_publication_fetch", |
2844 | 2884 | [({"dbName": "PubMed", "identifier": f"{TEST_PUBMED_IDENTIFIER}"})], |
@@ -2954,6 +2994,42 @@ def test_nonetype_annotated_functional_impact_statement_for_score_set_when_thres |
2954 | 2994 | assert annotated_variant is None |
2955 | 2995 |
|
2956 | 2996 |
|
| 2997 | +@pytest.mark.parametrize( |
| 2998 | + "mock_publication_fetch", |
| 2999 | + [({"dbName": "PubMed", "identifier": f"{TEST_PUBMED_IDENTIFIER}"})], |
| 3000 | + indirect=["mock_publication_fetch"], |
| 3001 | +) |
| 3002 | +def test_get_annotated_functional_impact_statement_for_score_set_when_some_variants_were_not_mapped( |
| 3003 | + client, session, data_provider, data_files, setup_router_db, admin_app_overrides, mock_publication_fetch |
| 3004 | +): |
| 3005 | + experiment = create_experiment(client) |
| 3006 | + score_set = create_seq_score_set_with_mapped_variants( |
| 3007 | + client, |
| 3008 | + session, |
| 3009 | + data_provider, |
| 3010 | + experiment["urn"], |
| 3011 | + data_files / "scores.csv", |
| 3012 | + update={ |
| 3013 | + "secondaryPublicationIdentifiers": [{"dbName": "PubMed", "identifier": f"{TEST_PUBMED_IDENTIFIER}"}], |
| 3014 | + "scoreRanges": camelize(TEST_SCORE_SET_RANGES_ALL_SCHEMAS_PRESENT), |
| 3015 | + }, |
| 3016 | + ) |
| 3017 | + |
| 3018 | + first_var = clear_first_mapped_variant_post_mapped(session, score_set["urn"]) |
| 3019 | + |
| 3020 | + response = client.get(f"/api/v1/score-sets/{score_set['urn']}/annotated-variants/functional-impact-statement") |
| 3021 | + response_data = response.json() |
| 3022 | + |
| 3023 | + assert response.status_code == 200 |
| 3024 | + assert len(response_data) == score_set["numVariants"] |
| 3025 | + |
| 3026 | + for annotated_variant_urn, annotated_variant in response_data.items(): |
| 3027 | + if annotated_variant_urn == first_var.urn: |
| 3028 | + assert annotated_variant is None |
| 3029 | + else: |
| 3030 | + assert annotated_variant.get("type") == "Statement" |
| 3031 | + |
| 3032 | + |
2957 | 3033 | @pytest.mark.parametrize( |
2958 | 3034 | "mock_publication_fetch", |
2959 | 3035 | [({"dbName": "PubMed", "identifier": f"{TEST_PUBMED_IDENTIFIER}"})], |
@@ -3069,6 +3145,42 @@ def test_annotated_functional_study_result_exists_for_score_set_when_thresholds_ |
3069 | 3145 | assert annotated_variant.get("type") == "ExperimentalVariantFunctionalImpactStudyResult" |
3070 | 3146 |
|
3071 | 3147 |
|
| 3148 | +@pytest.mark.parametrize( |
| 3149 | + "mock_publication_fetch", |
| 3150 | + [({"dbName": "PubMed", "identifier": f"{TEST_PUBMED_IDENTIFIER}"})], |
| 3151 | + indirect=["mock_publication_fetch"], |
| 3152 | +) |
| 3153 | +def test_annotated_functional_study_result_exists_for_score_set_when_some_variants_were_not_mapped( |
| 3154 | + client, session, data_provider, data_files, setup_router_db, admin_app_overrides, mock_publication_fetch |
| 3155 | +): |
| 3156 | + experiment = create_experiment(client) |
| 3157 | + score_set = create_seq_score_set_with_mapped_variants( |
| 3158 | + client, |
| 3159 | + session, |
| 3160 | + data_provider, |
| 3161 | + experiment["urn"], |
| 3162 | + data_files / "scores.csv", |
| 3163 | + update={ |
| 3164 | + "secondaryPublicationIdentifiers": [{"dbName": "PubMed", "identifier": f"{TEST_PUBMED_IDENTIFIER}"}], |
| 3165 | + "scoreRanges": camelize(TEST_SCORE_SET_RANGES_ONLY_PILLAR_PROJECT), |
| 3166 | + }, |
| 3167 | + ) |
| 3168 | + |
| 3169 | + first_var = clear_first_mapped_variant_post_mapped(session, score_set["urn"]) |
| 3170 | + |
| 3171 | + response = client.get(f"/api/v1/score-sets/{score_set['urn']}/annotated-variants/functional-study-result") |
| 3172 | + response_data = response.json() |
| 3173 | + |
| 3174 | + assert response.status_code == 200 |
| 3175 | + assert len(response_data) == score_set["numVariants"] |
| 3176 | + |
| 3177 | + for annotated_variant_urn, annotated_variant in response_data.items(): |
| 3178 | + if annotated_variant_urn == first_var.urn: |
| 3179 | + assert annotated_variant is None |
| 3180 | + else: |
| 3181 | + assert annotated_variant.get("type") == "ExperimentalVariantFunctionalImpactStudyResult" |
| 3182 | + |
| 3183 | + |
3072 | 3184 | ######################################################################################################################## |
3073 | 3185 | # Fetching gnomad variants for a score set |
3074 | 3186 | ######################################################################################################################## |
|
0 commit comments