JAL-2422 JAL-3551 unit tests updated for code changes
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 15 May 2020 16:56:17 +0000 (17:56 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 15 May 2020 16:56:17 +0000 (17:56 +0100)
test/jalview/ext/jmol/JmolCommandsTest.java
test/jalview/ext/pymol/PymolCommandsTest.java
test/jalview/ext/rbvi/chimera/ChimeraCommandsTest.java
test/jalview/ext/rbvi/chimera/ChimeraXCommandsTest.java
test/jalview/structures/models/AAStructureBindingModelTest.java

index 211e918..1ade00e 100644 (file)
@@ -23,6 +23,15 @@ package jalview.ext.jmol;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertTrue;
 
+import java.awt.Color;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
 import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.ColumnSelection;
@@ -38,15 +47,6 @@ import jalview.structure.StructureCommandsI;
 import jalview.structure.StructureMapping;
 import jalview.structure.StructureSelectionManager;
 
-import java.awt.Color;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
 public class JmolCommandsTest
 {
 
@@ -182,13 +182,12 @@ public class JmolCommandsTest
     // they were added; within colour, by model, by chain, ranges in start order
     List<StructureCommandI> commands = new JmolCommands()
             .colourBySequence(map);
-    assertEquals(commands.size(), 3);
+    assertEquals(commands.size(), 1);
     String expected1 = "select 2-5:A/1.1|9-23:A/1.1|7:B/1.1|1:A/2.1|4-7:B/2.1;color[0,0,255]";
     String expected2 = "select 3-5:A/2.1|8:A/2.1;color[255,255,0]";
     String expected3 = "select 3-9:A/1.1;color[255,0,0]";
-    assertEquals(commands.get(0).getCommand(), expected1);
-    assertEquals(commands.get(1).getCommand(), expected2);
-    assertEquals(commands.get(2).getCommand(), expected3);
+    assertEquals(commands.get(0).getCommand(),
+            expected1 + ";" + expected2 + ";" + expected3);
   }
 
   @Test(groups = { "Functional" })
index 9dc107e..c0f22c8 100644 (file)
@@ -22,10 +22,6 @@ package jalview.ext.pymol;
 
 import static org.testng.Assert.assertEquals;
 
-import jalview.structure.AtomSpecModel;
-import jalview.structure.StructureCommandI;
-import jalview.structure.StructureCommandsI;
-
 import java.awt.Color;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -33,6 +29,10 @@ import java.util.Map;
 
 import org.testng.annotations.Test;
 
+import jalview.structure.AtomSpecModel;
+import jalview.structure.StructureCommandI;
+import jalview.structure.StructureCommandsI;
+
 public class PymolCommandsTest
 {
 
@@ -202,7 +202,7 @@ public class PymolCommandsTest
   {
     PymolCommands testee = new PymolCommands();
     assertEquals(testee.openCommandFile("commands.pml").toString(),
-            "@commands.pml");
+            "run(commands.pml)");
   }
 
   @Test(groups = "Functional")
index 5afbd7a..f087020 100644 (file)
@@ -23,10 +23,6 @@ package jalview.ext.rbvi.chimera;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertTrue;
 
-import jalview.structure.AtomSpecModel;
-import jalview.structure.StructureCommandI;
-import jalview.structure.StructureCommandsI;
-
 import java.awt.Color;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
@@ -35,6 +31,10 @@ import java.util.Map;
 
 import org.testng.annotations.Test;
 
+import jalview.structure.AtomSpecModel;
+import jalview.structure.StructureCommandI;
+import jalview.structure.StructureCommandsI;
+
 public class ChimeraCommandsTest
 {
 
@@ -57,12 +57,9 @@ public class ChimeraCommandsTest
     // they were added; within colour, by model, by chain, ranges in start order
     List<StructureCommandI> commands = new ChimeraCommands()
             .colourBySequence(map);
-    assertEquals(commands.size(), 3);
+    assertEquals(commands.size(), 1);
     assertEquals(commands.get(0).getCommand(),
-            "color #0000ff #0:2-5.A,9-23.A,7.B|#1:1.A,4-7.B");
-    assertEquals(commands.get(1).getCommand(),
-            "color #ffff00 #1:3-5.A,8.A");
-    assertEquals(commands.get(2).getCommand(), "color #ff0000 #0:3-9.A");
+            "color #0000ff #0:2-5.A,9-23.A,7.B|#1:1.A,4-7.B;color #ffff00 #1:3-5.A,8.A;color #ff0000 #0:3-9.A");
   }
 
   @Test(groups = { "Functional" })
