JAL-1925 update source version in license
[jalview.git] / test / jalview / util / MapListTest.java
index 6e7e19e..bc3bd24 100644 (file)
@@ -1,3 +1,23 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b2)
+ * Copyright (C) 2015 The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
 package jalview.util;
 
 import static org.testng.AssertJUnit.assertEquals;
@@ -14,27 +34,22 @@ import org.testng.annotations.Test;
 public class MapListTest
 {
 
-  @Test(groups ={ "Functional" })
+  @Test(groups = { "Functional" })
   public void testSomething()
   {
-    MapList ml = new MapList(new int[]
-    { 1, 5, 10, 15, 25, 20 }, new int[]
-    { 51, 1 }, 1, 3);
-    MapList ml1 = new MapList(new int[]
-    { 1, 3, 17, 4 }, new int[]
-    { 51, 1 }, 1, 3);
-    MapList ml2 = new MapList(new int[]
-    { 1, 60 }, new int[]
-    { 1, 20 }, 3, 1);
+    MapList ml = new MapList(new int[] { 1, 5, 10, 15, 25, 20 }, new int[] {
+        51, 1 }, 1, 3);
+    MapList ml1 = new MapList(new int[] { 1, 3, 17, 4 },
+            new int[] { 51, 1 }, 1, 3);
+    MapList ml2 = new MapList(new int[] { 1, 60 }, new int[] { 1, 20 }, 3,
+            1);
     // test internal consistency
     int to[] = new int[51];
     testMap(ml, 1, 60);
-    MapList mldna = new MapList(new int[]
-    { 2, 2, 6, 8, 12, 16 }, new int[]
+    MapList mldna = new MapList(new int[] { 2, 2, 6, 8, 12, 16 }, new int[]
     { 1, 3 }, 3, 1);
     int[] frm = mldna.locateInFrom(1, 1);
-    testLocateFrom(mldna, 1, 1, new int[]
-    { 2, 2, 6, 7 });
+    testLocateFrom(mldna, 1, 1, new int[] { 2, 2, 6, 7 });
     testMap(mldna, 1, 3);
     /*
      * for (int from=1; from<=51; from++) { int[] too=ml.shiftTo(from); int[]
@@ -99,7 +114,7 @@ public class MapListTest
       if (mmap[1][i - 1] == -1)
       {
         System.out.print(i + "=XXX");
-  
+
       }
       else
       {
@@ -160,7 +175,7 @@ public class MapListTest
       if (mmap[1][i - 1] == -1)
       {
         System.out.print(i + "=XXX");
-  
+
       }
       else
       {
@@ -219,16 +234,14 @@ public class MapListTest
    * Tests for method that locates ranges in the 'from' map for given range in
    * the 'to' map.
    */
-  @Test(groups ={ "Functional" })
+  @Test(groups = { "Functional" })
   public void testLocateInFrom_noIntrons()
   {
     /*
      * Simple mapping with no introns
      */
-    int[] codons = new int[]
-    { 1, 12 };
-    int[] protein = new int[]
-    { 1, 4 };
+    int[] codons = new int[] { 1, 12 };
+    int[] protein = new int[] { 1, 4 };
     MapList ml = new MapList(codons, protein, 3, 1);
     assertEquals("[1, 3]", Arrays.toString(ml.locateInFrom(1, 1)));
     assertEquals("[4, 6]", Arrays.toString(ml.locateInFrom(2, 2)));
@@ -251,17 +264,15 @@ public class MapListTest
    * Tests for method that locates ranges in the 'from' map for given range in
    * the 'to' map.
    */
-  @Test(groups ={ "Functional" })
+  @Test(groups = { "Functional" })
   public void testLocateInFrom_withIntrons()
   {
     /*
      * Exons at positions [2, 3, 5] [6, 7, 9] [10, 12, 14] [16, 17, 18] i.e.
      * 2-3, 5-7, 9-10, 12-12, 14-14, 16-18
      */
-    int[] codons =
-    { 2, 3, 5, 7, 9, 10, 12, 12, 14, 14, 16, 18 };
-    int[] protein =
-    { 1, 4 };
+    int[] codons = { 2, 3, 5, 7, 9, 10, 12, 12, 14, 14, 16, 18 };
+    int[] protein = { 1, 4 };
     MapList ml = new MapList(codons, protein, 3, 1);
     assertEquals("[2, 3, 5, 5]", Arrays.toString(ml.locateInFrom(1, 1)));
     assertEquals("[6, 7, 9, 9]", Arrays.toString(ml.locateInFrom(2, 2)));
@@ -274,16 +285,14 @@ public class MapListTest
    * Tests for method that locates ranges in the 'to' map for given range in the
    * 'from' map.
    */
-  @Test(groups ={ "Functional" })
+  @Test(groups = { "Functional" })
   public void testLocateInTo_noIntrons()
   {
     /*
      * Simple mapping with no introns
      */
-    int[] codons = new int[]
-    { 1, 12 };
-    int[] protein = new int[]
-    { 1, 4 };
+    int[] codons = new int[] { 1, 12 };
+    int[] protein = new int[] { 1, 4 };
     MapList ml = new MapList(codons, protein, 3, 1);
     assertEquals("[1, 1]", Arrays.toString(ml.locateInTo(1, 3)));
     assertEquals("[2, 2]", Arrays.toString(ml.locateInTo(4, 6)));
@@ -314,20 +323,18 @@ public class MapListTest
    * Tests for method that locates ranges in the 'to' map for given range in the
    * 'from' map.
    */
-  @Test(groups ={ "Functional" })
+  @Test(groups = { "Functional" })
   public void testLocateInTo_withIntrons()
   {
     /*
      * Exons at positions [2, 3, 5] [6, 7, 9] [10, 12, 14] [16, 17, 18] i.e.
      * 2-3, 5-7, 9-10, 12-12, 14-14, 16-18
      */
-    int[] codons =
-    { 2, 3, 5, 7, 9, 10, 12, 12, 14, 14, 16, 18 };
+    int[] codons = { 2, 3, 5, 7, 9, 10, 12, 12, 14, 14, 16, 18 };
     /*
      * Mapped proteins at positions 1, 3, 4, 6 in the sequence
      */
-    int[] protein =
-    { 1, 1, 3, 4, 6, 6 };
+    int[] protein = { 1, 1, 3, 4, 6, 6 };
     MapList ml = new MapList(codons, protein, 3, 1);
 
     /*
@@ -357,13 +364,11 @@ public class MapListTest
   /**
    * Test equals method.
    */
-  @Test(groups ={ "Functional" })
+  @Test(groups = { "Functional" })
   public void testEquals()
   {
-    int[] codons = new int[]
-    { 2, 3, 5, 7, 9, 10, 12, 12, 14, 14, 16, 18 };
-    int[] protein = new int[]
-    { 1, 4 };
+    int[] codons = new int[] { 2, 3, 5, 7, 9, 10, 12, 12, 14, 14, 16, 18 };
+    int[] protein = new int[] { 1, 4 };
     MapList ml = new MapList(codons, protein, 3, 1);
     MapList ml1 = new MapList(codons, protein, 3, 1); // same values
     MapList ml2 = new MapList(codons, protein, 2, 1); // fromRatio differs
@@ -406,27 +411,23 @@ public class MapListTest
   /**
    * Test for the method that flattens a list of ranges into a single array.
    */
-  @Test(groups ={ "Functional" })
+  @Test(groups = { "Functional" })
   public void testGetRanges()
   {
     List<int[]> ranges = new ArrayList<int[]>();
-    ranges.add(new int[]
-    { 2, 3 });
-    ranges.add(new int[]
-    { 5, 6 });
+    ranges.add(new int[] { 2, 3 });
+    ranges.add(new int[] { 5, 6 });
     assertEquals("[2, 3, 5, 6]", Arrays.toString(MapList.getRanges(ranges)));
   }
 
   /**
    * Check state after construction
    */
-  @Test(groups ={ "Functional" })
+  @Test(groups = { "Functional" })
   public void testConstructor()
   {
-    int[] codons =
-    { 2, 3, 5, 7, 9, 10, 12, 12, 14, 14, 16, 18 };
-    int[] protein =
-    { 1, 1, 3, 4, 6, 6 };
+    int[] codons = { 2, 3, 5, 7, 9, 10, 12, 12, 14, 14, 16, 18 };
+    int[] protein = { 1, 1, 3, 4, 6, 6 };
     MapList ml = new MapList(codons, protein, 3, 1);
     assertEquals(3, ml.getFromRatio());
     assertEquals(2, ml.getFromLowest());
@@ -478,13 +479,11 @@ public class MapListTest
   /**
    * Test the method that creates an inverse mapping
    */
-  @Test(groups ={ "Functional" })
+  @Test(groups = { "Functional" })
   public void testGetInverse()
   {
-    int[] codons =
-    { 2, 3, 5, 7, 9, 10, 12, 12, 14, 14, 16, 18 };
-    int[] protein =
-    { 1, 1, 3, 4, 6, 6 };
+    int[] codons = { 2, 3, 5, 7, 9, 10, 12, 12, 14, 14, 16, 18 };
+    int[] protein = { 1, 1, 3, 4, 6, 6 };
 
     MapList ml = new MapList(codons, protein, 3, 1);
     MapList ml2 = ml.getInverse();
@@ -498,12 +497,11 @@ public class MapListTest
             prettyPrint(ml2.getFromRanges()));
   }
 
-  @Test(groups ={ "Functional" })
+  @Test(groups = { "Functional" })
   public void testToString()
   {
-    MapList ml = new MapList(new int[]
-    { 1, 5, 10, 15, 25, 20 }, new int[]
-    { 51, 1 }, 1, 3);
+    MapList ml = new MapList(new int[] { 1, 5, 10, 15, 25, 20 }, new int[] {
+        51, 1 }, 1, 3);
     String s = ml.toString();
     assertEquals("From (1:3) [ [1, 5] [10, 15] [25, 20] ] To [ [51, 1] ]",
             s);