JAL-2920 unit tests for 3 or more original or variant bases
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 6 Jun 2018 15:47:55 +0000 (16:47 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 6 Jun 2018 15:47:55 +0000 (16:47 +0100)
test/jalview/ws/dbsources/UniprotTest.java

index ab79f10..67d5d62 100644 (file)
@@ -248,14 +248,39 @@ public class UniprotTest
 
     uf.setPosition(23);
     uf.setOriginal("K");
-    Vector<String> vars = new Vector();
+    Vector<String> vars = new Vector<>();
     vars.add("y");
     uf.setVariation(vars);
     assertEquals("p.Lys23Tyr Hello", Uniprot.getDescription(uf));
 
+    vars.add("W");
+    assertEquals("p.Lys23Tyr\np.Lys23Trp Hello",
+            Uniprot.getDescription(uf));
+
+    /*
+     * indel cases
+     * up to 3 bases (original or variant) are shown using 3 letter code
+     */
+    vars.clear();
+    vars.add("KWE");
+    uf.setOriginal("KLS");
+    assertEquals(
+            "p.LysLeuSer23LysTrpGlu Hello",
+            Uniprot.getDescription(uf));
+
+    // adding a fourth original base switches to single letter code
+    uf.setOriginal("KLST");
+    assertEquals("p.KLST23LysTrpGlu Hello",
+            Uniprot.getDescription(uf));
+
+    // adding a fourth variant switches to a condensed representation
+    vars.clear();
+    vars.add("KWES");
+    assertEquals("p.KLST23KWES Hello", Uniprot.getDescription(uf));
+
     vars.clear();
     vars.add("z"); // unknown variant - fails gracefully
-    uf.setVariation(vars);
+    uf.setOriginal("K");
     assertEquals("p.Lys23z Hello", Uniprot.getDescription(uf));
 
     uf.setVariation(null); // variant missing - is ignored