HmfExonPanelBed { @NotNull static List<GenomeRegion> createRegions(@NotNull final DriverGenePanel genePanel, @NotNull final List<HmfTranscriptRegion> regions) { final Set<String> actionableGenes = Sets.newHashSet(); actionableGenes.addAll(genePanel.oncoGenes()); actionableGenes.addAll(genePanel.tsGenes()); final Map<String, GenomeRegions> regionsMap = Maps.newHashMap(); for (HmfTranscriptRegion transcript : regions) { final GenomeRegions regionBuilder = regionsMap.computeIfAbsent(transcript.chromosome(), GenomeRegions::new); boolean forward = transcript.strand() == Strand.FORWARD; for (int i = 0; i < transcript.exome().size(); i++) { if (transcript.codingStart() == 0 || !actionableGenes.contains(transcript.gene())) { continue; } final HmfExonRegion exon = transcript.exome().get(i); if (i != 0) { regionBuilder.addRegion(exon.start() - 2, exon.start() - 1); if (!forward) { regionBuilder.addPosition(exon.start() - 5); } } if (i != transcript.exome().size() - 1) { regionBuilder.addRegion(exon.end() + 1, exon.end() + 2); if (forward) { regionBuilder.addPosition(exon.end() + 5); } } if (transcript.codingStart() < exon.end() && transcript.codingEnd() > exon.start()) { regionBuilder.addRegion(Math.max(transcript.codingStart(), exon.start()), Math.min(transcript.codingEnd(), exon.end())); } } } final List<GenomeRegion> result = Lists.newArrayList(); for (GenomeRegions genomeRegions : regionsMap.values()) { result.addAll(genomeRegions.build()); } Collections.sort(result); return result; }  @SuppressWarnings("WeakerAccess") static void write19File(@NotNull final String filename, @NotNull final String genePanelFile); @SuppressWarnings("WeakerAccess") static void write38File(@NotNull final String filename, @NotNull final String genePanelFile);  }
@Test public void testReverseTranscript() { final DriverGenePanel genePanel = DriverGenePanelFactoryTest.testGenePanel(); final HmfTranscriptRegion transcript = HmfGenePanelSupplier.allGenesMap37().get("TP53"); HmfExonRegion firstExon = transcript.exome().get(0); HmfExonRegion secondExon = transcript.exome().get(1); HmfExonRegion thirdExon = transcript.exome().get(2); HmfExonRegion finalCodingExon = transcript.exome().get(transcript.exome().size() - 2); List<GenomeRegion> regions = HmfExonPanelBed.createRegions(genePanel, Lists.newArrayList(transcript, transcript)); assertRegion(regions.get(0), transcript.codingStart(), firstExon.end() + 2); assertRegion(regions.get(1), secondExon.start() - 5, secondExon.start() - 5); assertRegion(regions.get(2), secondExon.start() - 2, secondExon.end() + 2); assertRegion(regions.get(3), thirdExon.start() - 5, thirdExon.start() - 5); assertRegion(regions.get(13), 7579307, 7579307); assertRegion(regions.get(18), finalCodingExon.start() - 2, transcript.codingEnd()); assertRegion(regions.get(19), finalCodingExon.end() + 1, finalCodingExon.end() + 2); }