BEDFileLoader { @NotNull public static SortedSetMultimap<String, GenomeRegion> fromBedFile(@NotNull String bedFile) throws IOException { final SortedSetMultimap<String, GenomeRegion> regionMap = TreeMultimap.create(); String prevChromosome = null; GenomeRegion prevRegion = null; try (final AbstractFeatureReader<BEDFeature, LineIterator> reader = getFeatureReader(bedFile, new BEDCodec(), false)) { for (final BEDFeature bedFeature : reader.iterator()) { final String chromosome = bedFeature.getContig(); final long start = bedFeature.getStart(); final long end = bedFeature.getEnd(); if (end < start) { LOGGER.warn("Invalid genome region found in chromosome {}: start={}, end={}", chromosome, start, end); } else { final GenomeRegion region = GenomeRegions.create(chromosome, start, end); if (prevRegion != null && chromosome.equals(prevChromosome) && prevRegion.end() >= start) { LOGGER.warn("BED file is not sorted, please fix! Current={}, Previous={}", region, prevRegion); } else { regionMap.put(chromosome, region); prevChromosome = chromosome; prevRegion = region; } } } } return regionMap; } private  BEDFileLoader(); @NotNull static SortedSetMultimap<String, GenomeRegion> fromBedFile(@NotNull String bedFile);  }
@Test public void verifyStartIsOneBased() throws IOException { final String bedFile = BED_FILE_BASE_PATH + File.separator + VALID_BED; final SortedSetMultimap<String, GenomeRegion> regions = BEDFileLoader.fromBedFile(bedFile); assertEquals(1, regions.get("1").first().start()); assertEquals(1, regions.get("1").first().end()); }