@Test(dataProvider = "testSpanOverlappings") public void testSpanOverlappings(SRAAccession acc, int reference, int firstLocus, int lastLocus, long[] spanCoordinates) { final SRAIndex index = getIndex(acc); final BAMFileSpan span = index.getSpanOverlapping(reference, firstLocus, lastLocus); long[] coordinatesFromIndex = span.toCoordinateArray(); Assert.assertTrue(Arrays.equals(coordinatesFromIndex, spanCoordinates), "Coordinates mismatch. Expected: " + Arrays.toString(spanCoordinates) + " but was : " + Arrays.toString(coordinatesFromIndex)); }
@Test public void testLevelSize() { final SRAIndex index = getIndex(DEFAULT_ACCESSION); Assert.assertEquals(index.getLevelSize(0), GenomicIndexUtil.LEVEL_STARTS[1] - GenomicIndexUtil.LEVEL_STARTS[0]); Assert.assertEquals(index.getLevelSize(LAST_BIN_LEVEL), GenomicIndexUtil.MAX_BINS - GenomicIndexUtil.LEVEL_STARTS[LAST_BIN_LEVEL] - 1); }
@Test(dataProvider = "testBinOverlappings") public void testBinOverlappings(SRAAccession acc, int reference, int firstLocus, int lastLocus, Set<Integer> binNumbers) { final SRAIndex index = getIndex(acc); final Iterator<Bin> binIterator = index.getBinsOverlapping(reference, firstLocus, lastLocus).iterator(); final Set<Integer> binNumbersFromIndex = new HashSet<>(); while (binIterator.hasNext()) { final Bin bin = binIterator.next(); binNumbersFromIndex.add(bin.getBinNumber() - SRA_BIN_OFFSET); } Assert.assertEquals(binNumbers, binNumbersFromIndex); }
@Test public void testLevelForBin() { final SRAIndex index = getIndex(DEFAULT_ACCESSION); final Bin bin = new Bin(0, SRA_BIN_OFFSET); Assert.assertEquals(index.getLevelForBin(bin), LAST_BIN_LEVEL); }
@Test(dataProvider = "testBinLocuses") public void testBinLocuses(SRAAccession acc, int reference, int binIndex, int firstLocus, int lastLocus) { final SRAIndex index = getIndex(acc); final Bin bin = new Bin(reference, SRA_BIN_OFFSET + binIndex); Assert.assertEquals(index.getFirstLocusInBin(bin), firstLocus); Assert.assertEquals(index.getLastLocusInBin(bin), lastLocus); }