Merge branch 'develop' into features/JAL-2110_makeSenseOfCrossRef
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 23 May 2016 12:22:40 +0000 (13:22 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 23 May 2016 12:22:40 +0000 (13:22 +0100)
help/html/webServices/msaclient.html
src/jalview/util/DnaUtils.java
test/jalview/util/DnaUtilsTest.java

index b685576..6266036 100644 (file)
       from the input</li>
     <li><em>realignment</em> - where any aligned sequences will be
       used by the service to construct a profile based alignment of the
-      remaining unaligned sequences.</li>
+      remaining unaligned sequences</li>
   </ul>
   <strong>JABAWS Alignment services</strong>
   <br> Most alignment services are provided by the
   <a href="JABAWS.html">JABAWS framework</a>, which allows you to
   customise the precise parameters used when running each alignment
-  prgoram. In addition to the 'Default settings', you may choose from a
+  program. In addition to the 'Default settings', you may choose from a
   range of alignment preset settings, or create your own using the
   <a href="webServicesParams.html">'Edit Settings And Run ..' dialog
     box</a>.
@@ -58,7 +58,7 @@
   <ul>
     <li><a href="http://www.clustal.org/">Clustal Omega and
         Clustal W</a> (version 2.0.12)</li>
-    <li><a href="http://align.bmr.kyushu-u.ac.jp/mafft/software/">Mafft</a>
+    <li><a href="http://mafft.cbrc.jp/alignment/software/">Mafft</a>
       (version 6.8.57b)</li>
     <li><a href="http://www.drive5.com/muscle">Muscle</a> (version
       3.8.31)</li>
index 9ab4fda..f6514e5 100644 (file)
@@ -35,14 +35,15 @@ public class DnaUtils
 
     /*
      * try to parse m..n (or simply m)
+     * also handles <m..n or m..>n (discarding < or >)
      */
     String[] range = location.split("\\.\\.");
     if (range.length == 1 || range.length == 2)
     {
       try
       {
-        int start = Integer.valueOf(range[0]);
-        int end = range.length == 1 ? start : Integer.valueOf(range[1]);
+        int start = parseRangeEnd(range[0]);
+        int end = range.length == 1 ? start : parseRangeEnd(range[1]);
         return Collections.singletonList(new int[] { start, end });
       } catch (NumberFormatException e)
       {
@@ -64,6 +65,22 @@ public class DnaUtils
   }
 
   /**
+   * Returns the integer value of a locus, discarding any < or > prefix
+   * 
+   * @throws NumberFormatException
+   *           if value is not numeric
+   */
+  static int parseRangeEnd(String loc)
+  {
+
+    if (loc.startsWith("<") || loc.startsWith(">"))
+    {
+      loc = loc.substring(1);
+    }
+    return Integer.valueOf(loc);
+  }
+
+  /**
    * Parses a complement(locationSpec) into a list of start-end ranges
    * 
    * @param location
index 9e978fe..6623c13 100644 (file)
@@ -89,10 +89,20 @@ public class DnaUtilsTest
     assertEquals(87064, ranges.get(1)[1]);
 
     /*
+     * beyond 5' or 3' locus
+     */
+    ranges = DnaUtils.parseLocation("<34..126");
+    assertEquals(1, ranges.size());
+    assertEquals(34, ranges.get(0)[0]);
+    assertEquals(126, ranges.get(0)[1]);
+    ranges = DnaUtils.parseLocation("35..>127");
+    assertEquals(1, ranges.size());
+    assertEquals(35, ranges.get(0)[0]);
+    assertEquals(127, ranges.get(0)[1]);
+
+    /*
      * valid things we don't yet handle
      */
-    assertNull(DnaUtils.parseLocation("<34..126"));
-    assertNull(DnaUtils.parseLocation("34..>126"));
     assertNull(DnaUtils.parseLocation("34.126"));
     assertNull(DnaUtils.parseLocation("34^126"));
     assertNull(DnaUtils.parseLocation("order(34..126,130..180)"));
@@ -114,6 +124,19 @@ public class DnaUtilsTest
     {
       // expected
     }
+
+    /*
+     * nested joins are not allowed; just as well since this fails to parse
+     * (splitting tokens by comma fragments the inner join expression)
+     */
+    assertNull(DnaUtils
+            .parseLocation("join(1..2,join(4..5,10..12),18..22)"));
+    /*
+     * complement may not enclose multiple ranges 
+     * parsing fails for the same reason
+     */
+    assertNull(DnaUtils
+            .parseLocation("join(complement(36618..36700,4000..4200),86988..87064)"));
   }
 
 }