+ String expected = String.format(
+ "align %s@CA toAtoms %s@CA; ribbon %s|%s; view", toAlignSpec,
+ refSpec, toAlignSpec, refSpec);
+ assertEquals(cmd, expected);
+ }
+
+ @Test(groups = "Functional")
+ public void testGetAtomSpec()
+ {
+ AtomSpecModel model = new AtomSpecModel();
+ assertEquals(testee.getAtomSpec(model, false), "");
+ model.addRange("1", 2, 4, "A");
+ assertEquals(testee.getAtomSpec(model, false), "#1/A:2-4");
+ model.addRange("1", 8, 8, "A");
+ assertEquals(testee.getAtomSpec(model, false), "#1/A:2-4,8");
+ model.addRange("1", 5, 7, "B");
+ assertEquals(testee.getAtomSpec(model, false), "#1/A:2-4,8/B:5-7");
+ model.addRange("1", 3, 5, "A");
+ assertEquals(testee.getAtomSpec(model, false), "#1/A:2-5,8/B:5-7");
+ model.addRange("0", 1, 4, "B");
+ assertEquals(testee.getAtomSpec(model, false),
+ "#0/B:1-4|#1/A:2-5,8/B:5-7");
+ model.addRange("0", 5, 9, "C");
+ assertEquals(testee.getAtomSpec(model, false),
+ "#0/B:1-4/C:5-9|#1/A:2-5,8/B:5-7");
+ model.addRange("1", 8, 10, "B");
+ assertEquals(testee.getAtomSpec(model, false),
+ "#0/B:1-4/C:5-9|#1/A:2-5,8/B:5-10");
+ model.addRange("1", 8, 9, "B");
+ assertEquals(testee.getAtomSpec(model, false),
+ "#0/B:1-4/C:5-9|#1/A:2-5,8/B:5-10");
+ model.addRange("0", 3, 10, "C"); // subsumes 5-9
+ assertEquals(testee.getAtomSpec(model, false),
+ "#0/B:1-4/C:3-10|#1/A:2-5,8/B:5-10");
+ model.addRange("5", 25, 35, " ");
+ assertEquals(testee.getAtomSpec(model, false),
+ "#0/B:1-4/C:3-10|#1/A:2-5,8/B:5-10|#5/:25-35");
+ }
+
+ @Test(groups = "Functional")
+ public void testGetAtomSpec_alphaOnly()
+ {
+ AtomSpecModel model = new AtomSpecModel();
+ assertEquals(testee.getAtomSpec(model, true), "");
+ model.addRange("1", 2, 4, "A");
+ assertEquals(testee.getAtomSpec(model, true), "#1/A:2-4@CA");
+ model.addRange("1", 8, 8, "A");
+ assertEquals(testee.getAtomSpec(model, true), "#1/A:2-4,8@CA");
+ model.addRange("1", 5, 7, "B");
+ assertEquals(testee.getAtomSpec(model, true), "#1/A:2-4,8/B:5-7@CA");
+ model.addRange("1", 3, 5, "A");
+ assertEquals(testee.getAtomSpec(model, true), "#1/A:2-5,8/B:5-7@CA");
+ model.addRange("0", 1, 4, "B");
+ assertEquals(testee.getAtomSpec(model, true),
+ "#0/B:1-4@CA|#1/A:2-5,8/B:5-7@CA");
+ model.addRange("0", 5, 9, "C");
+ assertEquals(testee.getAtomSpec(model, true),
+ "#0/B:1-4/C:5-9@CA|#1/A:2-5,8/B:5-7@CA");
+ model.addRange("1", 8, 10, "B");
+ assertEquals(testee.getAtomSpec(model, true),
+ "#0/B:1-4/C:5-9@CA|#1/A:2-5,8/B:5-10@CA");
+ model.addRange("1", 8, 9, "B");
+ assertEquals(testee.getAtomSpec(model, true),
+ "#0/B:1-4/C:5-9@CA|#1/A:2-5,8/B:5-10@CA");
+ model.addRange("0", 3, 10, "C"); // subsumes 5-9
+ assertEquals(testee.getAtomSpec(model, true),
+ "#0/B:1-4/C:3-10@CA|#1/A:2-5,8/B:5-10@CA");
+ model.addRange("5", 25, 35, " "); // empty chain code
+ assertEquals(testee.getAtomSpec(model, true),
+ "#0/B:1-4/C:3-10@CA|#1/A:2-5,8/B:5-10@CA|#5/:25-35@CA");
+ }
+
+ @Test(groups = "Functional")
+ public void testGetModelStartNo()
+ {
+ assertEquals(testee.getModelStartNo(), 1);
+ }
+
+ @Test(groups = "Functional")
+ public void testGetResidueSpec()
+ {
+ assertEquals(testee.getResidueSpec("ALA"), ":ALA");
+ }
+
+ @Test(groups = "Functional")
+ public void testShowBackbone()
+ {
+ List<StructureCommandI> showBackbone = testee.showBackbone();
+ assertEquals(showBackbone.size(), 1);
+ assertEquals(showBackbone.get(0).getCommand(),
+ "~display all;~ribbon;show @CA|P atoms");
+ }
+
+ @Test(groups = "Functional")
+ public void testOpenCommandFile()
+ {
+ assertEquals(testee.openCommandFile("nowhere").getCommand(),
+ "open nowhere");
+ }
+
+ @Test(groups = "Functional")
+ public void testSaveSession()
+ {
+ assertEquals(testee.saveSession("somewhere").getCommand(),
+ "save somewhere format session");
+ }
+
+ @Test(groups = "Functional")
+ public void testGetColourCommand()
+ {
+ assertEquals(testee.colourResidues("something", Color.MAGENTA)
+ .getCommand(),
+ "color something #ff00ff");
+ }
+
+ @Test(groups = "Functional")
+ public void testSetAttribute()
+ {
+ AtomSpecModel model = new AtomSpecModel();
+ model.addRange("1", 89, 92, "A");
+ model.addRange("2", 12, 20, "B");
+ model.addRange("2", 8, 9, "B");
+ assertEquals(testee.setAttribute("jv_kd", "27.3", model)
+ .getCommand(),
+ "setattr #1/A:89-92|#2/B:8-9,12-20 res jv_kd '27.3' create true");
+ }
+
+ @Test(groups = "Functional")
+ public void testCloseViewer()
+ {
+ assertEquals(testee.closeViewer(), new StructureCommand("exit"));
+ }
+
+ @Test(groups = "Functional")
+ public void testGetSelectedResidues()
+ {
+ assertEquals(testee.getSelectedResidues(),
+ new StructureCommand("info selection level residue"));
+ }
+
+ @Test(groups = "Functional")
+ public void testStartNotifications()
+ {
+ List<StructureCommandI> cmds = testee.startNotifications("to here");
+ assertEquals(cmds.size(), 2);
+ assertEquals(cmds.get(0), new StructureCommand("info notify start models jalview prefix ModelChanged url to here"));
+ assertEquals(cmds.get(1), new StructureCommand("info notify start selection jalview prefix SelectionChanged url to here"));
+ }
+
+ @Test(groups = "Functional")
+ public void testStopNotifications()
+ {
+ List<StructureCommandI> cmds = testee.stopNotifications();
+ assertEquals(cmds.size(), 2);
+ assertEquals(cmds.get(0), new StructureCommand("info notify stop models jalview"));
+ assertEquals(cmds.get(1), new StructureCommand("info notify stop selection jalview"));
+ }
+
+ @Test(groups = "Functional")
+ public void testListResidueAttributes()
+ {
+ assertEquals(testee.listResidueAttributes(),
+ new StructureCommand("info resattr"));