HiPhiveProteinInteractionScorer { public GeneMatch getClosestPhenoMatchInNetwork(Integer entrezGeneId) { if (!dataMatrix.containsGene(entrezGeneId) || weightedHighQualityMatrixIndex.isEmpty()) { return GeneMatch.NO_HIT; } int rowIndex = dataMatrix.getRowIndexForGene(entrezGeneId); GeneColumnIndex topHighQualityGene = getGeneColumnIndexOfMostPhenotypicallySimilarGene(rowIndex, entrezGeneId); if (topHighQualityGene == null) { return GeneMatch.NO_HIT; } double walkerScore = 0.5 + weightedHighQualityMatrix.get(rowIndex, topHighQualityGene.columnIndex); Integer closestGeneId = topHighQualityGene.geneId; List<GeneModelPhenotypeMatch> models = bestGeneModels.get(closestGeneId); return GeneMatch.builder() .queryGeneId(entrezGeneId) .matchGeneId(closestGeneId) .score(walkerScore) .bestMatchModels(models) .build(); } private  HiPhiveProteinInteractionScorer();  HiPhiveProteinInteractionScorer(DataMatrix dataMatrix, ListMultimap<Integer, GeneModelPhenotypeMatch> bestGeneModels, double highQualityPhenoScoreCutOff); static HiPhiveProteinInteractionScorer empty(); GeneMatch getClosestPhenoMatchInNetwork(Integer entrezGeneId);  }
@Test public void geneInNetworkButUnderPhenotypeCutoff() { ArrayListMultimap<Integer, GeneModelPhenotypeMatch> bestGeneModels = ArrayListMultimap.create(); bestGeneModels.put(1, geneModelMatch(1, HIGH_QUALITY_PHENO_SCORE_CUT_OFF - 0.5, "MONDO:1")); HiPhiveProteinInteractionScorer instance = new HiPhiveProteinInteractionScorer(dataMatrix, bestGeneModels, HIGH_QUALITY_PHENO_SCORE_CUT_OFF); assertThat(instance.getClosestPhenoMatchInNetwork(1), equalTo(GeneMatch.NO_HIT)); }
@Test public void geneInNetworkSelfHit() { ArrayListMultimap<Integer, GeneModelPhenotypeMatch> bestGeneModels = ArrayListMultimap.create(); bestGeneModels.put(1, geneModelMatch(1, 0.7, "MONDO:1")); HiPhiveProteinInteractionScorer instance = new HiPhiveProteinInteractionScorer(dataMatrix, bestGeneModels, HIGH_QUALITY_PHENO_SCORE_CUT_OFF); assertThat(instance.getClosestPhenoMatchInNetwork(1), equalTo(GeneMatch.NO_HIT)); }
@Test public void geneInNetworkClosestHit() { GeneModelPhenotypeMatch bestModel = geneModelMatch(5, 0.7, "MONDO:5"); ArrayListMultimap<Integer, GeneModelPhenotypeMatch> bestGeneModels = ArrayListMultimap.create(); bestGeneModels.put(bestModel.getEntrezGeneId(), bestModel); HiPhiveProteinInteractionScorer instance = new HiPhiveProteinInteractionScorer(dataMatrix, bestGeneModels, HIGH_QUALITY_PHENO_SCORE_CUT_OFF); int queryGeneId = 6; GeneMatch closestPhenoMatchInNetwork = instance.getClosestPhenoMatchInNetwork(queryGeneId); assertThat(closestPhenoMatchInNetwork.getQueryGeneId(), equalTo(queryGeneId)); assertThat(closestPhenoMatchInNetwork.getMatchGeneId(), equalTo(bestModel.getEntrezGeneId())); assertThat(closestPhenoMatchInNetwork.getScore(), closeTo(0.57d, 0.001)); assertThat(closestPhenoMatchInNetwork.getBestMatchModels(), equalTo(ImmutableList.of(bestModel))); }
@Test public void geneInNetworkClosestHitTwoNetworks() { GeneModelPhenotypeMatch model5 = geneModelMatch(5, 0.7, "MONDO:5"); GeneModelPhenotypeMatch model2 = geneModelMatch(2, 0.62, "MONDO:2"); GeneModelPhenotypeMatch model3 = geneModelMatch(3, 0.63, "MONDO:3"); ArrayListMultimap<Integer, GeneModelPhenotypeMatch> bestGeneModels = ArrayListMultimap.create(); bestGeneModels.put(model5.getEntrezGeneId(), model5); bestGeneModels.put(model2.getEntrezGeneId(), model2); bestGeneModels.put(model3.getEntrezGeneId(), model3); HiPhiveProteinInteractionScorer instance = new HiPhiveProteinInteractionScorer(dataMatrix, bestGeneModels, HIGH_QUALITY_PHENO_SCORE_CUT_OFF); int queryGeneId = 4; GeneMatch closestPhenoMatchInNetwork = instance.getClosestPhenoMatchInNetwork(queryGeneId); assertThat(closestPhenoMatchInNetwork.getQueryGeneId(), equalTo(queryGeneId)); assertThat(closestPhenoMatchInNetwork.getMatchGeneId(), equalTo(model3.getEntrezGeneId())); assertThat(closestPhenoMatchInNetwork.getScore(), closeTo(0.563d, 0.001)); assertThat(closestPhenoMatchInNetwork.getBestMatchModels(), equalTo(ImmutableList.of(model3))); }