Files
PlantAI-rag/tests/test_qa_v1_1_73_relation_taxonomy.py

73 lines
2.8 KiB
Python

from src.rag.retrieval.relation_taxonomy import (
normalize_relation_group,
relation_names_for_groups,
)
def test_v1_1_73_r1_relation_taxonomy_fills_empty_groups():
cases = {
"is_a": "classification",
"encodes": "gene_structure",
"member_of": "family_membership",
"is_member_of": "family_membership",
"interacts_with": "protein_interaction",
"forms_complex_with": "protein_interaction",
"regulates": "regulatory_interaction",
"activates": "regulatory_interaction",
"promotes": "regulatory_interaction",
"controls": "regulatory_interaction",
"inhibits": "regulatory_interaction",
"negatively_regulates": "regulatory_interaction",
"involved_in": "pathway_participation",
"participates_in": "pathway_participation",
"responds_to": "stress_response",
"induced_by": "stress_response",
"treated_with": "treatment_or_stress",
"expressed_in": "expression_tissue",
"relative_expression_in": "expression_tissue",
"localizes_to": "subcellular_localization",
"is_orthologous_to": "orthology_homology",
"contains_domain": "motif_domain",
}
for relation, expected_group in cases.items():
assert normalize_relation_group(relation, "") == expected_group
def test_v1_1_73_r1_relation_taxonomy_preserves_existing_valid_group():
assert normalize_relation_group("regulates", "hormone_response") == "hormone_response"
def test_v1_1_73_r1_relation_names_for_groups_supports_fallback_search():
assert "regulates" in relation_names_for_groups(["regulatory_interaction"])
assert "is_a" in relation_names_for_groups(["classification"])
assert "encodes" in relation_names_for_groups(["gene_structure"])
assert "interacts_with" in relation_names_for_groups(["protein_interaction"])
from src.rag.qa_v1_1_73_r1.planner_group_templates import apply_planner_group_templates
def test_v1_1_73_r1_planner_group_templates_entity_regulated_gene_product():
hop1, hop2, notes = apply_planner_group_templates(
"For VRN1, which gene or protein is linked to the entity regulated by VRN1?",
["regulatory_interaction"],
["regulatory_interaction"],
)
assert "regulatory_interaction" in hop1
assert "gene_structure" in hop2
assert "classification" in hop2
assert "protein_interaction" in hop2
assert notes
def test_v1_1_73_r1_planner_group_templates_interaction_and_pathway():
hop1, hop2, notes = apply_planner_group_templates(
"For Slr1, which biological pathway or process is linked to the gene or protein that Slr1 was reported to interact with?",
[],
[],
)
assert "protein_interaction" in hop1
assert "pathway_participation" in hop2
assert notes