@Test
public void testReassignGeneToMostPhenotypicallySimilarGeneInAnnotationsAnnotationsOverlapTwoGenesShouldOnlyHaveTopPhenotypeGeneMatchAnnotations() {

    //in this scenario the annotations for the variant overlap both the GNRHR2 and RBM8A genes.
    Stream<VariantContext> variantContext = TestVcfParser.forSamples("Adam", "Eve")
            .parseVariantContext("1 145510730 . T C,A 123.15 PASS GENE=GNRHR2 GT 1/1 0/2");
    VariantFactory variantFactory = TestFactory.buildDefaultVariantFactory();
    List<VariantEvaluation> variants = variantFactory.createVariantEvaluations(variantContext)
            .collect(toList());
    Gene topPhenotypeMatchGene = TestFactory.newGeneRBM8A();
    Gene GNRHR2 = TestFactory.newGeneGNRHR2();
    allGenes.put(topPhenotypeMatchGene.getGeneSymbol(), topPhenotypeMatchGene);
    allGenes.put(GNRHR2.getGeneSymbol(), GNRHR2);
    addPriorityResultWithScore(topPhenotypeMatchGene, 1d);
    addPriorityResultWithScore(GNRHR2, 0d);
    TopologicalDomain topologicalDomain = makeTad(1, 1, 20000, GNRHR2, topPhenotypeMatchGene);
    instance = makeInstance(PriorityType.HIPHIVE_PRIORITY, topologicalDomain);
    variants.forEach(variantEvaluation -> {
        logger.info("Before re-assigning variant to best phenotype match ({})", topPhenotypeMatchGene.getGeneSymbol());
        logger.info("{} {}:{} {} {} {} {}", variantEvaluation.getGeneSymbol(), variantEvaluation.getChromosome(), variantEvaluation
                .getPosition(), variantEvaluation.getRef(), variantEvaluation.getAlt(), variantEvaluation.getVariantEffect(), variantEvaluation
                .getTranscriptAnnotations()
                .size());
        assertThat(variantEvaluation, isAssignedTo(GNRHR2));
        assertThat(variantEvaluation.getVariantEffect(), equalTo(VariantEffect.MISSENSE_VARIANT));
        variantEvaluation.getTranscriptAnnotations()
                .forEach(transcriptAnnotation -> logger.info("{}", transcriptAnnotation));
        List<TranscriptAnnotation> reassignedAnnotations = variantEvaluation.getTranscriptAnnotations().stream()
                .filter(transcriptAnnotation -> transcriptAnnotation.getGeneSymbol()
                        .equals(topPhenotypeMatchGene.getGeneSymbol()))
                .collect(toList());
        instance.reassignGeneToMostPhenotypicallySimilarGeneInAnnotations(variantEvaluation);
        logger.info("After re-assigning variant to best phenotype match ({})", topPhenotypeMatchGene.getGeneSymbol());
        logger.info("{} {}:{} {} {} {} {}", variantEvaluation.getGeneSymbol(), variantEvaluation.getChromosome(), variantEvaluation
                .getPosition(), variantEvaluation.getRef(), variantEvaluation.getAlt(), variantEvaluation.getVariantEffect(), variantEvaluation
                .getTranscriptAnnotations()
                .size());
        assertThat(variantEvaluation, isAssignedTo(topPhenotypeMatchGene));
        assertThat(variantEvaluation.getVariantEffect(), equalTo(VariantEffect.THREE_PRIME_UTR_EXON_VARIANT));
        assertThat(variantEvaluation.getTranscriptAnnotations(), equalTo(reassignedAnnotations));
        variantEvaluation.getTranscriptAnnotations()
                .forEach(transcriptAnnotation -> logger.info("{}", transcriptAnnotation));
    });
}