@@ -205,11 +202,13 @@ public class ChimeraCommandsTest
     toAlign.addRange("2", 22, 22, "C");
     List<StructureCommandI> command = testee.superposeStructures(ref,
             toAlign);
-    String refSpec = "#1:12-14.A,18.B,22-23.B@CA|P&~@.B-Z&~@.2-9";
-    String toAlignSpec = "#2:15-17.B,20-21.B,22.C@CA|P&~@.B-Z&~@.2-9";
+    // 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; ribbon %s|%s; focus",
-            refSpec, toAlignSpec, refSpec, toAlignSpec);
+            "match %s%s %s%s; ribbon %s|%s; focus", toAlignSpec,
+            carbonAlphas, refSpec, carbonAlphas, toAlignSpec, refSpec);
     assertEquals(command.get(0).getCommand(), expected);
   }
 
@@ -221,34 +220,34 @@ public class ChimeraCommandsTest
     assertEquals(testee.getAtomSpec(model, true), "");
     model.addRange("1", 2, 4, "A");
     assertEquals(testee.getAtomSpec(model, true),
-            "#1:2-4.A@CA|P&~@.B-Z&~@.2-9");
+            "#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|P&~@.B-Z&~@.2-9");
+            "#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|P&~@.B-Z&~@.2-9");
+            "#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|P&~@.B-Z&~@.2-9");
+            "#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|P&~@.B-Z&~@.2-9|#1:2-5.A,8.A,5-7.B@CA|P&~@.B-Z&~@.2-9");
+            "#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|P&~@.B-Z&~@.2-9|#1:2-5.A,8.A,5-7.B@CA|P&~@.B-Z&~@.2-9");
+            "#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|P&~@.B-Z&~@.2-9|#1:2-5.A,8.A,5-10.B@CA|P&~@.B-Z&~@.2-9");
+            "#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|P&~@.B-Z&~@.2-9|#1:2-5.A,8.A,5-10.B@CA|P&~@.B-Z&~@.2-9");
+            "#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|P&~@.B-Z&~@.2-9|#1:2-5.A,8.A,5-10.B@CA|P&~@.B-Z&~@.2-9");
+            "#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|P&~@.B-Z&~@.2-9|#1:2-5.A,8.A,5-10.B@CA|P&~@.B-Z&~@.2-9|#5:25-35.@CA|P&~@.B-Z&~@.2-9");
+            "#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");
   
   }
 
@@ -272,7 +271,8 @@ public class ChimeraCommandsTest
     ChimeraCommands testee = new ChimeraCommands();
     List<StructureCommandI> cmds = testee.showBackbone();
     assertEquals(cmds.size(), 1);
-    assertEquals(cmds.get(0).getCommand(), "~display all;chain @CA|P");
+    assertEquals(cmds.get(0).getCommand(),
+            "~display all;~ribbon;chain @CA|P");
   }
 
   @Test(groups = "Functional")
index 3bd64d7..044a1d9 100644 (file)
@@ -23,10 +23,6 @@ package jalview.ext.rbvi.chimera;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertTrue;
 
-import jalview.structure.AtomSpecModel;
-import jalview.structure.StructureCommandI;
-import jalview.structure.StructureCommandsI;
-
 import java.awt.Color;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
@@ -35,6 +31,10 @@ import java.util.Map;
 
 import org.testng.annotations.Test;
 
+import jalview.structure.AtomSpecModel;
+import jalview.structure.StructureCommandI;
+import jalview.structure.StructureCommandsI;
+
 public class ChimeraXCommandsTest
 {
   @Test(groups = { "Functional" })
@@ -80,11 +80,9 @@ public class ChimeraXCommandsTest
      */
     List<StructureCommandI> commands = new ChimeraXCommands()
             .colourBySequence(map);
-    assertEquals(commands.size(), 3);
+    assertEquals(commands.size(), 1);
     assertEquals(commands.get(0).getCommand(),
-            "color #1/A:2-5,9-23/B:7|#2/A:1/B:4-7 #0000ff");
-    assertEquals(commands.get(1).getCommand(), "color #2/A:3-5,8 #ffff00");
-    assertEquals(commands.get(2).getCommand(), "color #1/A:3-9 #ff0000");
+            "color #1/A:2-5,9-23/B:7|#2/A:1/B:4-7 #0000ff;color #2/A:3-5,8 #ffff00;color #1/A:3-9 #ff0000");
   }
 
   @Test(groups = { "Functional" })
