Class OntologySearchSourceInferredRelationsTest

java.lang.Object
ubic.gemma.core.search.source.OntologySearchSourceInferredRelationsTest

public class OntologySearchSourceInferredRelationsTest extends Object
The opt-in widening of a search into inferred relations.

Driven directly rather than through the whole ontology search path, because what can go wrong here is not "does search work" — it is whether the flag is honoured, whether an inferred hit can outscore a direct one, whether a term the query already carries silently loses its score to the inference penalty, and whether one prolific seed can swamp the query.

The case throughout is the one that motivated the feature: GSE134453 carries genotype: SURF1 patient and no disease annotation, and a user searching Leigh syndrome has to find it. If the widening does not happen, dropping the redundant disease tag on the grounds that it is inferable does not relocate the fact, it deletes it.

  • Constructor Details

    • OntologySearchSourceInferredRelationsTest

      public OntologySearchSourceInferredRelationsTest()
  • Method Details

    • setUp

      @BeforeEach public void setUp()
    • testWideningDoesNotHappenUnlessAskedFor

      @Test public void testWideningDoesNotHappenUnlessAskedFor()
      Off by default: an existing search must not change shape because this feature landed.
    • testSearchingADiseaseReachesTheGenotypeThatStandsForIt

      @Test public void testSearchingADiseaseReachesTheGenotypeThatStandsForIt()
      The acceptance criterion: searching the disease reaches the genotype that stands for it.
    • testAnInferredTermScoresBelowTheTermActuallyAskedFor

      @Test public void testAnInferredTermScoresBelowTheTermActuallyAskedFor()
      An inferred hit must never outrank a dataset actually annotated with the query.

      Getting this backwards would put "we think this genotype means your disease" above "this dataset is annotated with your disease", which reads as a broken search rather than a ranking choice.

    • testADirectHitIsNotDemotedByAlsoBeingInferred

      @Test public void testADirectHitIsNotDemotedByAlsoBeingInferred()
      A term the query already matched directly keeps its own score.

      Relations are read in both directions, so a term can legitimately come back as related to a seed the query already carries. Overwriting it with the inference penalty would demote a direct hit for the sole reason that something else in the corpus also points at it.

    • testOneProlificSeedCannotSwampTheQuery

      @Test public void testOneProlificSeedCannotSwampTheQuery()
      🛑 One seed may not swamp the query.

      This is the Trp53 case: it pairs with 15 diseases in our corpus and a null in it genuinely models several malignancies, so a search that expanded through all of them would stop being a search for the disease the user typed and become a search for every dataset that ever mutated the gene. The ranked list is cut per seed, so the best few contribute and the tail does not.

    • testCandidatesWithinTheBudgetAllGoIn

      @Test public void testCandidatesWithinTheBudgetAllGoIn()
      Within the per-seed budget, ambiguity survives: nothing picks one of the candidates.
    • testAnUngroundedRelatedTermIsDropped

      @Test public void testAnUngroundedRelatedTermIsDropped()
      An ungrounded related term is dropped rather than matched on its label.

      The lookup this feeds matches on VALUE_URI, so a term with no URI has nothing to match against. Falling back to the string would be label matching, which is what cost two tokenisation bugs in a single day elsewhere (B-cell destroyed by treating cell as a stopword; lymphoma. not equal to lymphoma).

    • testBothDirectionsAreAsked

      @Test public void testBothDirectionsAreAsked()
      Both directions are consulted: which end of a relation the user typed is not something to guess. A curated statement puts the disease in the subject and the gene in the object.
    • testAbsentRelationServiceIsHarmless

      @Test public void testAbsentRelationServiceIsHarmless()
      With no relation service wired the widening is a no-op rather than a failure — several contexts construct this source by hand.