Merge branch 'bugs/JAL-3009_blockingNetworkThreads' into releases/Release_2_10_4_Branch
authorJim Procter <jprocter@issues.jalview.org>
Thu, 7 Jun 2018 15:22:37 +0000 (16:22 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Thu, 7 Jun 2018 15:22:37 +0000 (16:22 +0100)
help/html/releases.html
help/html/whatsNew.html
resources/uniprot_mapping.xml
src/jalview/datamodel/xdb/uniprot/UniprotFeature.java
src/jalview/ws/dbsources/Uniprot.java
test/jalview/ws/dbsources/UniprotTest.java

index 7ceebff..d176bfb 100755 (executable)
@@ -71,13 +71,17 @@ li:before {
       <td width="60" nowrap>
         <div align="center">
           <strong><a name="Jalview.2.10.4b1">2.10.4b1</a><br />
-            <em>5/06/2018</em></strong>
+            <em>7/06/2018</em></strong>
         </div>
       </td>
       <td><div align="left">
           <em></em>
           <ul>
             <li>
+              <!-- JAL-2920 -->Use HGVS nomenclature for variant
+              annotation retrieved from Uniprot
+            </li>
+            <li>
               <!-- JAL-1460 -->Windows File Shortcuts can be dragged
               onto the Jalview Desktop
             </li>
@@ -88,7 +92,7 @@ li:before {
           <ul>
             <li>
               <!-- JAL-3017 -->Cannot import features with multiple
-              variant elements
+              variant elements (blocks import of some Uniprot records)
             </li>
             <li>
               <!-- JAL-2997 -->Clustal files with sequence positions in
@@ -99,14 +103,14 @@ li:before {
               not alignment area in exported graphic
             </li>
             <li>
-              <!-- JAL-2992 -->Annotation panel set too high when
-              annotation added to view
-            </li>
-            <li>
               <!-- JAL-2993 -->F2/Keyboard mode edits work when Overview
               window has input focus
             </li>
             <li>
+              <!-- JAL-2992 -->Annotation panel set too high when
+              annotation added to view (Windows)
+            </li>
+            <li>
               <!-- JAL-1460 -->Drag URL from chrome, firefox, IE to
               Jalview desktop on Windows doesn't open file<br /> <em>Dragging
                 the currently open URL and links from a page viewed in
index 0abd2a7..ed6f5c2 100755 (executable)
 </head>
 <body>
   <p>
-    <strong>What's new in Jalview 2.10.4 ?</strong>
-  </p>
-  <p>
-    This is the May 2018 release of Jalview, and the last in the 2.10.x series. Jalview 2.10.4 includes:
+    <strong>What's new in Jalview 2.10.4b1 ?</strong>
   </p>
+  <p>This is the first patch release for Jalview 2.10.4. It includes
+    the following new patches:</p>
+  <ul>
+    <li>HGVS nomenclature used for variant annotation retrieved
+      from Uniprot</li>
+    <li>Uniprot import fails for some sequences (Cannot import
+      features with multiple variant elements)</li>
+    <li>Clustal files with sequence positions in right-hand column
+      are now parsed correctly</li>
+    <li>Wrap view - export to SVG - IDs shown but not alignment
+      area in exported graphic</li>
+    <li>F2/Keyboard mode edits work when Overview window has input
+      focus</li>
+    <li>Windows specific fixes:
+      <ul>
+        <li>Annotation panel set too high when annotation added to
+          view</li>
+        <li>Updated search paths for Chimera default installation</li>
+        <li>Windows File Shortcuts can be dragged onto the Jalview
+          Desktop</li>
+        <li>Drag URL from Chrome, Firefox, IE to Jalview desktop on
+          Windows doesn't open file:<br /> Dragging the currently open
+          URL and links from a page viewed in Firefox or Chrome on
+          Windows is now fully supported.<br />
+        <strong>If you are using Edge</strong>, only links in the page
+          can be dragged.<br />
+        <strong>With Internet Explorer</strong>, only the currently open
+          URL in the browser can be dropped onto Jalview.
+        </li>
+      </ul>
+    </li>
+  </ul>
+  <p>Highlights in the 2.10.4 series include:</p>
   <ul>
     <li>Numerous efficiency improvements in the renderer and overview when working with large alignments with lots of hidden columns</li>
     <li>Use of HTTPS when connecting to Uniprot, Ensembl and other EBI web services</li>
index 4c9ad5f..68868c4 100755 (executable)
@@ -18,6 +18,7 @@
  * The Jalview Authors are detailed in the 'AUTHORS' file.
 -->
 <mapping>
+  <!-- see https://www.uniprot.org/docs/uniprot.xsd for latest Uniprot XML schema -->
        <class name="jalview.datamodel.xdb.uniprot.UniprotFile">
                  <map-to xml="uniprot"/>               
                  <field name="UniprotEntries" type="jalview.datamodel.xdb.uniprot.UniprotEntry" collection="vector">
index 3bae87e..8bd5652 100644 (file)
@@ -53,40 +53,7 @@ public class UniprotFeature
 
   public String getDescription()
   {
-    if (description == null && variation == null && original == null)
-    {
-      return null;
-    }
-    StringBuilder sb = new StringBuilder();
-    if (description != null)
-    {
-      sb.append(description);
-    }
-    if (variation != null && variation.size() > 0)
-    {
-      int i = 0;
-      for (String var : variation)
-      {
-        if (i++ > 0)
-        {
-          sb.append(",");
-        }
-        if (sb.length() > 0)
-        {
-          sb.append(" ");
-        }
-        sb.append("Variation: '" + var + "'");
-      }
-    }
-    if (original != null)
-    {
-      if (sb.length() > 0)
-      {
-        sb.append(" ");
-      }
-      sb.append("Original: '" + original + "'");
-    }
-    return sb.toString();
+    return description;
   }
 
   public void setDescription(String d)
index 6b09eb6..167cd97 100644 (file)
@@ -32,6 +32,8 @@ import jalview.datamodel.SequenceI;
 import jalview.datamodel.xdb.uniprot.UniprotEntry;
 import jalview.datamodel.xdb.uniprot.UniprotFeature;
 import jalview.datamodel.xdb.uniprot.UniprotFile;
+import jalview.schemes.ResidueProperties;
+import jalview.util.StringUtils;
 import jalview.ws.seqfetcher.DbSourceProxyImpl;
 
 import java.io.InputStream;
@@ -40,6 +42,7 @@ import java.io.Reader;
 import java.net.URL;
 import java.net.URLConnection;
 import java.util.ArrayList;
+import java.util.List;
 import java.util.Vector;
 
 import org.exolab.castor.mapping.Mapping;
@@ -278,7 +281,7 @@ public class Uniprot extends DbSourceProxyImpl
       for (UniprotFeature uf : entry.getFeature())
       {
         SequenceFeature copy = new SequenceFeature(uf.getType(),
-                uf.getDescription(), uf.getBegin(), uf.getEnd(), "Uniprot");
+                getDescription(uf), uf.getBegin(), uf.getEnd(), "Uniprot");
         copy.setStatus(uf.getStatus());
         sequence.addSequenceFeature(copy);
       }
@@ -291,6 +294,94 @@ public class Uniprot extends DbSourceProxyImpl
   }
 
   /**
+   * Constructs a feature description from the description and (optionally)
+   * original and variant fields of the Uniprot XML feature
+   * 
+   * @param uf
+   * @return
+   */
+  protected static String getDescription(UniprotFeature uf)
+  {
+    String orig = uf.getOriginal();
+    List<String> variants = uf.getVariation();
+    StringBuilder sb = new StringBuilder();
+
+    /*
+     * append variant in standard format if present
+     * e.g. p.Arg59Lys
+     * multiple variants are split over lines using <br>
+     */
+    boolean asHtml = false;
+    if (orig != null && !orig.isEmpty() && variants != null
+            && !variants.isEmpty())
+    {
+      int p = 0;
+      for (String var : variants)
+      {
+        // TODO proper HGVS nomenclature for delins structural variations
+        // http://varnomen.hgvs.org/recommendations/protein/variant/delins/
+        // 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.");
+        if (orig.length() < 4)
+        {
+          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()));
+
+        if (var.length() < 4)
+        {
+          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())
+        {
+          sb.append("<br/>&nbsp;&nbsp;");
+          asHtml = true;
+        }
+        else
+        {
+          sb.append(" ");
+        }
+      }
+    }
+    String description = uf.getDescription();
+    if (description != null)
+    {
+      sb.append(description);
+    }
+    if (asHtml)
+    {
+      sb.insert(0, "<html>");
+      sb.append("</html>");
+    }
+
+    return sb.toString();
+  }
+
+  /**
    * 
    * @param entry
    *          UniportEntry
index b70e581..060c303 100644 (file)
@@ -35,6 +35,7 @@ import java.io.Reader;
 import java.io.StringReader;
 import java.util.Vector;
 
+import org.testng.Assert;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
@@ -67,6 +68,8 @@ public class UniprotTest
           + "<feature type=\"sequence variant\" description=\"Pathogenic\"><original>M</original><variation>L</variation><location><position position=\"41\"/></location></feature>"
           + "<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>";
 
@@ -102,7 +105,7 @@ public class UniprotTest
      * Check sequence features
      */
     Vector<UniprotFeature> features = entry.getFeature();
-    assertEquals(7, features.size());
+    assertEquals(9, features.size());
     UniprotFeature sf = features.get(0);
     assertEquals("signal peptide", sf.getType());
     assertNull(sf.getDescription());
@@ -124,33 +127,50 @@ public class UniprotTest
 
     sf = features.get(3);
     assertEquals("sequence variant", sf.getType());
-    assertEquals("Variation: 'L' Original: 'M'", sf.getDescription());
+    assertNull(sf.getDescription());
     assertEquals(41, sf.getPosition());
     assertEquals(41, sf.getBegin());
     assertEquals(41, sf.getEnd());
 
     sf = features.get(4);
     assertEquals("sequence variant", sf.getType());
-    assertEquals("Pathogenic Variation: 'L' Original: 'M'",
-            sf.getDescription());
+    assertEquals("Pathogenic", sf.getDescription());
     assertEquals(41, sf.getPosition());
     assertEquals(41, sf.getBegin());
     assertEquals(41, sf.getEnd());
 
     sf = features.get(5);
     assertEquals("sequence variant", sf.getType());
-    assertEquals("Pathogenic Original: 'M'", sf.getDescription());
+    assertEquals("Pathogenic", sf.getDescription());
     assertEquals(41, sf.getPosition());
     assertEquals(41, sf.getBegin());
     assertEquals(41, sf.getEnd());
 
     sf = features.get(6);
     assertEquals("sequence variant", sf.getType());
-    assertEquals("Foo Variation: 'L', Variation: 'LMV' Original: 'M'",
+    assertEquals("Foo",
             sf.getDescription());
     assertEquals(42, sf.getPosition());
     assertEquals(42, sf.getBegin());
     assertEquals(42, sf.getEnd());
+    Assert.assertEquals(Uniprot.getDescription(sf),
+            "<html>p.Met42Leu" + "<br/>&nbsp;&nbsp;"
+                    + "p.Met42LeuMetVal Foo</html>");
+
+    sf = features.get(7);
+    assertEquals(42, sf.getBegin());
+    assertEquals(43, sf.getEnd());
+    Assert.assertEquals(Uniprot.getDescription(sf),
+            "<html>p.MetLeu42LeuLeu" + "<br/>&nbsp;&nbsp;"
+                    + "p.MetLeu42LeuMetVal Foo</html>");
+
+    sf = features.get(8);
+    assertEquals(42, sf.getBegin());
+    assertEquals(45, sf.getEnd());
+    Assert.assertEquals(Uniprot.getDescription(sf),
+            "<html>p.MLML42LeuLeu" + "<br/>&nbsp;&nbsp;"
+                    + "p.MLML42LMVK Foo Too</html>");
+
     /*
      * Check cross-references
      */
@@ -219,4 +239,53 @@ public class UniprotTest
     assertEquals(expectedDescription,
             Uniprot.getUniprotEntryDescription(entry));
   }
+
+  @Test(groups = { "Functional" })
+  public void testGetDescription()
+  {
+    UniprotFeature uf = new UniprotFeature();
+    assertEquals("", Uniprot.getDescription(uf));
+
+    uf.setDescription("Hello");
+    assertEquals("Hello", Uniprot.getDescription(uf));
+
+    uf.setPosition(23);
+    uf.setOriginal("K");
+    Vector<String> vars = new Vector<>();
+    vars.add("y");
+    uf.setVariation(vars);
+    assertEquals("p.Lys23Tyr Hello", Uniprot.getDescription(uf));
+
+    // multiple variants generate an html description over more than one line
+    vars.add("W");
+    assertEquals("<html>p.Lys23Tyr<br/>&nbsp;&nbsp;p.Lys23Trp Hello</html>",
+            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 single letter code
+    vars.clear();
+    vars.add("KWES");
+    assertEquals("p.KLST23KWES Hello", Uniprot.getDescription(uf));
+
+    vars.clear();
+    vars.add("z"); // unknown variant - fails gracefully
+    uf.setOriginal("K");
+    assertEquals("p.Lys23z Hello", Uniprot.getDescription(uf));
+
+    uf.setVariation(null); // variant missing - is ignored
+    assertEquals("Hello", Uniprot.getDescription(uf));
+  }
 }