JAL-2920 don’t output variant/original sequence as three-letter codes for more than...
authorJim Procter <jprocter@issues.jalview.org>
Wed, 6 Jun 2018 15:06:03 +0000 (16:06 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Wed, 6 Jun 2018 15:06:03 +0000 (16:06 +0100)
src/jalview/ws/dbsources/Uniprot.java
test/jalview/ws/dbsources/UniprotTest.java

index 274ad32..d44b104 100644 (file)
@@ -317,24 +317,41 @@ public class Uniprot extends DbSourceProxyImpl
       for (String var : variants)
       {
         // TODO proper HGVC nomenclature for delins structural variations
+        // for now we are pragmatic - any orig/variant sequence longer than
+        // three characters is shown with single-character notation rather than
+        // three-letter notation
         sb.append("p.");
-        for (int c = 0, clen = orig.length(); c < clen; c++)
+        if (orig.length() < 4)
         {
-          char origchar = orig.charAt(c);
-          String orig3 = ResidueProperties.aa2Triplet.get("" + origchar);
-          sb.append(orig3 == null ? origchar
-                  : StringUtils.toSentenceCase(orig3));
+          for (int c = 0, clen = orig.length(); c < clen; c++)
+          {
+            char origchar = orig.charAt(c);
+            String orig3 = ResidueProperties.aa2Triplet.get("" + origchar);
+            sb.append(orig3 == null ? origchar
+                    : StringUtils.toSentenceCase(orig3));
+          }
+        }
+        else
+        {
+          sb.append(orig);
         }
 
         sb.append(Integer.toString(uf.getPosition()));
 
-        for (int c = 0, clen = var.length(); c < clen; c++)
+        if (var.length() < 4)
         {
-          char varchar = var.charAt(c);
-          String var3 = ResidueProperties.aa2Triplet.get("" + varchar);
-
-          sb.append(var3 != null ? StringUtils.toSentenceCase(var3)
-                  : "" + varchar);
+          for (int c = 0, clen = var.length(); c < clen; c++)
+          {
+            char varchar = var.charAt(c);
+            String var3 = ResidueProperties.aa2Triplet.get("" + varchar);
+
+            sb.append(var3 != null ? StringUtils.toSentenceCase(var3)
+                    : "" + varchar);
+          }
+        }
+        else
+        {
+          sb.append(var);
         }
         if (++p != variants.size())
         {
index c7f216e..ab79f10 100644 (file)
@@ -69,6 +69,7 @@ public class UniprotTest
           + "<feature type=\"sequence variant\" description=\"Pathogenic\"><original>M</original><location><position position=\"41\"/></location></feature>"
           + "<feature type=\"sequence variant\" description=\"Foo\"><variation>L</variation><variation>LMV</variation><original>M</original><location><position position=\"42\"/></location></feature>"
           + "<feature type=\"sequence variant\" description=\"Foo\"><variation>LL</variation><variation>LMV</variation><original>ML</original><location><begin position=\"42\"/><end position=\"43\"/></location></feature>"
+          + "<feature type=\"sequence variant\" description=\"Foo Too\"><variation>LL</variation><variation>LMVK</variation><original>MLML</original><location><begin position=\"42\"/><end position=\"45\"/></location></feature>"
           + "<sequence length=\"10\" mass=\"27410\" checksum=\"8CB760AACF88FE6C\" modified=\"2008-01-15\" version=\"1\">MHAPL VSKDL</sequence></entry>"
           + "</uniprot>";
 
@@ -104,7 +105,7 @@ public class UniprotTest
      * Check sequence features
      */
     Vector<UniprotFeature> features = entry.getFeature();
-    assertEquals(8, features.size());
+    assertEquals(9, features.size());
     UniprotFeature sf = features.get(0);
     assertEquals("signal peptide", sf.getType());
     assertNull(sf.getDescription());
@@ -159,9 +160,17 @@ public class UniprotTest
     assertEquals(42, sf.getBegin());
     assertEquals(43, sf.getEnd());
     Assert.assertEquals(Uniprot.getDescription(sf),
-            "p.MetLeu42LeuLeu" + "\n" + "p.MetLeu42LeuMetVal Foo"); /*
-                                                                    * Check cross-references
-                                                                    */
+            "p.MetLeu42LeuLeu" + "\n" + "p.MetLeu42LeuMetVal Foo");
+
+    sf = features.get(8);
+    assertEquals(42, sf.getBegin());
+    assertEquals(45, sf.getEnd());
+    Assert.assertEquals(Uniprot.getDescription(sf),
+            "p.MLML42LeuLeu" + "\n" + "p.MLML42LMVK Foo Too");
+
+    /*
+     * Check cross-references
+     */
     Vector<PDBEntry> xrefs = entry.getDbReference();
     assertEquals(3, xrefs.size());