HmfTranscriptRegion implements TranscriptRegion { @Value.Derived @Nullable public List<GenomeRegion> codonByIndex(int index) { return codonRangeByIndex(index, index); }  @NotNull abstract String geneID(); abstract long geneStart(); abstract long geneEnd(); abstract long codingStart(); abstract long codingEnd(); @NotNull abstract Strand strand(); @NotNull abstract List<Integer> entrezId(); @NotNull abstract List<HmfExonRegion> exome(); @Value.Derived @Nullable HmfExonRegion exonByIndex(int index); @Value.Derived @Nullable // TODO: Convert to using long. List<GenomeRegion> codingRangeByGenomicCoordinates(int genomicStartPosition, int genomicEndPosition); @Value.Derived @Nullable List<GenomeRegion> codonByIndex(int index); @NotNull List<GenomeRegion> codonRangeAtGenomicPosition(long position); @Value.Derived @Nullable List<GenomeRegion> codonRangeByIndex(int startCodon, int endCodon);  }
@Test public void canRetrieveCodonByIndexOnForwardGene() { HmfTranscriptRegion transcript = create(Strand.FORWARD); assertNull(transcript.codonByIndex(-1)); assertNull(transcript.codonByIndex(0)); GenomeRegion codon1 = assertedCodonGet(transcript, 1); assertNotNull(codon1); assertEquals(2, codon1.start()); assertEquals(4, codon1.end()); GenomeRegion codon2Part1 = assertedCodonGet(transcript, 2, 0); assertNotNull(codon2Part1); assertEquals(5, codon2Part1.start()); assertEquals(5, codon2Part1.end()); GenomeRegion codon2Part2 = assertedCodonGet(transcript, 2, 1); assertNotNull(codon2Part2); assertEquals(7, codon2Part2.start()); assertEquals(8, codon2Part2.end()); GenomeRegion codon3 = assertedCodonGet(transcript, 3); assertNotNull(codon3); assertEquals(9, codon3.start()); assertEquals(11, codon3.end()); GenomeRegion codon4 = assertedCodonGet(transcript, 4); assertNotNull(codon4); assertEquals(12, codon4.start()); assertEquals(14, codon4.end()); GenomeRegion codon5Part1 = assertedCodonGet(transcript, 5, 0); assertNotNull(codon5Part1); assertEquals(15, codon5Part1.start()); assertEquals(16, codon5Part1.end()); GenomeRegion codon5Part2 = assertedCodonGet(transcript, 5, 1); assertNotNull(codon5Part2); assertEquals(18, codon5Part2.start()); assertEquals(18, codon5Part2.end()); assertNull(transcript.codonByIndex(6)); }
@Test public void canRetrieveCodonByIndexOnReverseGene() { HmfTranscriptRegion transcript = create(Strand.REVERSE); assertNull(transcript.codonByIndex(-1)); assertNull(transcript.codonByIndex(0)); GenomeRegion codon1Part1 = assertedCodonGet(transcript, 1, 0); assertNotNull(codon1Part1); assertEquals(15, codon1Part1.start()); assertEquals(16, codon1Part1.end()); GenomeRegion codon1Part2 = assertedCodonGet(transcript, 1, 1); assertNotNull(codon1Part2); assertEquals(18, codon1Part2.start()); assertEquals(18, codon1Part2.end()); GenomeRegion codon2 = assertedCodonGet(transcript, 2); assertNotNull(codon2); assertEquals(12, codon2.start()); assertEquals(14, codon2.end()); GenomeRegion codon3 = assertedCodonGet(transcript, 3); assertNotNull(codon3); assertEquals(9, codon3.start()); assertEquals(11, codon3.end()); GenomeRegion codon4Part1 = assertedCodonGet(transcript, 4, 0); assertNotNull(codon4Part1); assertEquals(5, codon4Part1.start()); assertEquals(5, codon4Part1.end()); GenomeRegion codon4Part2 = assertedCodonGet(transcript, 4, 1); assertNotNull(codon4Part2); assertEquals(7, codon4Part2.start()); assertEquals(8, codon4Part2.end()); GenomeRegion codon5 = assertedCodonGet(transcript, 5); assertNotNull(codon5); assertEquals(2, codon5.start()); assertEquals(4, codon5.end()); assertNull(transcript.codonByIndex(6)); }
@Test public void worksForRealBRAFCodon600() { HmfTranscriptRegion braf = HmfGenePanelSupplier.allGenesMap37().get("BRAF"); List<GenomeRegion> codon600 = braf.codonByIndex(600); assertNotNull(codon600); assertEquals(1, codon600.size()); assertEquals(140453135, codon600.get(0).start()); assertEquals(140453137, codon600.get(0).end()); }