IgnoreGapsConsensus
authoramwaterhouse <Andrew Waterhouse>
Mon, 15 Aug 2005 12:08:41 +0000 (12:08 +0000)
committeramwaterhouse <Andrew Waterhouse>
Mon, 15 Aug 2005 12:08:41 +0000 (12:08 +0000)
16 files changed:
src/jalview/appletgui/APopupMenu.java
src/jalview/appletgui/AlignFrame.java
src/jalview/appletgui/AlignViewport.java
src/jalview/appletgui/AnnotationLabels.java
src/jalview/appletgui/AnnotationPanel.java
src/jalview/appletgui/SliderPanel.java
src/jalview/appletgui/UserDefinedColours.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/AlignViewport.java
src/jalview/gui/AnnotationLabels.java
src/jalview/gui/AnnotationPanel.java
src/jalview/gui/Jalview2XML.java
src/jalview/gui/PopupMenu.java
src/jalview/gui/SliderPanel.java
src/jalview/gui/TreeCanvas.java
src/jalview/gui/UserDefinedColours.java

index 858770a..0cfa537 100755 (executable)
@@ -387,11 +387,11 @@ public class APopupMenu
           getGroup().getName());\r
       if (sg.cs instanceof ResidueColourScheme)\r
       {\r
-        ( (ResidueColourScheme) sg.cs).setThreshold(threshold);\r
+        ( (ResidueColourScheme) sg.cs).setThreshold(threshold, ap.av.getIgnoreGapsConsensus());\r
       }\r
       else if (sg.cs instanceof ScoreColourScheme)\r
       {\r
-        ( (ScoreColourScheme) sg.cs).setThreshold(threshold);\r
+        ( (ScoreColourScheme) sg.cs).setThreshold(threshold, ap.av.getIgnoreGapsConsensus());\r
       }\r
 \r
       SliderPanel.showPIDSlider();\r
@@ -400,7 +400,7 @@ public class APopupMenu
     else // remove PIDColouring\r
     {\r
       ResidueColourScheme rcs = (ResidueColourScheme) sg.cs;\r
-      rcs.setThreshold(0);\r
+      rcs.setThreshold(0, ap.av.getIgnoreGapsConsensus());\r
       sg.cs = rcs;\r
     }\r
 \r
index 0bdcb55..db1f9c9 100755 (executable)
@@ -808,14 +808,14 @@ public class AlignFrame
 \r
       if (cs instanceof ResidueColourScheme)\r
       {\r
-        ( (ResidueColourScheme) cs).setThreshold(threshold);\r
+        ( (ResidueColourScheme) cs).setThreshold(threshold, viewport.getIgnoreGapsConsensus());\r
       }\r
 \r
       viewport.setGlobalColourScheme(cs);\r
     }\r
     else if (cs instanceof ResidueColourScheme)\r
     {\r
-      ( (ResidueColourScheme) cs).setThreshold(0);\r
+      ( (ResidueColourScheme) cs).setThreshold(0, viewport.getIgnoreGapsConsensus());\r
     }\r
 \r
     if (viewport.getConservationSelected())\r
@@ -885,7 +885,7 @@ public class AlignFrame
         {\r
           if (sg.cs instanceof ResidueColourScheme)\r
           {\r
-            ( (ResidueColourScheme) sg.cs).setThreshold(threshold);\r
+            ( (ResidueColourScheme) sg.cs).setThreshold(threshold, viewport.getIgnoreGapsConsensus());\r
           }\r
 \r
           sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0, sg.getWidth()));\r
@@ -914,6 +914,8 @@ public class AlignFrame
       }\r
     }\r
 \r
+    updateCSConsensus();\r
+\r
     if (alignPanel.getOverviewPanel() != null)\r
     {\r
       alignPanel.getOverviewPanel().updateOverviewImage();\r
@@ -922,6 +924,12 @@ public class AlignFrame
     alignPanel.repaint();\r
   }\r
 \r
