import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertNull;
import static org.testng.AssertJUnit.assertSame;
import static org.testng.AssertJUnit.assertTrue;
-import static org.testng.AssertJUnit.fail;
-
-import java.awt.Color;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
+import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals;
import java.awt.Color;
import java.io.IOException;
import org.testng.annotations.Test;
import jalview.api.AlignViewportI;
-import jalview.bin.Cache;
+import jalview.bin.Console;
import jalview.commands.EditCommand;
import jalview.commands.EditCommand.Action;
import jalview.commands.EditCommand.Edit;
@BeforeClass(alwaysRun = true)
public void setUp()
{
- Cache.initLogger();
+ Console.initLogger();
}
@BeforeClass(alwaysRun = true)
}
@Test(groups = "Functional")
- public void testListToArray()
+ public void testFindOverlap()
{
List<int[]> ranges = new ArrayList<>();
-
- int[] result = MappingUtils.rangeListToArray(ranges);
- assertEquals(result.length, 0);
- ranges.add(new int[] { 24, 12 });
- result = MappingUtils.rangeListToArray(ranges);
- assertEquals(result.length, 2);
- assertEquals(result[0], 24);
- assertEquals(result[1], 12);
- ranges.add(new int[] { -7, 30 });
- result = MappingUtils.rangeListToArray(ranges);
- assertEquals(result.length, 4);
- assertEquals(result[0], 24);
- assertEquals(result[1], 12);
- assertEquals(result[2], -7);
- assertEquals(result[3], 30);
- try
- {
- MappingUtils.rangeListToArray(null);
- fail("Expected exception");
- } catch (NullPointerException e)
- {
- // expected
- }
+ ranges.add(new int[] { 4, 8 });
+ ranges.add(new int[] { 10, 12 });
+ ranges.add(new int[] { 16, 19 });
+
+ int[] overlap = MappingUtils.findOverlap(ranges, 5, 13);
+ assertArrayEquals(overlap, new int[] { 5, 12 });
+ overlap = MappingUtils.findOverlap(ranges, -100, 100);
+ assertArrayEquals(overlap, new int[] { 4, 19 });
+ overlap = MappingUtils.findOverlap(ranges, 7, 17);
+ assertArrayEquals(overlap, new int[] { 7, 17 });
+ overlap = MappingUtils.findOverlap(ranges, 13, 15);
+ assertNull(overlap);
}
-
+
/**
* Test mapping a sequence group where sequences in and outside the group
* share a dataset sequence (e.g. alternative CDS for the same gene)
* <p>
- * This scenario doesn't arise after JAL-3763 changes, but test left as still valid
+ * This scenario doesn't arise after JAL-3763 changes, but test left as still
+ * valid
+ *
* @throws IOException
*/
@Test(groups = { "Functional" })