FilterConsensus implements Callable<Integer> { static Map<Integer, Allele> readBedFile(final File bedFile) throws IOException { BufferedReader reader = null; final Map<Integer, Allele> exons = new HashMap<Integer, Allele>(); try { reader = reader(bedFile); BedReader.stream(reader, new BedListener() { @Override public boolean record(final BedRecord rec) { try { int exon = Integer.parseInt(rec.name()); Locus locus = FeatureParser.parseLocus(rec.chrom() + ":" + rec.start() + "-" + rec.end()); exons.put(exon, Allele.builder() .withContig(locus.getContig()) .withStart(locus.getMin()) .withEnd(locus.getMax()) .build()); } catch (AlleleException | NumberFormatException | NullPointerException | ParseException e) { throw new ConversionException(rec, e); } return true; } }); } catch (ConversionException e) { throw new IOException("could not convert BED record \"" + e.rec() + "\" to allele", e.getCause()); } finally { try { reader.close(); } catch (Exception e) { } } return exons; } FilterConsensus(final File bamFile,
                           final File bedFile,
                           final File outputFile,
                           final String gene,
                           final boolean cdna,
                           final boolean removeGaps,
                           final double minimumBreadth,
                           final int expectedPloidy); @Override Integer call(); static void main(final String[] args);  }
@Test public void testEmptyReadBedFile() throws Exception { Map<Integer, Allele> exons = readBedFile(bedFile); assertTrue(exons.isEmpty()); }
@Test(expected=IOException.class) public void testReadGenomicFileMissingName() throws Exception { copyResource("missing-name.bed", bedFile); readBedFile(bedFile); }
@Test(expected=IOException.class) public void testReadGenomicFileInvalidName() throws Exception { copyResource("invalid-name.bed", bedFile); readBedFile(bedFile); }
@Test public void testReadBedFile() throws Exception { copyResource("hla-a.bed", bedFile); Map<Integer, Allele> exons = readBedFile(bedFile); assertFalse(exons.isEmpty()); assertTrue(exons.containsKey(2)); assertTrue(exons.containsKey(3)); }