@@ -184,8 +182,8 @@ public class ChimeraXCommandsTest
      * ribbon command does not
      */
     String expected = String.format(
-            "align %s@CA|P toAtoms %s@CA|P; ribbon %s|%s; view",
-            refSpec, toAlignSpec, refSpec, toAlignSpec);
+            "align %s@CA toAtoms %s@CA; ribbon %s|%s; view",
+            toAlignSpec, refSpec, toAlignSpec, refSpec);
     assertEquals(cmd, expected);
   }
 
@@ -230,31 +228,31 @@ public class ChimeraXCommandsTest
     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|P");
+    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|P");
+    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|P");
+    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|P");
+    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|P|#1/A:2-5,8/B:5-7@CA|P");
+            "#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|P|#1/A:2-5,8/B:5-7@CA|P");
+            "#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|P|#1/A:2-5,8/B:5-10@CA|P");
+            "#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|P|#1/A:2-5,8/B:5-10@CA|P");
+            "#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|P|#1/A:2-5,8/B:5-10@CA|P");
+            "#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|P|#1/A:2-5,8/B:5-10@CA|P|#5/:25-35@CA|P");
+            "#0/B:1-4/C:3-10@CA|#1/A:2-5,8/B:5-10@CA|#5/:25-35@CA");
   }
 
   @Test(groups = "Functional")
@@ -278,7 +276,7 @@ public class ChimeraXCommandsTest
     List<StructureCommandI> showBackbone = testee.showBackbone();
     assertEquals(showBackbone.size(), 1);
     assertEquals(showBackbone.get(0).getCommand(),
-            "~display all;show @CA|P pbonds");
+            "~display all;~ribbon;show @CA|P atoms");
   }
 
   @Test(groups = "Functional")
index 5e0e52f..16452a5 100644 (file)
@@ -25,6 +25,18 @@ import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertNotNull;
 import static org.testng.Assert.assertTrue;
 
+import java.awt.Color;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.BitSet;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
 import jalview.api.AlignmentViewPanel;
 import jalview.api.SequenceRenderer;
 import jalview.datamodel.Alignment;
@@ -46,19 +58,6 @@ import jalview.structure.AtomSpecModel;
 import jalview.structure.StructureCommandI;
 import jalview.structure.StructureMapping;
 import jalview.structure.StructureSelectionManager;
-
-import java.awt.Color;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.BitSet;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
 import junit.extensions.PA;
 
 /**
@@ -286,9 +285,20 @@ public class AAStructureBindingModelTest
         return null;
       }
 
+      /*
+       * for this test, let structure model ids be 0, 1, ...
+       * corresponding to first, second etc pdbfile
+       */
       @Override
-      protected String getModelIdForFile(String chainId)
+      protected String getModelIdForFile(String pdbfile)
       {
+        for (int i = 0; i < this.getPdbCount(); i++)
+        {
+          if (pdbfile.equals(this.getPdbEntry(i).getFile()))
+          {
+            return String.valueOf(i);
+          }
+        }
         return "";
       }
 
@@ -415,8 +425,8 @@ public class AAStructureBindingModelTest
     SequenceI[][] seqs = new SequenceI[][] { { seq1 }, { seq2 } };
     String[] files = new String[] { "seq1.pdb", "seq2.pdb" };
     PDBEntry[] pdbFiles = new PDBEntry[2];
-    pdbFiles[0] = new PDBEntry("PDB1", "A", Type.PDB, "INLINEPDB1");
-    pdbFiles[1] = new PDBEntry("PDB2", "B", Type.PDB, "INLINEPDB2");
+    pdbFiles[0] = new PDBEntry("PDB1", "A", Type.PDB, "seq1.pdb");
+    pdbFiles[1] = new PDBEntry("PDB2", "B", Type.PDB, "seq2.pdb");
     StructureSelectionManager ssm = new StructureSelectionManager();
   
     /*