- /*
- * map residues 1-10 to residues 21-30 (atoms 105-150) in structures
- */
- HashMap<Integer, int[]> map = new HashMap<Integer, int[]>();
- for (int pos = 1; pos <= seq1.getLength(); pos++)
- {
- map.put(pos, new int[] { 20 + pos, 5 * (20 + pos) });
- }
- StructureMapping sm1 = new StructureMapping(seq1, "seq1.pdb", "pdb1",
- "A", map, null);
- ssm.addStructureMapping(sm1);
- StructureMapping sm2 = new StructureMapping(seq2, "seq2.pdb", "pdb2",
- "B", map, null);
- ssm.addStructureMapping(sm2);
-
- StructureMappingcommandSet[] commands = ChimeraCommands
- .getColourBySequenceCommand(ssm, files, seqs, sr, af.alignPanel);
- assertEquals(1, commands.length);
- assertEquals(1, commands[0].commands.length);
- String theCommand = commands[0].commands[0];
- // M colour is #82827d (see strand.html help page)
- assertTrue(theCommand.contains("color #82827d #0:21.A|#1:21.B"));
- // H colour is #60609f
- assertTrue(theCommand.contains("color #60609f #0:22.A"));
- // V colour is #ffff00
- assertTrue(theCommand.contains("color #ffff00 #1:22.B"));
- // hidden columns are Gray (128, 128, 128)
- assertTrue(theCommand.contains("color #808080 #0:23-25.A|#1:23-25.B"));
- // S and G are both coloured #4949b6
- assertTrue(theCommand.contains("color #4949b6 #0:26-30.A|#1:26-30.B"));
+ @Test(groups = "Functional")
+ public void testGetAtomSpec_alphaOnly()
+ {
+ StructureCommandsI testee = new ChimeraCommands();
+ 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()
+ {
+ StructureCommandsI testee = new ChimeraCommands();
+ assertEquals(testee.getModelStartNo(), 0);
+ }
+
+ @Test(groups = "Functional")
+ public void testGetResidueSpec()
+ {
+ ChimeraCommands testee = new ChimeraCommands();
+ assertEquals(testee.getResidueSpec("ALA"), "::ALA");
+ }
+
+ @Test(groups = "Functional")
+ public void testShowBackbone()
+ {
+ ChimeraCommands testee = new ChimeraCommands();
+ 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()
+ {
+ ChimeraCommands testee = new ChimeraCommands();
+ assertEquals(testee.openCommandFile("nowhere").getCommand(),
+ "open cmd:nowhere");
+ }
+
+ @Test(groups = "Functional")
+ public void testSaveSession()
+ {
+ ChimeraCommands testee = new ChimeraCommands();
+ assertEquals(testee.saveSession("somewhere").getCommand(),
+ "save somewhere");
+ }
+
+ @Test(groups = "Functional")
+ public void testGetColourCommand()
+ {
+ ChimeraCommands testee = new ChimeraCommands();
+ assertEquals(testee.getColourCommand("something", Color.MAGENTA)
+ .getCommand(),
+ "color #ff00ff something");
+ }
+
+ @Test(groups = "Functional")
+ public void testSetAttribute()
+ {
+ ChimeraCommands testee = new ChimeraCommands();
+ 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("phi", "27.3", model).getCommand(),
+ "setattr res phi '27.3' #1:89-92.A|#2:8-9.B,12-20.B");