1 package jalview.ext.rbvi.chimera;
3 import static org.testng.AssertJUnit.assertEquals;
4 import static org.testng.AssertJUnit.assertTrue;
7 import java.util.Arrays;
8 import java.util.LinkedHashMap;
12 import org.testng.annotations.Test;
14 public class ChimeraCommandsTest
16 @Test(groups ={ "Functional" })
17 public void testAddColourRange()
19 Map<Color, Map<Integer, Map<String, List<int[]>>>> map = new LinkedHashMap<Color, Map<Integer, Map<String, List<int[]>>>>();
20 ChimeraCommands.addColourRange(map, Color.pink, 1, 2, 4, "A");
21 ChimeraCommands.addColourRange(map, Color.pink, 1, 8, 8, "A");
22 ChimeraCommands.addColourRange(map, Color.pink, 1, 5, 7, "B");
23 ChimeraCommands.addColourRange(map, Color.red, 1, 3, 5, "A");
24 ChimeraCommands.addColourRange(map, Color.red, 0, 1, 4, "B");
25 ChimeraCommands.addColourRange(map, Color.orange, 0, 5, 9, "C");
27 // three colours mapped
28 assertEquals(3, map.keySet().size());
30 // Red has two models, Pink and Orange one each
31 assertEquals(2, map.get(Color.red).keySet().size());
32 assertEquals(1, map.get(Color.orange).keySet().size());
33 assertEquals(1, map.get(Color.pink).keySet().size());
35 // pink model 1 has two chains, red.0 / red.1 / orange.0 one each
36 assertEquals(2, map.get(Color.pink).get(1).keySet().size());
37 assertEquals(1, map.get(Color.red).get(0).keySet().size());
38 assertEquals(1, map.get(Color.red).get(1).keySet().size());
39 assertEquals(1, map.get(Color.orange).get(0).keySet().size());
42 List<int[]> posList = map.get(Color.pink).get(1).get("A");
43 assertEquals(2, posList.size());
44 assertTrue(Arrays.equals(new int[]
45 { 2, 4 }, posList.get(0)));
46 assertTrue(Arrays.equals(new int[]
47 { 8, 8 }, posList.get(1)));
49 posList = map.get(Color.pink).get(1).get("B");
50 assertEquals(1, posList.size());
51 assertTrue(Arrays.equals(new int[]
52 { 5, 7 }, posList.get(0)));
54 posList = map.get(Color.red).get(0).get("B");
55 assertEquals(1, posList.size());
56 assertTrue(Arrays.equals(new int[]
57 { 1, 4 }, posList.get(0)));
59 posList = map.get(Color.red).get(1).get("A");
60 assertEquals(1, posList.size());
61 assertTrue(Arrays.equals(new int[]
62 { 3, 5 }, posList.get(0)));
64 posList = map.get(Color.orange).get(0).get("C");
65 assertEquals(1, posList.size());
66 assertTrue(Arrays.equals(new int[]
67 { 5, 9 }, posList.get(0)));
70 @Test(groups ={ "Functional" })
71 public void testBuildColourCommands()
74 Map<Color, Map<Integer, Map<String, List<int[]>>>> map = new LinkedHashMap<Color, Map<Integer, Map<String, List<int[]>>>>();
75 ChimeraCommands.addColourRange(map, Color.blue, 0, 2, 5, "A");
76 ChimeraCommands.addColourRange(map, Color.blue, 0, 7, 7, "B");
77 ChimeraCommands.addColourRange(map, Color.blue, 0, 9, 23, "A");
78 ChimeraCommands.addColourRange(map, Color.blue, 1, 1, 1, "A");
79 ChimeraCommands.addColourRange(map, Color.blue, 1, 4, 7, "B");
80 ChimeraCommands.addColourRange(map, Color.yellow, 1, 8, 8, "A");
81 ChimeraCommands.addColourRange(map, Color.yellow, 1, 3, 5, "A");
82 ChimeraCommands.addColourRange(map, Color.red, 0, 3, 5, "A");
84 // Colours should appear in the Chimera command in the order in which
85 // they were added; within colour, by model, by chain, and positions as
87 String command = ChimeraCommands.buildColourCommands(map).get(0);
89 "color #0000ff #0:2-5.A,9-23.A,7.B|#1:1.A,4-7.B; color #ffff00 #1:8.A,3-5.A; color #ff0000 #0:3-5.A",