+  public void updateCSConsensus()\r
+  {\r
+    //Colour schemes must have their consensus updated\r
+\r
+  }\r
+\r
   protected void modifyPID_actionPerformed(ActionEvent e)\r
   {\r
     if (viewport.getAbovePIDThreshold())\r
index 51478f2..e7cae44 100755 (executable)
@@ -74,6 +74,9 @@ public class AlignViewport
   boolean scaleLeftWrapped = true;\r
   boolean scaleRightWrapped = true;\r
 \r
+\r
+  boolean ignoreGapsInConsensusCalculation = false;\r
+\r
   public AlignViewport(AlignmentI al, JalviewLite applet)\r
   {\r
     setAlignment(al);\r
@@ -264,18 +267,21 @@ public class AlignViewport
     for (int i = 0; i < alignment.getWidth(); i++)\r
     {\r
       hash = (Hashtable) vconsensus.elementAt(i);\r
-      float value = new Float(hash.get("maxCount").toString()).floatValue();\r
-      value /= new Float(hash.get("size").toString()).floatValue();\r
+      float value = 0;\r
+      if(ignoreGapsInConsensusCalculation)\r
+        value = ((Float)hash.get("pid_nogaps")).floatValue();\r
+      else\r
+        value = ((Float)hash.get("pid_gaps")).floatValue();\r
 \r
-      value *= 100;\r
-      String maxRes = hash.get("maxResidue") + " ";\r
+      String maxRes = hash.get("maxResidue").toString();\r
       String mouseOver = hash.get("maxResidue") + " ";\r
-      if (maxRes.length() > 2)\r
+      if (maxRes.length() > 1)\r
       {\r
         mouseOver = "[" + maxRes + "] ";\r
-        maxRes = "+ ";\r
+        maxRes = "+";\r
       }\r
 \r
+\r
       mouseOver += (int) value + "%";\r
       annotations[i] = new Annotation(maxRes, mouseOver, ' ', value);\r
 \r
@@ -643,4 +649,24 @@ public class AlignViewport
     scaleRightWrapped = b;\r
   }\r
 \r
+  public void setIgnoreGapsConsensus(boolean b)\r
+  {\r
+    ignoreGapsInConsensusCalculation = b;\r
+    updateConsensus();\r
+    if (globalColourScheme!=null && globalColourScheme instanceof ResidueColourScheme)\r
+    {\r
+      ( (ResidueColourScheme) globalColourScheme).setThreshold(\r
+          ( (ResidueColourScheme) globalColourScheme).getThreshold(),\r
+          ignoreGapsInConsensusCalculation);\r
+\r
+    }\r
+\r
+  }\r
+\r
+  public boolean getIgnoreGapsConsensus()\r
+  {\r
+    return ignoreGapsInConsensusCalculation;\r
+  }\r
+\r
+\r
 }\r
index 38013d1..1a83b09 100755 (executable)
@@ -121,7 +121,26 @@ public class AnnotationLabels
     item = new MenuItem(OUTPUT_TEXT);\r
     item.addActionListener(this);\r
     pop.add(item);\r
-    pop.show(this, evt.getX(), evt.getY());\r
+\r
+    if (aa[selectedRow].label.equals("Consensus"))\r
+    {\r
+      pop.addSeparator();\r
+      final CheckboxMenuItem cbmi = new CheckboxMenuItem(\r
+          "Ignore gaps in calculation",\r
+          ap.av.getIgnoreGapsConsensus());\r
+\r
+      cbmi.addItemListener(new ItemListener()\r
+      {\r
+        public void itemStateChanged(ItemEvent e)\r
+        {\r
+          ap.av.setIgnoreGapsConsensus(cbmi.getState());\r
+          ap.repaint();\r
+        }\r
+      });\r
+      pop.add(cbmi);\r
+    }\r
+\r
+     pop.show(this, evt.getX(), evt.getY());\r
 \r
   }\r
 \r
