PhenoGridAdaptor { public PhenoGrid makePhenoGridFromHiPhiveResults(String phenoGridId, List<HiPhivePriorityResult> hiPhiveResults) { Set<String> phenotypeIds = new LinkedHashSet<>(); if (!hiPhiveResults.isEmpty()) { HiPhivePriorityResult result = hiPhiveResults.get(0); for (PhenotypeTerm phenoTerm : result.getQueryPhenotypeTerms()) { phenotypeIds.add(phenoTerm.getId()); } } PhenoGridQueryTerms phenoGridQueryTerms = new PhenoGridQueryTerms(phenoGridId, phenotypeIds); List<GeneModelPhenotypeMatch> diseaseModels = new ArrayList<>(); List<GeneModelPhenotypeMatch> mouseModels = new ArrayList<>(); List<GeneModelPhenotypeMatch> fishModels = new ArrayList<>(); for (HiPhivePriorityResult result : hiPhiveResults) { for (GeneModelPhenotypeMatch model : result.getPhenotypeEvidence()) { switch(model.getOrganism()) { case HUMAN: diseaseModels.add(model); break; case MOUSE: mouseModels.add(model); break; case FISH: fishModels.add(model); break; } } } List<PhenoGridMatchGroup> phenoGridMatchGroups = createPhenogridMatchGroups(phenotypeIds, diseaseModels, mouseModels, fishModels); return new PhenoGrid(phenoGridQueryTerms, phenoGridMatchGroups); }  PhenoGrid makePhenoGridFromHiPhiveResults(String phenoGridId, List<HiPhivePriorityResult> hiPhiveResults);  }
@Test public void testPhenoGridFromEmptyHiPhiveResults() { hiPhiveResults = Collections.emptyList(); PhenoGrid output = instance.makePhenoGridFromHiPhiveResults(phenoGridId, hiPhiveResults); assertThat(output, notNullValue()); PhenoGridQueryTerms queryTerms = output.getPhenoGridQueryTerms(); assertThat(queryTerms, notNullValue()); assertThat(queryTerms.getId(), equalTo(phenoGridId)); assertThat(queryTerms.getPhenotypeIds().isEmpty(), is(true)); assertThat(output.getPhenoGridMatchGroups().isEmpty(), is(true)); }
@Test public void testDiseaseOnlyPhenoGridMatch() { hiPhiveResults = new ArrayList<>(); hiPhiveResults.add(onlyDiseaseModelHiPhiveResult); PhenoGrid output = instance.makePhenoGridFromHiPhiveResults(phenoGridId, hiPhiveResults); testOutputHeader(output); List<PhenoGridMatchGroup> gridMatchGroups = output.getPhenoGridMatchGroups(); testHasExpectedNumberOfOrganismsUsedForPhenotypeComparison(1, gridMatchGroups); testExpectedTaxonomicOrderOfPhenoGridMatchGroups(gridMatchGroups, diseaseTaxon); testMatchesAreInDescendingScoreOrder(gridMatchGroups, diseaseScore); testPhenoGridMatchGroupCommonValues(gridMatchGroups); }
@Test public void testPhenoGridWithHiPhiveResultContainingAllModelMatchesOneMatchGroupPerOrganism() { hiPhiveResults = new ArrayList<>(); hiPhiveResults.add(allModelsHiPhiveResult); PhenoGrid output = instance.makePhenoGridFromHiPhiveResults(phenoGridId, hiPhiveResults); testOutputHeader(output); List<PhenoGridMatchGroup> gridMatchGroups = output.getPhenoGridMatchGroups(); testHasExpectedNumberOfOrganismsUsedForPhenotypeComparison(3, gridMatchGroups); testExpectedTaxonomicOrderOfPhenoGridMatchGroups(gridMatchGroups, diseaseTaxon, mouseTaxon, fishTaxon); testMatchesAreInDescendingScoreOrder(gridMatchGroups, diseaseScore, mouseScore, fishScore); testPhenoGridMatchGroupCommonValues(gridMatchGroups); }