JannovarVariantAnnotator implements VariantAnnotator { public VariantAnnotation annotate(String contig, int pos, String ref, String alt) { AllelePosition trimmedAllele = AllelePosition.trim(pos, ref, alt); VariantAnnotations variantAnnotations = jannovarAnnotationService.annotateVariant(contig, trimmedAllele.getPos(), trimmedAllele .getRef(), trimmedAllele.getAlt()); return buildVariantAlleleAnnotation(genomeAssembly, contig, trimmedAllele, variantAnnotations); } JannovarVariantAnnotator(GenomeAssembly genomeAssembly, JannovarData jannovarData, ChromosomalRegionIndex<RegulatoryFeature> regulatoryRegionIndex); VariantAnnotation annotate(String contig, int pos, String ref, String alt);  }
@Test public void testGetAnnotationsForUnknownContigVariant() { VariantAnnotation annotations = instance.annotate("UNKNOWN", 1, "A", "T"); System.out.println(annotations); assertThat(annotations, not(nullValue())); assertThat(annotations.getChromosome(), equalTo(0)); assertThat(annotations.getPosition(), equalTo(1)); assertThat(annotations.getRef(), equalTo("A")); assertThat(annotations.getAlt(), equalTo("T")); assertThat(annotations.getGeneId(), equalTo("")); assertThat(annotations.getGeneSymbol(), equalTo(".")); assertThat(annotations.getVariantEffect(), equalTo(VariantEffect.SEQUENCE_VARIANT)); assertThat(annotations.hasTranscriptAnnotations(), is(false)); }
@Test public void testAnnotateMissenseVariant() { VariantAnnotation annotations = instance.annotate("10", 123256215, "T", "G"); assertThat(annotations.getChromosomeName(), equalTo("10")); assertThat(annotations.getChromosome(), equalTo(10)); assertThat(annotations.getPosition(), equalTo(123256215)); assertThat(annotations.getRef(), equalTo("T")); assertThat(annotations.getAlt(), equalTo("G")); assertThat(annotations.getGeneId(), equalTo("2263")); assertThat(annotations.getGeneSymbol(), equalTo("FGFR2")); assertThat(annotations.getVariantEffect(), equalTo(VariantEffect.MISSENSE_VARIANT)); assertThat(annotations.hasTranscriptAnnotations(), is(true)); TranscriptAnnotation transcriptAnnotation = annotations.getTranscriptAnnotations().get(0); assertThat(transcriptAnnotation.getGeneSymbol(), equalTo("FGFR2")); assertThat(transcriptAnnotation.getAccession(), equalTo("uc021pzz.1")); assertThat(transcriptAnnotation.getDistanceFromNearestGene(), equalTo(Integer.MIN_VALUE)); assertThat(transcriptAnnotation.getHgvsGenomic(), equalTo("g.12278533A>C")); assertThat(transcriptAnnotation.getHgvsCdna(), equalTo("c.1694A>C")); assertThat(transcriptAnnotation.getHgvsProtein(), equalTo("p.(Glu565Ala)")); }
@Test public void testAnnotateSpliceAcceptorVariant() { VariantAnnotation annotations = instance.annotate("10", 123243319, "T", "G"); assertThat(annotations.getChromosomeName(), equalTo("10")); assertThat(annotations.getChromosome(), equalTo(10)); assertThat(annotations.getPosition(), equalTo(123243319)); assertThat(annotations.getRef(), equalTo("T")); assertThat(annotations.getAlt(), equalTo("G")); assertThat(annotations.getGeneId(), equalTo("2263")); assertThat(annotations.getGeneSymbol(), equalTo("FGFR2")); assertThat(annotations.getVariantEffect(), equalTo(VariantEffect.SPLICE_ACCEPTOR_VARIANT)); assertThat(annotations.hasTranscriptAnnotations(), is(true)); TranscriptAnnotation transcriptAnnotation = annotations.getTranscriptAnnotations().get(0); assertThat(transcriptAnnotation.getGeneSymbol(), equalTo("FGFR2")); assertThat(transcriptAnnotation.getAccession(), equalTo("uc021pzz.1")); assertThat(transcriptAnnotation.getDistanceFromNearestGene(), equalTo(Integer.MIN_VALUE)); assertThat(transcriptAnnotation.getHgvsGenomic(), equalTo("g.12291429A>C")); assertThat(transcriptAnnotation.getHgvsCdna(), equalTo("c.2196-2A>C")); assertThat(transcriptAnnotation.getHgvsProtein(), equalTo("p.?")); }
@Test public void testAnnotateDownstreamVariant() { VariantAnnotation annotations = instance.annotate("10", 123237800, "T", "G"); assertThat(annotations.getChromosomeName(), equalTo("10")); assertThat(annotations.getChromosome(), equalTo(10)); assertThat(annotations.getPosition(), equalTo(123237800)); assertThat(annotations.getRef(), equalTo("T")); assertThat(annotations.getAlt(), equalTo("G")); assertThat(annotations.getGeneId(), equalTo("2263")); assertThat(annotations.getGeneSymbol(), equalTo("FGFR2")); assertThat(annotations.getVariantEffect(), equalTo(VariantEffect.DOWNSTREAM_GENE_VARIANT)); assertThat(annotations.hasTranscriptAnnotations(), is(true)); TranscriptAnnotation transcriptAnnotation = annotations.getTranscriptAnnotations().get(0); assertThat(transcriptAnnotation.getGeneSymbol(), equalTo("FGFR2")); assertThat(transcriptAnnotation.getAccession(), equalTo("uc021pzz.1")); assertThat(transcriptAnnotation.getDistanceFromNearestGene(), equalTo(-120171)); }
@Test public void testAnnotateUpstreamVariant() { VariantAnnotation annotations = instance.annotate("10", 123357973, "T", "G"); assertThat(annotations.getChromosomeName(), equalTo("10")); assertThat(annotations.getChromosome(), equalTo(10)); assertThat(annotations.getPosition(), equalTo(123357973)); assertThat(annotations.getRef(), equalTo("T")); assertThat(annotations.getAlt(), equalTo("G")); assertThat(annotations.getGeneId(), equalTo("2263")); assertThat(annotations.getGeneSymbol(), equalTo("FGFR2")); assertThat(annotations.getVariantEffect(), equalTo(VariantEffect.UPSTREAM_GENE_VARIANT)); assertThat(annotations.hasTranscriptAnnotations(), is(true)); TranscriptAnnotation transcriptAnnotation = annotations.getTranscriptAnnotations().get(0); assertThat(transcriptAnnotation.getGeneSymbol(), equalTo("FGFR2")); assertThat(transcriptAnnotation.getAccession(), equalTo("uc021pzz.1")); assertThat(transcriptAnnotation.getDistanceFromNearestGene(), equalTo(120130)); }
@Test public void testAnnotateIntergenicVariant() { VariantAnnotation annotations = instance.annotate("10", 150000000, "T", "G"); assertThat(annotations.getChromosomeName(), equalTo("10")); assertThat(annotations.getChromosome(), equalTo(10)); assertThat(annotations.getPosition(), equalTo(150000000)); assertThat(annotations.getRef(), equalTo("T")); assertThat(annotations.getAlt(), equalTo("G")); assertThat(annotations.getGeneId(), equalTo("2263")); assertThat(annotations.getGeneSymbol(), equalTo("FGFR2")); assertThat(annotations.getVariantEffect(), equalTo(VariantEffect.INTERGENIC_VARIANT)); assertThat(annotations.hasTranscriptAnnotations(), is(true)); TranscriptAnnotation transcriptAnnotation = annotations.getTranscriptAnnotations().get(0); assertThat(transcriptAnnotation.getGeneSymbol(), equalTo("FGFR2")); assertThat(transcriptAnnotation.getAccession(), equalTo("uc021pzz.1")); assertThat(transcriptAnnotation.getDistanceFromNearestGene(), equalTo(26762157)); }
@Test public void testUpstreamGeneIntergenicVariantsInRegulatoryRegion() { VariantAnnotation upstreamVariant = instance.annotate("10", 123357973, "T", "G"); assertThat(upstreamVariant.getVariantEffect(), equalTo(VariantEffect.UPSTREAM_GENE_VARIANT)); VariantAnnotation intergenicVariant = instance.annotate("10", 150000000, "T", "G"); assertThat(intergenicVariant.getVariantEffect(), equalTo(VariantEffect.INTERGENIC_VARIANT)); RegulatoryFeature enhancer = new RegulatoryFeature(10, upstreamVariant.getPosition(), upstreamVariant.getPosition(), RegulatoryFeature.FeatureType.ENHANCER); RegulatoryFeature tfBindingSite = new RegulatoryFeature(10, intergenicVariant.getPosition(), intergenicVariant.getPosition(), RegulatoryFeature.FeatureType.TF_BINDING_SITE); VariantAnnotator annotatorWithRegulatoryRegions = new JannovarVariantAnnotator(TestFactory.getDefaultGenomeAssembly(), TestFactory.buildDefaultJannovarData(), ChromosomalRegionIndex.of(ImmutableList.of(enhancer, tfBindingSite)) ); VariantAnnotation wasUpstream = annotatorWithRegulatoryRegions.annotate(upstreamVariant.getChromosomeName(), upstreamVariant.getPosition(), upstreamVariant.getRef(), upstreamVariant.getAlt()); assertThat(wasUpstream.getVariantEffect(), equalTo(VariantEffect.REGULATORY_REGION_VARIANT)); VariantAnnotation wasIntergenic = annotatorWithRegulatoryRegions.annotate(intergenicVariant.getChromosomeName(), intergenicVariant.getPosition(), intergenicVariant.getRef(), intergenicVariant.getAlt()); assertThat(wasIntergenic.getVariantEffect(), equalTo(VariantEffect.REGULATORY_REGION_VARIANT)); }
@Test public void testGetAnnotationsForUnTrimmedDeletionReturnsValueOfAllelePositionTrim() { int pos = 118608470; String ref = "AGTT"; String alt = "AGT"; VariantAnnotation annotations = instance.annotate("X", pos, ref, alt); System.out.println(annotations); AllelePosition allelePosition = AllelePosition.trim(pos, ref, alt); System.out.printf("AnnotationList{pos=%d, ref='%s', alt='%s'}%n", annotations.getPosition(), annotations.getRef(), annotations .getAlt()); System.out.println(allelePosition); assertThat(annotations.getChromosome(), equalTo(23)); assertThat(annotations.getPosition(), equalTo(allelePosition.getPos())); assertThat(annotations.getRef(), equalTo(allelePosition.getRef())); assertThat(annotations.getAlt(), equalTo(allelePosition.getAlt())); assertThat(annotations.hasTranscriptAnnotations(), is(false)); }
@Test public void testGetAnnotationsForUnTrimmedDeletionTrimmedWithAllelePosition() { int pos = 118608470; String ref = "AGTT"; String alt = "AGT"; AllelePosition trimmed = AllelePosition.trim(pos, ref, alt); VariantAnnotation variantAnnotation = instance.annotate("X", pos, ref, alt); System.out.println(variantAnnotation); System.out.printf("AnnotationList{pos=%d, ref='%s', alt='%s'}%n", variantAnnotation.getPosition(), variantAnnotation .getRef(), variantAnnotation.getAlt()); System.out.println("Trimmed: " + trimmed); assertThat(variantAnnotation.getChromosome(), equalTo(23)); assertThat(variantAnnotation.getPosition(), equalTo(trimmed.getPos())); assertThat(variantAnnotation.getRef(), equalTo(trimmed.getRef())); assertThat(variantAnnotation.getAlt(), equalTo(trimmed.getAlt())); assertThat(variantAnnotation.hasTranscriptAnnotations(), is(false)); }
@Test void testStructuralVariant() { int pos = 118608470; String ref = "A"; String alt = "<INS>"; AllelePosition trimmed = AllelePosition.trim(pos, ref, alt); VariantAnnotation variantAnnotation = instance.annotate("X", pos, ref, alt); assertThat(variantAnnotation.getChromosome(), equalTo(23)); assertThat(variantAnnotation.getPosition(), equalTo(trimmed.getPos())); assertThat(variantAnnotation.getRef(), equalTo(trimmed.getRef())); assertThat(variantAnnotation.getAlt(), equalTo(trimmed.getAlt())); assertThat(variantAnnotation.hasTranscriptAnnotations(), is(false)); assertThat(variantAnnotation.getVariantEffect(), equalTo(VariantEffect.STRUCTURAL_VARIANT)); }