def test_hide_compounds_follow_filter_in(app, variant_obj): """Test hiding compounds from view given hide compounds follow filter options""" # GIVEN a variant compound_variant_obj = { "_id": "a_compound", "case_id": variant_obj["case_id"], "chromosome": variant_obj["chromosome"], "position": variant_obj["position"] + 3, "end": variant_obj["position"] + 3, "reference": "A", "alternative": "G", "category": "sv", "sub_category": "del", } store.variant_collection.insert_one(compound_variant_obj) compound_variant_dict = { "variant": "a_compound", "is_dismissed": False, } # GIVEN a variant with the other variant as an only compound variant_obj["compounds"] = [compound_variant_dict] print("variant obj", variant_obj) # WHEN asking for hiding compounds that do match a subtype annotation query_form = {"svtype": ["dup", "del"], "compound_follow_filter": True} # WHEN calling the function hide_compounds_query(store, variant_obj, query_form) # WHEN checking its compounds compounds = variant_obj.get("compounds") # THEN the only compound now appears included assert compounds[0]["is_dismissed"] is False # WHEN asking for hiding compounds that do not match a subtype annotation query_form = {"svtype": ["inv"], "compound_follow_filter": True} # WHEN calling the function hide_compounds_query(store, variant_obj, query_form) # WHEN checking its compounds compounds = variant_obj.get("compounds") # THEN the only compound now appears dismissed assert compounds[0]["is_dismissed"]
def test_hide_compounds_follow_filter_clnsig(app, variant_obj): """Test hiding compounds from view given hide compounds follow filter options""" # GIVEN a variant compound_variant_obj = { "_id": "a_compound", "case_id": variant_obj["case_id"], "chromosome": variant_obj["chromosome"], "position": variant_obj["position"] + 3, "end": variant_obj["position"] + 3, "reference": "A", "alternative": "G", "clnsig": [{ "value": "Pathogenic", "accession": "RCV00123456.7", "revstat": "single" }], } store.variant_collection.insert_one(compound_variant_obj) compound_variant_dict = { "variant": "a_compound", "is_dismissed": False, } # GIVEN a variant with the other variant as an only compound variant_obj["compounds"] = [compound_variant_dict] print("variant obj", variant_obj) # WHEN asking for hiding compounds that do match a ClinVar annotation query_form = {"clinsig": [4, 5], "compound_follow_filter": True} # WHEN calling the function hide_compounds_query(store, variant_obj, query_form) # WHEN checking its compounds compounds = variant_obj.get("compounds") # THEN the only compound appears included assert compounds[0]["is_dismissed"] is False
def test_hide_compounds_query_rank(app, variant_obj): """Test hiding compounds from view given a compound rank score filter option""" # GIVEN a variant test_rank_score = 4 compound_variant_obj = { "_id": "a_compound", "case_id": variant_obj["case_id"], "chromosome": variant_obj["chromosome"], "position": variant_obj["position"] + 3, "reference": "A", "alternative": "G", "rank_score": test_rank_score, "is_dismissed": False, } store.variant_collection.insert_one(compound_variant_obj) # GIVEN a variant with the other as an only compound variant_obj["compounds"] = [compound_variant_obj] # WHEN asking for a lower score threshold query_form = {"compound_rank_score": test_rank_score - 1} # WHEN calling the function hide_compounds_query(store, variant_obj, query_form) # WHEN checking its compounds compounds = variant_obj.get("compounds") # THEN the only compound is still not dismissed assert compounds[0]["is_dismissed"] is False # WHEN asking for hiding compounds with higher rank score threshold query_form = {"compound_rank_score": test_rank_score + 1} # WHEN calling the function hide_compounds_query(store, variant_obj, query_form) # WHEN checking its compounds compounds = variant_obj.get("compounds") # THEN the only compound now appears dismissed assert compounds[0]["is_dismissed"]
def test_hide_compounds_follow_filter(app, variant_obj): """Test hiding compounds from view given hide compounds follow filter options""" # GIVEN a variant test_cadd = 15 compound_variant_obj = { "_id": "a_compound", "case_id": variant_obj["case_id"], "chromosome": variant_obj["chromosome"], "position": variant_obj["position"] + 3, "end": variant_obj["position"] + 3, "reference": "A", "alternative": "G", "cadd_score": test_cadd, "local_obs_old": 10, } store.variant_collection.insert_one(compound_variant_obj) compound_variant_dict = { "variant": "a_compound", "is_dismissed": False, } # GIVEN a variant with the other variant as an only compound variant_obj["compounds"] = [compound_variant_dict] # CADD # WHEN asking for hiding compounds with higher cadd score threshold query_form = {"cadd_score": test_cadd + 1, "compound_follow_filter": True} # WHEN calling the function hide_compounds_query(store, variant_obj, query_form) # WHEN checking its compounds compounds = variant_obj.get("compounds") # THEN the only compound now appears dismissed assert compounds[0]["is_dismissed"] # POSITION # WHEN setting it back to visible compound_variant_dict["is_dismissed"] = False # WHEN asking for hiding compounds with position in the range query_form = { "position": variant_obj["position"] - 1, "end": variant_obj["position"] + 5, "compound_follow_filter": True, } # WHEN calling the function hide_compounds_query(store, variant_obj, query_form) # WHEN checking its compounds compounds = variant_obj.get("compounds") # THEN the only compound now appears dismissed assert compounds[0]["is_dismissed"] # FREQ # WHEN setting it back to visible compound_variant_dict["is_dismissed"] = False # WHEN asking for hiding compounds with more counts query_form = {"local_obs": 5, "compound_follow_filter": True} # WHEN calling the function hide_compounds_query(store, variant_obj, query_form) # WHEN checking its compounds compounds = variant_obj.get("compounds") # THEN the only compound now appears dismissed assert compounds[0]["is_dismissed"]
def test_hide_compounds_follow_filter_region(app, variant_obj): """Test hiding compounds from view given hide compounds follow filter options""" # GIVEN a variant test_cadd = 15 compound_variant_obj = { "_id": "a_compound", "case_id": variant_obj["case_id"], "chromosome": variant_obj["chromosome"], "position": variant_obj["position"] + 3, "end": variant_obj["position"] + 3, "reference": "A", "alternative": "G", "cadd_score": test_cadd, "spidex": -1.5, "local_obs_old": 10, } store.variant_collection.insert_one(compound_variant_obj) compound_variant_dict = { "variant": "a_compound", "is_dismissed": False, "region_annotations": ["exonic"], } # GIVEN a variant with the other variant as an only compound variant_obj["compounds"] = [compound_variant_dict] print("variant obj", variant_obj) # WHEN asking for hiding compounds that do match a region annotation query_form = { "region_annotations": ["exonic"], "compound_follow_filter": True } # WHEN calling the function hide_compounds_query(store, variant_obj, query_form) # WHEN checking its compounds compounds = variant_obj.get("compounds") # THEN the only compound now appears included assert compounds[0]["is_dismissed"] is False # but WHEN asking for hiding compounds that do not match a region annotation query_form = { "region_annotations": ["intronic"], "compound_follow_filter": True } # WHEN calling the function hide_compounds_query(store, variant_obj, query_form) # WHEN checking its compounds compounds = variant_obj.get("compounds") # THEN the only compound now appears hidden assert compounds[0]["is_dismissed"] # WHEN setting it back to visible compound_variant_dict["is_dismissed"] = False
def test_hide_compounds_follow_filter_spidex(app, variant_obj): """Test hiding compounds from view given hide compounds follow filter options""" # GIVEN a variant compound_variant_obj = { "_id": "a_compound", "case_id": variant_obj["case_id"], "chromosome": variant_obj["chromosome"], "position": variant_obj["position"] + 3, "end": variant_obj["position"] + 3, "reference": "A", "alternative": "G", "spidex": -1.5, # medium } store.variant_collection.insert_one(compound_variant_obj) compound_variant_dict = { "variant": "a_compound", "is_dismissed": False, } # GIVEN a variant with the other variant as an only compound variant_obj["compounds"] = [compound_variant_dict] # WHEN asking for hiding compounds with higher rank score threshold query_form = {"spidex_human": ["high"], "compound_follow_filter": True} # WHEN calling the function hide_compounds_query(store, variant_obj, query_form) # WHEN checking its compounds compounds = variant_obj.get("compounds") # THEN the only compound appears dismissed assert compounds[0]["is_dismissed"] # WHEN setting it back to visible compound_variant_dict["is_dismissed"] = False # GIVEN a variant with the other variant as an only compound variant_obj["compounds"] = [compound_variant_dict] # WHEN asking for hiding compounds within the spidex score interval query_form = {"spidex_human": ["medium"], "compound_follow_filter": True} # WHEN calling the function hide_compounds_query(store, variant_obj, query_form) # WHEN checking its compounds compounds = variant_obj.get("compounds") # THEN the only compound does not appear dismissed assert not compounds[0]["is_dismissed"] # WHEN setting it back to visible compound_variant_dict["is_dismissed"] = False # GIVEN a variant with the other variant as an only compound variant_obj["compounds"] = [compound_variant_dict] # WHEN asking for hiding compounds within a spidex score interval with both the containing and the higher level query_form = { "spidex_human": ["medium", "high"], "compound_follow_filter": True } # WHEN calling the function hide_compounds_query(store, variant_obj, query_form) # WHEN checking its compounds compounds = variant_obj.get("compounds") # THEN the only compound again appears not dismissed assert not compounds[0]["is_dismissed"]