index ad4aeb8..8e9469a 100755 (executable)
@@ -336,7 +336,7 @@ public class AnnotationPanel
                             fm.charWidth(row.annotations[j].displayCharacter.\r
                                          charAt(0))) / 2;\r
           g.setColor(row.annotations[j].colour);\r
-          if (j == 0)\r
+          if (j == 0 || row.isGraph)\r
           {\r
             if (row.annotations[0].secondaryStructure == 'H'\r
                 || row.annotations[0].secondaryStructure == 'E')\r
index caabbf9..d2eeff3 100755 (executable)
@@ -224,7 +224,7 @@ public class SliderPanel
       }\r
       else\r
       {\r
-        ( (ResidueColourScheme) toChange).setThreshold(i);\r
+        ( (ResidueColourScheme) toChange).setThreshold(i, ap.av.getIgnoreGapsConsensus());\r
       }\r
 \r
       groupIndex--;\r
index 80d91ef..86e1f5d 100755 (executable)
@@ -214,7 +214,7 @@ public class UserDefinedColours
     }\r
 \r
     UserColourScheme ucs = new UserColourScheme(newColours);\r
-    ucs.setThreshold(0);\r
+    ucs.setThreshold(0, ap.av.getIgnoreGapsConsensus());\r
 \r
     if (seqGroup != null)\r
     {\r
@@ -228,27 +228,6 @@ public class UserDefinedColours
     ap.repaint();\r
   }\r
 \r
-  public static UserColourScheme loadDefaultColours(String file)\r
-  {\r
-    UserColourScheme ucs = null;\r
-    try\r
-    {\r
-      BufferedReader in = new BufferedReader(new FileReader(file));\r
-      Color[] newColours = new Color[24];\r
-      for (int i = 0; i < 24; i++)\r
-      {\r
-        newColours[i] = new Color(Integer.parseInt(in.readLine()));\r
-      }\r
-\r
-      ucs = new UserColourScheme(newColours);\r
-      ucs.setThreshold(0);\r
-\r
-    }\r
-    catch (Exception ex)\r
-    {}\r
-\r
-    return ucs;\r
-  }\r
 \r
   protected void cancelButton_actionPerformed(ActionEvent e)\r
   {\r
index 727e1c6..a41fb36 100755 (executable)
@@ -1336,22 +1336,22 @@ public class AlignFrame extends GAlignFrame
 \r
             if (cs instanceof ResidueColourScheme)\r
             {\r
-                ((ResidueColourScheme) cs).setThreshold(threshold);\r
+                ((ResidueColourScheme) cs).setThreshold(threshold, viewport.getIgnoreGapsConsensus());\r
             }\r
             else if (cs instanceof ScoreColourScheme)\r
             {\r
-                ((ScoreColourScheme) cs).setThreshold(threshold);\r
+                ((ScoreColourScheme) cs).setThreshold(threshold, viewport.getIgnoreGapsConsensus());\r
             }\r
 \r
             viewport.setGlobalColourScheme(cs);\r
         }\r
         else if (cs instanceof ResidueColourScheme)\r
         {\r
-            ((ResidueColourScheme) cs).setThreshold(0);\r
+            ((ResidueColourScheme) cs).setThreshold(0, viewport.getIgnoreGapsConsensus());\r
         }\r
         else if (cs instanceof ScoreColourScheme)\r
         {\r
-            ((ScoreColourScheme) cs).setThreshold(0);\r
+            ((ScoreColourScheme) cs).setThreshold(0, viewport.getIgnoreGapsConsensus());\r
         }\r
 \r
         if (viewport.getConservationSelected())\r
@@ -1368,8 +1368,7 @@ public class AlignFrame extends GAlignFrame
 \r
             ccs = new ConservationColourScheme(c, cs);\r
 \r
