Added check for negative start columns
authorkjvdh <kjvanderheide@dundee.ac.uk>
Mon, 2 Oct 2017 08:14:44 +0000 (09:14 +0100)
committerkjvdh <kjvanderheide@dundee.ac.uk>
Mon, 2 Oct 2017 08:14:44 +0000 (09:14 +0100)
src/jalview/datamodel/SequenceGroup.java
test/jalview/gui/ValidColumnSelectionTest.java [new file with mode: 0644]

index e2f15e1..20b23a9 100755 (executable)
@@ -184,7 +184,19 @@ public class SequenceGroup implements AnnotatedCollectionI
     this.displayText = displayText;
     this.colourText = colourText;
     this.cs = new ResidueShader(scheme);
-    startRes = start;
+    
+    if (start > 0) // sanity check for negative start column positions
+    {
+      startRes = start;
+    }
+    else
+    {
+      jalview.bin.Cache.log.warn(
+              "Negative start column index detected, resetting to default index: "
+                      + startRes);
+      // start = startRes;
+    }
+    
     endRes = end;
     recalcConservation();
   }
@@ -208,7 +220,20 @@ public class SequenceGroup implements AnnotatedCollectionI
       displayBoxes = seqsel.displayBoxes;
       displayText = seqsel.displayText;
       colourText = seqsel.colourText;
-      startRes = seqsel.startRes;
+      
+      if (seqsel.startRes > 0) // sanity check for negative start column
+                               // positions
+      {
+        startRes = seqsel.startRes;
+      }
+      else
+      {
+        jalview.bin.Cache.log.warn(
+                "Negative start column index detected, resetting to default index: "
+                        + startRes);
+        // seqsel.startRes = startRes;
+      }
+  
       endRes = seqsel.endRes;
       cs = new ResidueShader((ResidueShader) seqsel.cs);
       if (seqsel.description != null)
diff --git a/test/jalview/gui/ValidColumnSelectionTest.java b/test/jalview/gui/ValidColumnSelectionTest.java
new file mode 100644 (file)
index 0000000..81d35f2
--- /dev/null
@@ -0,0 +1,21 @@
+package jalview.gui;
+
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class ValidColumnSelectionTest
+{
+  @BeforeClass(alwaysRun = true)
+  public void setUpJvOptionPane()
+  {
+    JvOptionPane.setInteractiveMode(false);
+    JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+  }
+
+  @Test(groups = "Functional")
+  public void testColumnSelection()
+  {
+
+  }
+
+}