JAL-1492 JAL-1397 JAL-643 JAL-969 pull up global and group colourscheme logic and...
authorJim Procter <jprocter@dundee.ac.uk>
Thu, 1 May 2014 14:33:59 +0000 (15:33 +0100)
committerJim Procter <jprocter@dundee.ac.uk>
Thu, 1 May 2014 14:33:59 +0000 (15:33 +0100)
src/jalview/appletgui/AlignFrame.java
src/jalview/datamodel/SequenceGroup.java
src/jalview/gui/AlignFrame.java
src/jalview/viewmodel/AlignmentViewport.java

index fbb61de..40999c6 100644 (file)
@@ -2328,42 +2328,20 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     {
       if (viewport.getAbovePIDThreshold())
       {
-        threshold = SliderPanel.setPIDSliderSource(alignPanel, cs,
-                "Background");
-
-        cs.setThreshold(threshold, viewport.getIgnoreGapsConsensus());
-
-        viewport.setGlobalColourScheme(cs);
-      }
-      else
-      {
-        cs.setThreshold(0, viewport.getIgnoreGapsConsensus());
-      }
+        viewport.setThreshold(SliderPanel.setPIDSliderSource(alignPanel, cs,
+                "Background"));
+      } 
 
       if (viewport.getConservationSelected())
       {
-
-        Alignment al = (Alignment) viewport.getAlignment();
-        Conservation c = new Conservation("All",
-                ResidueProperties.propHash, 3, al.getSequences(), 0,
-                al.getWidth() - 1);
-
-        c.calculate();
-        c.verdict(false, viewport.getConsPercGaps());
-
-        cs.setConservation(c);
-
-        cs.setConservationInc(SliderPanel.setConservationSlider(alignPanel,
+        cs.setConservationApplied(true);
+        viewport.setIncrement(SliderPanel.setConservationSlider(alignPanel,
                 cs, "Background"));
-
       }
       else
       {
-        cs.setConservation(null);
+        cs.setConservationApplied(false);
       }
-
-      cs.setConsensus(viewport.getSequenceConsensusHash());
-
     }
     viewport.setGlobalColourScheme(cs);
 
index 5d0841e..521bdbe 100755 (executable)
@@ -470,12 +470,28 @@ public class SequenceGroup implements AnnotatedCollectionI
   }
 
   /**
-   * Max Gaps Threshold for performing a conservation calculation TODO: make
-   * this a configurable property - or global to an alignment view
+   * Max Gaps Threshold (percent) for performing a conservation calculation 
    */
   private int consPercGaps = 25;
 
   /**
+   * @return Max Gaps Threshold for performing a conservation calculation
+   */
+  public int getConsPercGaps()
+  {
+    return consPercGaps;
+  }
+
+  /**
+   * set Max Gaps Threshold (percent) for performing a conservation calculation
+   * @param consPercGaps 
+   */
+  public void setConsPercGaps(int consPercGaps)
+  {
+    this.consPercGaps = consPercGaps;
+  }
+
+  /**
    * calculate residue conservation for group - but only if necessary.
    */
   public void recalcConservation()
index 353a139..d475c91 100644 (file)
@@ -3235,10 +3235,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       {
         threshold = SliderPanel.setPIDSliderSource(alignPanel, cs,
                 "Background");
-
         cs.setThreshold(threshold, viewport.getIgnoreGapsConsensus());
-
-        viewport.setGlobalColourScheme(cs);
       }
       else
       {
index 7e383a9..44ecf76 100644 (file)
@@ -212,6 +212,24 @@ public abstract class AlignmentViewport implements AlignViewportI
     // calculation till later or to do all calculations in thread.
     // via changecolour
     globalColourScheme = cs;
+    boolean recalc=false;
+    if (cs!=null)
+    {
+      cs.setConservationApplied(recalc = getConservationSelected());
+      if (getAbovePIDThreshold() || cs instanceof PIDColourScheme || cs instanceof Blosum62ColourScheme)
+      {
+        recalc = true;
+        cs.setThreshold(threshold, ignoreGapsInConsensusCalculation);
+      } else {
+        cs.setThreshold(0, ignoreGapsInConsensusCalculation);
+      }
+      if (recalc)
+      {
+        cs.setConsensus(hconsensus);
+        cs.setConservation(hconservation);
+      }
+      cs.alignmentChanged(alignment, hiddenRepSequences);
+    }
     if (getColourAppliesToAllGroups())
     {
       for (SequenceGroup sg : getAlignment().getGroups())
@@ -221,29 +239,13 @@ public abstract class AlignmentViewport implements AlignViewportI
           sg.cs = null;
           continue;
         }
-        if (cs instanceof ClustalxColourScheme)
-        {
-          sg.cs = new ClustalxColourScheme(sg, getHiddenRepSequences());
-        }
-        else
-        {
-          try
-          {
-            sg.cs = cs.getClass().newInstance();
-          } catch (Exception ex)
-          {
-            ex.printStackTrace();
-            sg.cs = cs;
-          }
-        }
-
+        sg.cs = cs.applyTo(sg, getHiddenRepSequences());
+        sg.setConsPercGaps(ConsPercGaps);
         if (getAbovePIDThreshold() || cs instanceof PIDColourScheme
                 || cs instanceof Blosum62ColourScheme)
         {
           sg.cs.setThreshold(threshold, getIgnoreGapsConsensus());
-          sg.cs.setConsensus(AAFrequency.calculate(
-                  sg.getSequences(getHiddenRepSequences()), 0,
-                  sg.getWidth()));
+          recalc=true;
         }
         else
         {
@@ -252,20 +254,19 @@ public abstract class AlignmentViewport implements AlignViewportI
 
         if (getConservationSelected())
         {
-          Conservation c = new Conservation("Group",
-                  ResidueProperties.propHash, 3,
-                  sg.getSequences(getHiddenRepSequences()), 0,
-                  getAlignment().getWidth() - 1);
-          c.calculate();
-          c.verdict(false, getConsPercGaps());
-          sg.cs.setConservation(c);
+          sg.cs.setConservationApplied(true);
+          recalc=true;
         }
         else
         {
           sg.cs.setConservation(null);
-          sg.cs.setThreshold(0, getIgnoreGapsConsensus());
+          // sg.cs.setThreshold(0, getIgnoreGapsConsensus());
+        }
+        if (recalc) {
+          sg.recalcConservation();
+        } else {
+          sg.cs.alignmentChanged(sg, hiddenRepSequences);
         }
-
       }
     }
 
@@ -1306,7 +1307,7 @@ public abstract class AlignmentViewport implements AlignViewportI
     ColourSchemeI cs = globalColourScheme;
     if (cs != null)
     {
-      cs.alignmentChanged(alignment, null);
+      cs.alignmentChanged(alignment, hiddenRepSequences);
 
       cs.setConsensus(hconsensus);
       if (cs.conservationApplied())