-            // MUST NOTIFY THE COLOURSCHEME OF CONSENSUS!\r
-            ccs.setConsensus(viewport.vconsensus);\r
+\r
             viewport.setGlobalColourScheme(ccs);\r
 \r
             ccs.inc = SliderPanel.setConservationSlider(alignPanel, ccs,\r
@@ -1421,11 +1420,11 @@ public class AlignFrame extends GAlignFrame
                 {\r
                     if (sg.cs instanceof ResidueColourScheme)\r
                     {\r
-                        ((ResidueColourScheme) sg.cs).setThreshold(threshold);\r
+                        ((ResidueColourScheme) sg.cs).setThreshold(threshold, viewport.getIgnoreGapsConsensus());\r
                     }\r
                     else if (sg.cs instanceof ScoreColourScheme)\r
                     {\r
-                        ((ScoreColourScheme) sg.cs).setThreshold(threshold);\r
+                        ((ScoreColourScheme) sg.cs).setThreshold(threshold, viewport.getIgnoreGapsConsensus());\r
                     }\r
 \r
                     sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0,\r
index 05927b6..e98fb9f 100755 (executable)
@@ -85,6 +85,8 @@ public class AlignViewport
     // JBPNote Prolly only need this in the applet version.\r
     private java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(this);\r
 \r
+    boolean ignoreGapsInConsensusCalculation = false;\r
+\r
     /**\r
      * Creates a new AlignViewport object.\r
      *\r
@@ -147,6 +149,7 @@ public class AlignViewport
             if (globalColourScheme instanceof UserColourScheme)\r
             {\r
                 globalColourScheme = UserDefinedColours.loadDefaultColours();\r
+                ((UserColourScheme)globalColourScheme).setThreshold(0, getIgnoreGapsConsensus());\r
             }\r
 \r
             if (globalColourScheme != null)\r
@@ -304,18 +307,19 @@ public class AlignViewport
         {\r
             hash = (Hashtable) vconsensus.elementAt(i);\r
 \r
-            float value = Float.parseFloat(hash.get("maxCount").toString());\r
-            value /= Float.parseFloat(hash.get("size").toString());\r
-\r
-            value *= 100;\r
+            float value = 0;\r
+            if(ignoreGapsInConsensusCalculation)\r
+              value = ((Float)hash.get("pid_nogaps")).floatValue();\r
+            else\r
+              value = ((Float)hash.get("pid_gaps")).floatValue();\r
 \r
-            String maxRes = hash.get("maxResidue") + " ";\r
-            String mouseOver = hash.get("maxResidue") + " ";\r
+            String maxRes = hash.get("maxResidue").toString();\r
+            String mouseOver = hash.get("maxResidue")+" ";\r
 \r
-            if (maxRes.length() > 2)\r
+            if (maxRes.length() > 1)\r
             {\r
                 mouseOver = "[" + maxRes + "] ";\r
-                maxRes = "+ ";\r
+                maxRes = "+";\r
             }\r
 \r
             mouseOver += ((int) value + "%");\r
@@ -336,6 +340,9 @@ public class AlignViewport
         {\r
             consensus.annotations = annotations;\r
         }\r
+\r
+        if(globalColourScheme!=null)\r
+          globalColourScheme.setConsensus(vconsensus);\r
     }\r
 \r
     /**\r
@@ -1027,4 +1034,23 @@ public class AlignViewport
     {\r
         changeSupport.firePropertyChange(prop, oldvalue, newvalue);\r
     }\r
+\r
+    public void setIgnoreGapsConsensus(boolean b)\r
+    {\r
+      ignoreGapsInConsensusCalculation = b;\r
+      updateConsensus();\r
+      if(globalColourScheme!=null && globalColourScheme instanceof ResidueColourScheme)\r
+      {\r
+        ((ResidueColourScheme) globalColourScheme).setThreshold(\r
+            ((ResidueColourScheme) globalColourScheme).getThreshold(), ignoreGapsInConsensusCalculation);\r
+\r
+\r
+      }\r
+\r
+    }\r
+\r
+    public boolean getIgnoreGapsConsensus()\r
+    {\r
+     return ignoreGapsInConsensusCalculation;\r
+    }\r
 }\r
index 2a972ea..099d1d1 100755 (executable)
@@ -171,6 +171,7 @@ public class AnnotationLabels extends JPanel implements MouseListener,
             cap.setText(aa[selectedRow].toString());\r
         }\r
 \r
+\r
         ap.annotationPanel.adjustPanelHeight();\r
 \r
         Dimension d = ap.annotationScroller.getPreferredSize();\r
@@ -319,6 +320,24 @@ public class AnnotationLabels extends JPanel implements MouseListener,
         item = new JMenuItem(OUTPUT_TEXT);\r
         item.addActionListener(this);\r
         pop.add(item);\r
+\r
+        if (aa[selectedRow].label.equals("Consensus"))\r
+        {\r
+          pop.addSeparator();\r
+          final JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem(\r
+              "Ignore gaps in calculation",\r
+              ap.av.getIgnoreGapsConsensus());\r
+          cbmi.addActionListener(new ActionListener()\r
+              {public void actionPerformed(ActionEvent e)\r
+               {\r
+                 ap.av.setIgnoreGapsConsensus(cbmi.getState());\r
+                 ap.repaint();\r
+               }\r
+              });\r
+          pop.add(cbmi);\r
+\r
+        }\r
+\r
         pop.show(this, evt.getX(), evt.getY());\r
     }\r
 \r
index 9ae103e..b8570a9 100755 (executable)
@@ -688,12 +688,13 @@ public class AnnotationPanel extends JPanel implements MouseListener,
                 if (validRes &&\r
                         (row.annotations[j].displayCharacter.length() > 0))\r
                 {\r
+\r
                     int charOffset = (av.charWidth -\r
                         fm.charWidth(row.annotations[j].displayCharacter.charAt(\r
                                 0))) / 2;\r
                     g.setColor(row.annotations[j].colour);\r
 \r
-                    if (j == 0)\r
+                    if (j == 0 || row.isGraph)\r
                     {\r
                         g.drawString(row.annotations[j].displayCharacter, x+charOffset,\r
                             y + iconOffset + 2);\r
index 70608c4..5d94c3c 100755 (executable)
@@ -523,6 +523,7 @@ public class Jalview2XML
         }\r
         catch (Exception ex)\r
         {\r
+          ex.printStackTrace();\r
             System.err.println("Exception whilst loading jalview XML file : " +\r
                 ex + "\n");\r
              JOptionPane.showInternalMessageDialog(Desktop.desktop,\r
@@ -631,11 +632,11 @@ public class Jalview2XML
 \r
                     if (cs instanceof ResidueColourScheme)\r
                     {\r
-                        ((ResidueColourScheme) cs).setThreshold(groups[i].getPidThreshold());\r
+                        ((ResidueColourScheme) cs).setThreshold(groups[i].getPidThreshold(), true);\r
                     }\r
                     else if (cs instanceof ScoreColourScheme)\r
                     {\r
-                        ((ScoreColourScheme) cs).setThreshold(groups[i].getPidThreshold());\r
+                        ((ScoreColourScheme) cs).setThreshold(groups[i].getPidThreshold(), true);\r
                     }\r
                 }\r
 \r
@@ -729,25 +730,28 @@ public class Jalview2XML
                 cs = ColourSchemeProperty.getColour(al, view.getBgColour());\r
             }\r
 \r
-            if (cs instanceof ConservationColourScheme)\r
-            {\r
-                ((ConservationColourScheme) cs).inc = view.getConsThreshold();\r
-            }\r
-\r
             if (cs instanceof ResidueColourScheme)\r
             {\r
-                ((ResidueColourScheme) cs).setThreshold(view.getPidThreshold());\r
+                ((ResidueColourScheme) cs).setThreshold(view.getPidThreshold(), true);\r
             }\r
             else if (cs instanceof ScoreColourScheme)\r
             {\r
-                ((ScoreColourScheme) cs).setThreshold(view.getPidThreshold());\r
+                ((ScoreColourScheme) cs).setThreshold(view.getPidThreshold(), true);\r
             }\r
+\r
+            if(cs!=null)\r
+              cs.setConsensus(af.viewport.vconsensus);\r
         }\r
 \r
+        af.setColourSelected(view.getBgColour());\r
         af.viewport.setGlobalColourScheme(cs);\r
-\r
         af.viewport.setColourAppliesToAllGroups(false);\r
         af.changeColour(af.viewport.getGlobalColourScheme());\r
+        if (view.getConservationSelected())\r
+        {\r
+          ( (ConservationColourScheme) af.viewport.getGlobalColourScheme()).inc = view.getConsThreshold();\r
+        }\r
+\r
         af.viewport.setColourAppliesToAllGroups(true);\r
 \r
         if (view.getShowSequenceFeatures())\r
index 0b53111..26fc93c 100755 (executable)
@@ -595,11 +595,11 @@ public class PopupMenu extends JPopupMenu
 \r
             if (sg.cs instanceof ResidueColourScheme)\r
             {\r
-                ((ResidueColourScheme) sg.cs).setThreshold(threshold);\r
+                ((ResidueColourScheme) sg.cs).setThreshold(threshold, ap.av.getIgnoreGapsConsensus());\r
             }\r
             else if (sg.cs instanceof ScoreColourScheme)\r
             {\r
-                ((ScoreColourScheme) sg.cs).setThreshold(threshold);\r
+                ((ScoreColourScheme) sg.cs).setThreshold(threshold, ap.av.getIgnoreGapsConsensus());\r
             }\r
 \r
             SliderPanel.showPIDSlider();\r
@@ -607,7 +607,7 @@ public class PopupMenu extends JPopupMenu
         else // remove PIDColouring\r
         {\r
             ResidueColourScheme rcs = (ResidueColourScheme) sg.cs;\r
-            rcs.setThreshold(0);\r
+            rcs.setThreshold(0, ap.av.getIgnoreGapsConsensus());\r
             sg.cs = rcs;\r
         }\r
 \r
index c18cc05..a9020c3 100755 (executable)
@@ -294,7 +294,7 @@ public class SliderPanel extends GSliderPanel
             }\r
             else\r
             {\r
-                ((ResidueColourScheme) toChange).setThreshold(i);\r
+                ((ResidueColourScheme) toChange).setThreshold(i, ap.av.getIgnoreGapsConsensus());\r
             }\r
 \r
             groupIndex--;\r
index d8ed3ee..d05aee1 100755 (executable)
@@ -715,7 +715,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable,
 \r
                     if (sg.cs != null)\r
                     {\r
-                        ((ResidueColourScheme) sg.cs).setThreshold(25);\r
+                        ((ResidueColourScheme) sg.cs).setThreshold(25, av.getIgnoreGapsConsensus());\r
                     }\r
 \r
                     if (av.getGlobalColourScheme() instanceof ConservationColourScheme)\r
index 651f40c..4ad129b 100755 (executable)
@@ -267,7 +267,7 @@ public class UserDefinedColours extends GUserDefinedColours
         }\r
 \r
         UserColourScheme ucs = new UserColourScheme(newColours);\r
-        ucs.setThreshold(0);\r
+        ucs.setThreshold(0, ap.av.getIgnoreGapsConsensus());\r
 \r
         if (seqGroup != null)\r
         {\r
@@ -346,7 +346,6 @@ public class UserDefinedColours extends GUserDefinedColours
         if (cols != null)\r
         {\r
             ucs = new UserColourScheme(cols);\r
-            ucs.setThreshold(0);\r
         }\r
 \r
         return ucs;\r