@Test public void testIntersectionOfEmptyFileSpans() { GATKBAMFileSpan empty1 = new GATKBAMFileSpan(); GATKBAMFileSpan empty2 = new GATKBAMFileSpan(); GATKBAMFileSpan intersection = empty1.intersection(empty2); Assert.assertEquals(intersection.getGATKChunks().size(),0,"Elements inserted in intersection of two empty sets"); }
@Test public void testIntersectionOfStrictSubset() { GATKBAMFileSpan regionOne = new GATKBAMFileSpan(new GATKChunk(0,1<<16)); GATKBAMFileSpan regionTwo = new GATKBAMFileSpan(new GATKChunk(0,2<<16)); GATKBAMFileSpan intersection = regionOne.intersection(regionTwo); Assert.assertEquals(intersection.getGATKChunks().size(),1,"No intersection found between two partially overlapping filespans"); Assert.assertEquals(intersection.getGATKChunks().get(0),new GATKChunk(0<<16,1<<16),"Determined intersection is incorrect."); // Make sure intersection is symmetric intersection = regionTwo.intersection(regionOne); Assert.assertEquals(intersection.getGATKChunks().size(),1,"No intersection found between two partially overlapping filespans"); Assert.assertEquals(intersection.getGATKChunks().get(0),new GATKChunk(0<<16,1<<16),"Determined intersection is incorrect."); }
@Test public void testIntersectionOfNonOverlappingFileSpans() { GATKBAMFileSpan regionOne = new GATKBAMFileSpan(new GATKChunk(0,1<<16)); GATKBAMFileSpan regionTwo = new GATKBAMFileSpan(new GATKChunk(1<<16,2<<16)); GATKBAMFileSpan intersection = regionOne.intersection(regionTwo); Assert.assertEquals(intersection.getGATKChunks().size(),0,"Elements inserted in intersection of two non-intersecting filespans"); }
@Test public void testIntersectionOfChunkLists() { GATKBAMFileSpan regionOne = new GATKBAMFileSpan(new GATKChunk(0,5<<16)); GATKBAMFileSpan regionTwo = new GATKBAMFileSpan(new GATKChunk[] { new GATKChunk(1<<16,2<<16), new GATKChunk(3<<16,4<<16) }); GATKBAMFileSpan intersection = regionOne.intersection(regionTwo); Assert.assertEquals(intersection.getGATKChunks().size(),2,"Wrong number of intersections found."); Assert.assertEquals(intersection.getGATKChunks().get(0),new GATKChunk(1<<16,2<<16),"Determined intersection is incorrect."); Assert.assertEquals(intersection.getGATKChunks().get(1),new GATKChunk(3<<16,4<<16),"Determined intersection is incorrect."); // Make sure intersection is symmetric intersection = regionTwo.intersection(regionOne); Assert.assertEquals(intersection.getGATKChunks().size(),2,"Wrong number of intersections found."); Assert.assertEquals(intersection.getGATKChunks().get(0),new GATKChunk(1<<16,2<<16),"Determined intersection is incorrect."); Assert.assertEquals(intersection.getGATKChunks().get(1),new GATKChunk(3<<16,4<<16),"Determined intersection is incorrect."); }
@Test public void testIntersectionOfSmallOverlapInFileSpans() { GATKBAMFileSpan regionOne = new GATKBAMFileSpan(new GATKChunk(0,1<<16)); GATKBAMFileSpan regionTwo = new GATKBAMFileSpan(new GATKChunk(65535,2<<16)); GATKBAMFileSpan intersection = regionOne.intersection(regionTwo); Assert.assertEquals(intersection.getGATKChunks().size(),1,"No intersection found between two partially overlapping filespans"); Assert.assertEquals(intersection.getGATKChunks().get(0),new GATKChunk(65535,1<<16),"Determined intersection is incorrect."); }
@Test public void testIntersectionOfPartialOverlap() { GATKBAMFileSpan regionOne = new GATKBAMFileSpan(new GATKChunk(0,2<<16)); GATKBAMFileSpan regionTwo = new GATKBAMFileSpan(new GATKChunk(0<<16|32768,1<<16|32768)); GATKBAMFileSpan intersection = regionOne.intersection(regionTwo); Assert.assertEquals(intersection.getGATKChunks().size(),1,"No intersection found between two partially overlapping filespans"); Assert.assertEquals(intersection.getGATKChunks().get(0),new GATKChunk(0<<16|32768,1<<16|32768),"Determined intersection is incorrect."); }