+ assertEquals(testee.makeAttributeName("helixColor"), "jv_helixColor_");
+ }
+
+ @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:2-4.A");
+ model.addRange("1", 8, 8, "A");
+ assertEquals(testee.getAtomSpec(model, false), "#1:2-4.A,8.A");
+ model.addRange("1", 5, 7, "B");
+ assertEquals(testee.getAtomSpec(model, false), "#1:2-4.A,8.A,5-7.B");
+ model.addRange("1", 3, 5, "A");
+ assertEquals(testee.getAtomSpec(model, false), "#1:2-5.A,8.A,5-7.B");
+ model.addRange("0", 1, 4, "B");
+ assertEquals(testee.getAtomSpec(model, false),
+ "#0:1-4.B|#1:2-5.A,8.A,5-7.B");
+ model.addRange("0", 5, 9, "C");
+ assertEquals(testee.getAtomSpec(model, false),
+ "#0:1-4.B,5-9.C|#1:2-5.A,8.A,5-7.B");
+ model.addRange("1", 8, 10, "B");
+ assertEquals(testee.getAtomSpec(model, false),
+ "#0:1-4.B,5-9.C|#1:2-5.A,8.A,5-10.B");
+ model.addRange("1", 8, 9, "B");
+ assertEquals(testee.getAtomSpec(model, false),
+ "#0:1-4.B,5-9.C|#1:2-5.A,8.A,5-10.B");
+ model.addRange("0", 3, 10, "C"); // subsumes 5-9
+ assertEquals(testee.getAtomSpec(model, false),
+ "#0:1-4.B,3-10.C|#1:2-5.A,8.A,5-10.B");
+ model.addRange("5", 25, 35, " ");
+ assertEquals(testee.getAtomSpec(model, false),
+ "#0:1-4.B,3-10.C|#1:2-5.A,8.A,5-10.B|#5:25-35.");
+
+ }
+
+ @Test(groups = { "Functional" })
+ public void testSuperposeStructures()
+ {
+ AtomSpecModel ref = new AtomSpecModel();
+ ref.addRange("1", 12, 14, "A");
+ ref.addRange("1", 18, 18, "B");
+ ref.addRange("1", 22, 23, "B");
+ AtomSpecModel toAlign = new AtomSpecModel();
+ toAlign.addRange("2", 15, 17, "B");
+ toAlign.addRange("2", 20, 21, "B");
+ toAlign.addRange("2", 22, 22, "C");
+ List<StructureCommandI> command = testee.superposeStructures(ref,
+ toAlign);
+ // qualifier to restrict match to CA and no altlocs
+ String carbonAlphas = "@CA&~@.B-Z&~@.2-9";
+ String refSpec = "#1:12-14.A,18.B,22-23.B";
+ String toAlignSpec = "#2:15-17.B,20-21.B,22.C";
+ String expected = String.format("match %s%s %s%s; ribbon %s|%s; focus",
+ toAlignSpec, carbonAlphas, refSpec, carbonAlphas, toAlignSpec,
+ refSpec);
+ assertEquals(command.get(0).getCommand(), expected);
+ }
+
+ @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:2-4.A@CA&~@.B-Z&~@.2-9");
+ model.addRange("1", 8, 8, "A");
+ assertEquals(testee.getAtomSpec(model, true),
+ "#1:2-4.A,8.A@CA&~@.B-Z&~@.2-9");
+ model.addRange("1", 5, 7, "B");
+ assertEquals(testee.getAtomSpec(model, true),
+ "#1:2-4.A,8.A,5-7.B@CA&~@.B-Z&~@.2-9");
+ model.addRange("1", 3, 5, "A");
+ assertEquals(testee.getAtomSpec(model, true),
+ "#1:2-5.A,8.A,5-7.B@CA&~@.B-Z&~@.2-9");
+ model.addRange("0", 1, 4, "B");
+ assertEquals(testee.getAtomSpec(model, true),
+ "#0:1-4.B@CA&~@.B-Z&~@.2-9|#1:2-5.A,8.A,5-7.B@CA&~@.B-Z&~@.2-9");
+ model.addRange("0", 5, 9, "C");
+ assertEquals(testee.getAtomSpec(model, true),
+ "#0:1-4.B,5-9.C@CA&~@.B-Z&~@.2-9|#1:2-5.A,8.A,5-7.B@CA&~@.B-Z&~@.2-9");
+ model.addRange("1", 8, 10, "B");
+ assertEquals(testee.getAtomSpec(model, true),
+ "#0:1-4.B,5-9.C@CA&~@.B-Z&~@.2-9|#1:2-5.A,8.A,5-10.B@CA&~@.B-Z&~@.2-9");
+ model.addRange("1", 8, 9, "B");
+ assertEquals(testee.getAtomSpec(model, true),
+ "#0:1-4.B,5-9.C@CA&~@.B-Z&~@.2-9|#1:2-5.A,8.A,5-10.B@CA&~@.B-Z&~@.2-9");
+ model.addRange("0", 3, 10, "C"); // subsumes 5-9
+ assertEquals(testee.getAtomSpec(model, true),
+ "#0:1-4.B,3-10.C@CA&~@.B-Z&~@.2-9|#1:2-5.A,8.A,5-10.B@CA&~@.B-Z&~@.2-9");
+ model.addRange("5", 25, 35, " "); // empty chain code
+ assertEquals(testee.getAtomSpec(model, true),
+ "#0:1-4.B,3-10.C@CA&~@.B-Z&~@.2-9|#1:2-5.A,8.A,5-10.B@CA&~@.B-Z&~@.2-9|#5:25-35.@CA&~@.B-Z&~@.2-9");
+
+ }
+
+ @Test(groups = "Functional")
+ public void testGetModelStartNo()
+ {
+ assertEquals(testee.getModelStartNo(), 0);
+ }
+
+ @Test(groups = "Functional")
+ public void testGetResidueSpec()
+ {
+ assertEquals(testee.getResidueSpec("ALA"), "::ALA");
+ }
+
+ @Test(groups = "Functional")
+ public void testShowBackbone()
+ {
+ List<StructureCommandI> cmds = testee.showBackbone();
+ assertEquals(cmds.size(), 1);
+ assertEquals(cmds.get(0).getCommand(),
+ "~display all;~ribbon;chain @CA|P");
+ }
+
+ @Test(groups = "Functional")
+ public void testOpenCommandFile()
+ {
+ assertEquals(testee.openCommandFile("nowhere").getCommand(),
+ "open cmd:nowhere");
+ }
+
+ @Test(groups = "Functional")
+ public void testSaveSession()
+ {
+ assertEquals(testee.saveSession("somewhere").getCommand(),
+ "save somewhere");
+ }
+
+ @Test(groups = "Functional")
+ public void testColourByChain()
+ {
+ assertEquals(testee.colourByChain().getCommand(), "rainbow chain");
+ }
+
+ @Test(groups = { "Functional" })
+ public void testSetBackgroundColour()
+ {
+ StructureCommandI cmd = testee.setBackgroundColour(Color.PINK);
+ assertEquals(cmd.getCommand(), "set bgColor #ffafaf");
+ }
+
+ @Test(groups = { "Functional" })
+ public void testLoadFile()
+ {
+ StructureCommandI cmd = testee.loadFile("/some/filepath");
+ assertEquals(cmd.getCommand(), "open /some/filepath");
+ }
+
+ @Test(groups = { "Functional" })
+ public void testOpenSession()
+ {
+ StructureCommandI cmd = testee.openSession("/some/filepath");
+ assertEquals(cmd.getCommand(), "open chimera:/some/filepath");
+ }
+
+ @Test(groups = "Functional")
+ public void testColourByCharge()
+ {
+ List<StructureCommandI> cmds = testee.colourByCharge();
+ assertEquals(cmds.size(), 1);
+ assertEquals(cmds.get(0)
+ .getCommand(),
+ "color white;color red ::ASP,GLU;color blue ::LYS,ARG;color yellow ::CYS");
+ }
+
+ @Test(groups = "Functional")
+ public void testGetColourCommand()
+ {
+ assertEquals(testee.colourResidues("something", Color.MAGENTA)
+ .getCommand(),
+ "color #ff00ff something");
+ }
+
+ @Test(groups = "Functional")
+ public void testFocusView()
+ {
+ assertEquals(testee.focusView().getCommand(), "focus");
+ }
+
+ @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 res jv_kd '27.3' #1:89-92.A|#2:8-9.B,12-20.B");
+ }
+
+ @Test(groups = "Functional")
+ public void testCloseViewer()
+ {
+ assertEquals(testee.closeViewer(), new StructureCommand("stop really"));
+ }
+
+ @Test(groups = "Functional")
+ public void testGetSelectedResidues()
+ {
+ assertEquals(testee.getSelectedResidues(),
+ new StructureCommand("list 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("listen start models url to here"));
+ assertEquals(cmds.get(1), new StructureCommand("listen start select 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("listen stop models"));
+ assertEquals(cmds.get(1), new StructureCommand("listen stop selection"));