HmfTranscriptRegion implements TranscriptRegion { @Value.Derived @Nullable public HmfExonRegion exonByIndex(int index) { int effectiveIndex = index - 1; List<HmfExonRegion> strandSortedExome = strandSortedExome(); if (effectiveIndex >= 0 && effectiveIndex < strandSortedExome.size()) { return strandSortedExome.get(effectiveIndex); } return null; }  @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 canRetrieveExonByIndexOnForwardGene() { HmfTranscriptRegion transcript = create(Strand.FORWARD); assertNull(transcript.exonByIndex(0)); HmfExonRegion exon1 = transcript.exonByIndex(1); assertNotNull(exon1); assertEquals("1", exon1.exonID()); HmfExonRegion exon2 = transcript.exonByIndex(2); assertNotNull(exon2); assertEquals("2", exon2.exonID()); HmfExonRegion exon3 = transcript.exonByIndex(3); assertNotNull(exon3); assertEquals("3", exon3.exonID()); assertNull(transcript.exonByIndex(4)); }
@Test public void canRetrieveExonByIndexOnReverseGene() { HmfTranscriptRegion transcript = create(Strand.REVERSE); assertNull(transcript.exonByIndex(0)); HmfExonRegion exon1 = transcript.exonByIndex(1); assertNotNull(exon1); assertEquals("3", exon1.exonID()); HmfExonRegion exon2 = transcript.exonByIndex(2); assertNotNull(exon2); assertEquals("2", exon2.exonID()); HmfExonRegion exon3 = transcript.exonByIndex(3); assertNotNull(exon3); assertEquals("1", exon3.exonID()); assertNull(transcript.exonByIndex(4)); }