JAL-2283 set 'by conservation' correctly when changing colour schem
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 24 Oct 2016 09:18:53 +0000 (10:18 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 24 Oct 2016 09:18:53 +0000 (10:18 +0100)
src/jalview/viewmodel/AlignmentViewport.java
test/jalview/gui/AlignViewportTest.java

index 3a92e4b..c1c88c1 100644 (file)
@@ -612,7 +612,7 @@ public abstract class AlignmentViewport implements AlignViewportI,
     boolean recalc = false;
     if (cs != null)
     {
-      cs.setConservationApplied(recalc = getConservationSelected());
+      recalc = getConservationSelected();
       if (getAbovePIDThreshold() || cs instanceof PIDColourScheme
               || cs instanceof Blosum62ColourScheme)
       {
@@ -629,6 +629,7 @@ public abstract class AlignmentViewport implements AlignViewportI,
         cs.setConsensus(hconsensus);
         cs.setConservation(hconservation);
       }
+      cs.setConservationApplied(getConservationSelected());
       cs.alignmentChanged(alignment, hiddenRepSequences);
     }
     if (getColourAppliesToAllGroups())
index 341a814..d7b26b0 100644 (file)
@@ -39,6 +39,8 @@ import jalview.datamodel.Sequence;
 import jalview.datamodel.SequenceI;
 import jalview.io.FileLoader;
 import jalview.io.FormatAdapter;
+import jalview.schemes.ColourSchemeI;
+import jalview.schemes.PIDColourScheme;
 import jalview.structure.StructureSelectionManager;
 import jalview.util.MapList;
 
@@ -329,4 +331,22 @@ public class AlignViewportTest
     assertNotNull("Quality in column 1 is null", annotations[0]);
     assertTrue("No quality value in column 1", annotations[0].value > 10f);
   }
+
+  @Test(groups = { "Functional" })
+  public void testSetGlobalColourScheme()
+  {
+    /*
+     * test for JAL-2283 don't inadvertently turn on colour by conservation
+     */
+    Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
+            Boolean.TRUE.toString());
+    Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
+            Boolean.FALSE.toString());
+    Cache.applicationProperties.setProperty("DEFAULT_COLOUR_PROT", "NONE");
+    AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
+            "examples/uniref50.fa", FormatAdapter.FILE);
+    ColourSchemeI cs = new PIDColourScheme();
+    af.getViewport().setGlobalColourScheme(cs);
+    assertFalse(cs.conservationApplied());
+  }
 }