GeneReassigner { public void reassignRegulatoryRegionVariantToMostPhenotypicallySimilarGeneInTad(VariantEvaluation variantEvaluation) { if (variantEvaluation.getVariantEffect() == VariantEffect.REGULATORY_REGION_VARIANT) { logger.debug("Checking gene assignment for {} chr={} pos={}", variantEvaluation.getVariantEffect(), variantEvaluation .getChromosome(), variantEvaluation.getPosition()); assignVariantToGeneWithHighestPhenotypeScore(variantEvaluation); } } GeneReassigner(PriorityType priorityType, Map<String, Gene> allGenes, ChromosomalRegionIndex<TopologicalDomain> tadIndex); void reassignRegulatoryRegionVariantToMostPhenotypicallySimilarGeneInTad(VariantEvaluation variantEvaluation); void reassignGeneToMostPhenotypicallySimilarGeneInAnnotations(VariantEvaluation variantEvaluation);  }
@Test public void assignsRegulatoryVariantToBestPhenotypicMatchvariantOriginallyAssociatedWithBestCandidateGene() { addPriorityResultWithScore(gene1, 1d); addPriorityResultWithScore(gene2, 0d); TopologicalDomain tad = makeTad(1, 1, 20000, gene1, gene2); instance = makeInstance(PriorityType.HIPHIVE_PRIORITY, tad); VariantEvaluation variant = regulatoryVariantInTad(tad, gene1); instance.reassignRegulatoryRegionVariantToMostPhenotypicallySimilarGeneInTad(variant); assertThat(variant, isAssignedTo(gene1)); }
@Test public void assignsRegulatoryVariantToBestPhenotypicMatchvariantNotOriginallyAssociatedWithBestCandidateGene() { addPriorityResultWithScore(gene1, 1d); addPriorityResultWithScore(gene2, 0d); TopologicalDomain tad = makeTad(1, 1, 20000, gene1, gene2); instance = makeInstance(PriorityType.HIPHIVE_PRIORITY, tad); VariantEvaluation variant = regulatoryVariantInTad(tad, gene2); instance.reassignRegulatoryRegionVariantToMostPhenotypicallySimilarGeneInTad(variant); assertThat(variant, isAssignedTo(gene1)); }
@Test public void assignsRegulatoryVariantToBestPhenotypicMatchvariantOriginallyAssociatedWithBestCandidateGeneKeepsOriginalAnnotations() { addPriorityResultWithScore(gene1, 1d); addPriorityResultWithScore(gene2, 0d); TopologicalDomain tad = makeTad(1, 1, 20000, gene1, gene2); instance = makeInstance(PriorityType.HIPHIVE_PRIORITY, tad); VariantEvaluation variant = regulatoryVariantInTad(tad, gene1); TranscriptAnnotation gene1Annotation = TranscriptAnnotation.builder().geneSymbol(gene1.getGeneSymbol()).build(); TranscriptAnnotation gene2Annotation = TranscriptAnnotation.builder().geneSymbol(gene2.getGeneSymbol()).build(); List<TranscriptAnnotation> originalAnnotations = Arrays.asList(gene2Annotation, gene1Annotation); variant.setAnnotations(originalAnnotations); instance.reassignRegulatoryRegionVariantToMostPhenotypicallySimilarGeneInTad(variant); assertThat(variant, isAssignedTo(gene1)); assertThat(variant.getTranscriptAnnotations(), equalTo(originalAnnotations)); }
@Test public void assignsRegulatoryVariantToBestPhenotypicMatchVariantNotOriginallyAssociatedWithBestCandidateGeneHasMatchingAnnotationsTransferred() { addPriorityResultWithScore(gene1, 1d); addPriorityResultWithScore(gene2, 0d); TopologicalDomain tad = makeTad(1, 1, 20000, gene1, gene2); instance = makeInstance(PriorityType.HIPHIVE_PRIORITY, tad); VariantEvaluation variant = regulatoryVariantInTad(tad, gene2); TranscriptAnnotation gene2Annotation = TranscriptAnnotation.builder().geneSymbol(gene2.getGeneSymbol()).build(); TranscriptAnnotation gene1Annotation = TranscriptAnnotation.builder().geneSymbol(gene1.getGeneSymbol()).build(); variant.setAnnotations(Arrays.asList(gene2Annotation, gene1Annotation)); instance.reassignRegulatoryRegionVariantToMostPhenotypicallySimilarGeneInTad(variant); assertThat(variant, isAssignedTo(gene1)); assertThat(variant.getTranscriptAnnotations(), equalTo(Collections.singletonList(gene1Annotation))); }
@Test public void assignsRegulatoryVariantToBestPhenotypicMatchVariantInTadButNotAssignedToKnownGene() { addPriorityResultWithScore(gene1, 1d); addPriorityResultWithScore(gene2, 0d); TopologicalDomain tad = makeTad(1, 1, 20000, gene1, gene2); instance = makeInstance(PriorityType.HIPHIVE_PRIORITY, tad); Gene noKnownGene = new Gene(".", -1); VariantEvaluation variant = regulatoryVariantInTad(tad, noKnownGene); instance.reassignRegulatoryRegionVariantToMostPhenotypicallySimilarGeneInTad(variant); assertThat(variant, isAssignedTo(gene1)); }
@Test public void assignsRegulatoryVariantToBestPhenotypicMatchVariantNotInKnownTadAndNotAssignedToKnownGene() { addPriorityResultWithScore(gene1, 1d); addPriorityResultWithScore(gene2, 0d); TopologicalDomain tad = makeTad(1, 1, 20000, gene1, gene2); instance = makeInstance(PriorityType.HIPHIVE_PRIORITY, tad); Gene noKnownGene = new Gene(".", -1); VariantEvaluation variant = variant(1, tad.getEnd() + 1000, "A", "T", VariantEffect.REGULATORY_REGION_VARIANT, noKnownGene); instance.reassignRegulatoryRegionVariantToMostPhenotypicallySimilarGeneInTad(variant); assertThat(variant, isAssignedTo(noKnownGene)); }
@Test public void assignsRegulatoryVariantToBestPhenotypicMatchGeneInTadNotInKnownGenes() { addPriorityResultWithScore(gene1, 1d); addPriorityResultWithScore(gene2, 0d); Gene noKnownGene = new Gene(".", -1); TopologicalDomain tad = makeTad(1, 1, 20000, gene1, gene2, noKnownGene); instance = makeInstance(PriorityType.HIPHIVE_PRIORITY, tad); VariantEvaluation variant = regulatoryVariantInTad(tad, gene1); instance.reassignRegulatoryRegionVariantToMostPhenotypicallySimilarGeneInTad(variant); assertThat(variant, isAssignedTo(gene1)); }
@Test public void noneTypePrioritiser() { TopologicalDomain tad = makeTad(1, 1, 20000, gene1, gene2); instance = makeInstance(PriorityType.NONE, tad); VariantEvaluation variant = regulatoryVariantInTad(tad, gene1); instance.reassignRegulatoryRegionVariantToMostPhenotypicallySimilarGeneInTad(variant); assertThat(variant, isAssignedTo(gene1)); }
@Test public void variantInGeneNotAssociatedAnyTad() { addPriorityResultWithScore(gene1, 1d); addPriorityResultWithScore(gene2, 0d); TopologicalDomain tad = makeTad(1, 1, 20000, gene1); instance = makeInstance(PriorityType.HIPHIVE_PRIORITY, tad); VariantEvaluation variant = variant(2, 999999, "A", "G", VariantEffect.REGULATORY_REGION_VARIANT, gene2); instance.reassignRegulatoryRegionVariantToMostPhenotypicallySimilarGeneInTad(variant); assertThat(variant, isAssignedTo(gene2)); }
@Test public void assignsRegulatoryVariantToBestPhenotypicMatchVariantAssociatedWithGeneInOtherTad() { addPriorityResultWithScore(gene1, 1d); TopologicalDomain tad1 = makeTad(1, 1, 20000, gene1); addPriorityResultWithScore(gene2, 0d); TopologicalDomain tad2 = makeTad(1, 40000, 80000, gene2); instance = makeInstance(PriorityType.HIPHIVE_PRIORITY, tad1, tad2); VariantEvaluation variant = regulatoryVariantInTad(tad2, gene2); instance.reassignRegulatoryRegionVariantToMostPhenotypicallySimilarGeneInTad(variant); assertThat(variant, isAssignedTo(gene2)); }
@Test public void assignsRegulatoryVariantToBestPhenotypicMatchIgnoresNonRegulatoryVariant() { addPriorityResultWithScore(gene1, 1d); addPriorityResultWithScore(gene2, 0d); TopologicalDomain tad = makeTad(1, 1, 20000, gene1, gene2); instance = makeInstance(PriorityType.HIPHIVE_PRIORITY, tad); VariantEvaluation variant = variantInTadWithEffect(tad, VariantEffect.MISSENSE_VARIANT, gene2); instance.reassignRegulatoryRegionVariantToMostPhenotypicallySimilarGeneInTad(variant); assertThat(variant, isAssignedTo(gene2)); }
@Test public void assignsRegulatoryVariantToBestPhenotypicMatchVariantNotMovedWhenAllGenesHaveEqualScore() { addPriorityResultWithScore(gene1, 0.5d); addPriorityResultWithScore(gene2, 0.5d); TopologicalDomain tad = makeTad(1, 1, 20000, gene1, gene2); instance = makeInstance(PriorityType.HIPHIVE_PRIORITY, tad); VariantEvaluation variant = regulatoryVariantInTad(tad, gene1); instance.reassignRegulatoryRegionVariantToMostPhenotypicallySimilarGeneInTad(variant); assertThat(variant, isAssignedTo(gene1)); }