BlatAssociationScorer { public static BlatAssociation scoreResults( Collection<BlatAssociation> blatAssociations ) { Map<GeneProduct, Collection<BlatAssociation>> geneProducts2Associations = BlatAssociationScorer .organizeBlatAssociationsByGeneProductAndInitializeScores( blatAssociations ); BlatAssociation globalBest = BlatAssociationScorer .removeExtraHitsPerGeneProduct( blatAssociations, geneProducts2Associations ); assert blatAssociations.size() > 0; Map<Gene, Collection<BlatAssociation>> genes2Associations = BlatAssociationScorer .organizeBlatAssociationsByGene( blatAssociations ); assert genes2Associations.size() > 0; if ( genes2Associations.size() == 1 ) { return globalBest; } Map<PhysicalLocation, Collection<Gene>> geneClusters = BlatAssociationScorer.clusterGenes( genes2Associations ); Map<PhysicalLocation, Double> scores = new HashMap<>(); for ( PhysicalLocation pl : geneClusters.keySet() ) { Double geneScore = 0.0; for ( Gene cgene : geneClusters.get( pl ) ) { for ( BlatAssociation blatAssociation : genes2Associations.get( cgene ) ) { Double alignScore = blatAssociation.getScore(); if ( alignScore > geneScore ) { geneScore = alignScore; } } } scores.put( pl, geneScore ); } for ( PhysicalLocation pl : geneClusters.keySet() ) { Double alignScore = scores.get( pl ); for ( Gene cgene : geneClusters.get( pl ) ) { for ( BlatAssociation blatAssociation : genes2Associations.get( cgene ) ) { blatAssociation .setSpecificity( BlatAssociationScorer.computeSpecificity( scores.values(), alignScore ) ); } } } return globalBest; }  static double computeOverlapFraction( BlatAssociation blatAssociation ); static BlatAssociation scoreResults( Collection<BlatAssociation> blatAssociations );  }
@Test public void testScoreResults() { GeneProduct geneProduct = this.createGeneProduct(); BlatResult blatResult_1 = this.createBlatResult( "6_cox_hap2" ); BlatResult blatResult_2 = this.createBlatResult( "6" ); BlatAssociation association_1 = BlatAssociation.Factory.newInstance(); association_1.setGeneProduct( geneProduct ); association_1.setBlatResult( blatResult_1 ); association_1.setScore( 50.0 ); association_1.setOverlap( 50 ); association_1.setBioSequence( BioSequence.Factory.newInstance() ); BlatAssociation association_2 = BlatAssociation.Factory.newInstance(); association_2.setGeneProduct( geneProduct ); association_2.setBlatResult( blatResult_2 ); association_2.setScore( 30.0 ); association_2.setOverlap( 30 ); association_2.setBioSequence( BioSequence.Factory.newInstance() ); Collection<BlatAssociation> blatAssociations = new ArrayList<>(); blatAssociations.add( association_1 ); blatAssociations.add( association_2 ); ProbeMapperConfig config = new ProbeMapperConfig(); config.setTrimNonCanonicalChromosomeHits( true ); BlatAssociation actual = BlatAssociationScorer.scoreResults( blatAssociations ); assertFalse( ChromosomeUtil.isCanonical( blatResult_1.getTargetChromosome() ) ); assertTrue( ChromosomeUtil.isCanonical( blatResult_2.getTargetChromosome() ) ); assertEquals( 940.0, association_1.getScore(), 0 ); assertEquals( 564.0, association_2.getScore(), 0 ); assertEquals( 1.0, actual.getSpecificity(), 0 ); }