showUnconserved and updated reference
authorjprocter <Jim Procter>
Fri, 6 Feb 2009 14:55:41 +0000 (14:55 +0000)
committerjprocter <Jim Procter>
Fri, 6 Feb 2009 14:55:41 +0000 (14:55 +0000)
src/jalview/appletgui/APopupMenu.java
src/jalview/appletgui/AlignFrame.java
src/jalview/appletgui/AlignViewport.java
src/jalview/appletgui/SequenceRenderer.java

index 9b21f60..2bacd70 100755 (executable)
@@ -79,6 +79,8 @@ public class APopupMenu extends java.awt.PopupMenu implements
 
   CheckboxMenuItem showColourText = new CheckboxMenuItem();
 
+  CheckboxMenuItem displayNonconserved = new CheckboxMenuItem();
+
   Menu editMenu = new Menu("Edit");
 
   MenuItem copy = new MenuItem("Copy (Jalview Only)");
@@ -150,6 +152,7 @@ public class APopupMenu extends java.awt.PopupMenu implements
       showText.setState(sg.getDisplayText());
       showColourText.setState(sg.getColourText());
       showBoxes.setState(sg.getDisplayBoxes());
+      displayNonconserved.setState(sg.getShowunconserved());
       if (!ap.av.alignment.getGroups().contains(sg))
       {
         groupMenu.remove(unGroupMenuItem);
@@ -352,6 +355,10 @@ public class APopupMenu extends java.awt.PopupMenu implements
     {
       showBoxes_itemStateChanged();
     }
+    else if (evt.getSource() == displayNonconserved)
+    {
+      this.showNonconserved_itemStateChanged();
+    }
   }
 
   public void actionPerformed(ActionEvent evt)
@@ -677,7 +684,9 @@ public class APopupMenu extends java.awt.PopupMenu implements
     showBoxes.setState(true);
     showBoxes.addItemListener(this);
     sequenceName.addActionListener(this);
-
+    displayNonconserved.setLabel("Show Nonconserved");
+    displayNonconserved.setState(false);
+    displayNonconserved.addItemListener(this);
     showText.setLabel("Text");
     showText.addItemListener(this);
     showColourText.setLabel("Colour Text");
@@ -766,6 +775,7 @@ public class APopupMenu extends java.awt.PopupMenu implements
     menu1.add(showBoxes);
     menu1.add(showText);
     menu1.add(showColourText);
+    menu1.add(displayNonconserved);
     toggleCase.addActionListener(this);
     pdb.addActionListener(this);
     hideSeqs.addActionListener(this);
@@ -966,6 +976,12 @@ public class APopupMenu extends java.awt.PopupMenu implements
     refresh();
   }
 
+  public void showNonconserved_itemStateChanged()
+  {
+    getGroup().setShowunconserved(this.displayNonconserved.getState());
+    refresh();
+  }
+
   public void showBoxes_itemStateChanged()
   {
     getGroup().setDisplayBoxes(showBoxes.getState());
index 3280815..d5aa0b0 100755 (executable)
@@ -68,6 +68,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     viewport.updateConsensus(alignPanel);
 
     annotationPanelMenuItem.setState(viewport.showAnnotation);
+    displayNonconservedMenuItem.setState(viewport.getShowunconserved());
 
     seqLimits.setState(viewport.showJVSuffix);
 
@@ -101,7 +102,6 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
         centreColumnLabelFlag.setState(true);
         centreColumnLabelFlag_stateChanged();
       }
-
       try
       {
         param = applet.getParameter("windowWidth");
@@ -477,7 +477,11 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
 
   public void itemStateChanged(ItemEvent evt)
   {
-    if (evt.getSource() == colourTextMenuItem)
+    if (evt.getSource() == displayNonconservedMenuItem)
+    {
+      displayNonconservedMenuItem_actionPerformed();
+    }
+    else if (evt.getSource() == colourTextMenuItem)
     {
       colourTextMenuItem_actionPerformed();
     }
@@ -1910,6 +1914,12 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     alignPanel.paintAlignment(true);
   }
 
+  protected void displayNonconservedMenuItem_actionPerformed()
+  {
+    viewport.setShowunconserved(displayNonconservedMenuItem.getState());
+    alignPanel.paintAlignment(true);
+  }
+
   protected void wrapMenuItem_actionPerformed()
   {
     viewport.setWrapAlignment(wrapMenuItem.getState());
@@ -2337,11 +2347,10 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
                         "For help, see the FAQ at www.jalview.org and/or join the jalview-discuss@jalview.org mailing list",
                         x, y += fh);
         g.drawString("If  you use Jalview, please cite:", x, y += fh + 8);
-        g
-                .drawString(
-                        "\"Clamp, M., Cuff, J., Searle, S. M. and Barton, G. J. (2004), The Jalview Java Alignment Editor\"",
-                        x, y += fh);
-        g.drawString("Bioinformatics,  2004 20;426-7.", x, y += fh);
+        g.drawString(
+                        "Waterhouse, A.M., Procter, J.B., Martin, D.M.A, Clamp, M. and Barton, G. J. (2009)",x,y+=fh);
+        g.drawString("Jalview Version 2 - a multiple sequence alignment editor and analysis workbench",x,y+=fh);
+        g.drawString("Bioinformatics doi: 10.1093/bioinformatics/btp033",x,y+=fh);
       }
     }
 
@@ -2503,6 +2512,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
 
   CheckboxMenuItem colourTextMenuItem = new CheckboxMenuItem();
 
+  CheckboxMenuItem displayNonconservedMenuItem = new CheckboxMenuItem();
+
   MenuItem alProperties = new MenuItem("Alignment Properties...");
 
   MenuItem overviewMenuItem = new MenuItem();
@@ -2677,6 +2688,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     annotationPanelMenuItem.addItemListener(this);
     colourTextMenuItem.setLabel("Colour Text");
     colourTextMenuItem.addItemListener(this);
+    displayNonconservedMenuItem.setLabel("Show non-conserved");
+    displayNonconservedMenuItem.addItemListener(this);
     alProperties.addActionListener(this);
     overviewMenuItem.setLabel("Overview Window");
     overviewMenuItem.addActionListener(this);
@@ -2883,6 +2896,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     formatMenu.add(viewBoxesMenuItem);
     formatMenu.add(viewTextMenuItem);
     formatMenu.add(colourTextMenuItem);
+    formatMenu.add(displayNonconservedMenuItem);
     formatMenu.add(renderGapsMenuItem);
     formatMenu.add(centreColumnLabelFlag);
     selectMenu.add(findMenuItem);
index 9512c5a..fd43a5d 100755 (executable)
@@ -184,6 +184,12 @@ public class AlignViewport
         showConsensus = Boolean.valueOf(param).booleanValue();
       }
 
+      param = applet.getParameter("showUnconserved");
+      if (param != null)
+      {
+        this.showUnconserved = Boolean.valueOf(param).booleanValue();
+      }
+
       param = applet.getParameter("upperCase");
       if (param != null)
       {
@@ -1502,4 +1508,24 @@ public class AlignViewport
   public boolean getFollowHighlight() {
     return followHighlight;
   }
+  /**
+   * show non-conserved residues only
+   */
+  public boolean showUnconserved=false;
+
+  /**
+   * @return the showUnconserved
+   */
+  public boolean getShowunconserved()
+  {
+    return showUnconserved;
+  }
+
+  /**
+   * @param showUnconserved the showUnconserved to set
+   */
+  public void setShowunconserved(boolean displayNonconserved)
+  {
+    this.showUnconserved = displayNonconserved;
+  }
 }
index c41c35f..531b4d0 100755 (executable)
@@ -96,7 +96,7 @@ public class SequenceRenderer
     }
 
   }
-
+  
   public Color findSequenceColour(SequenceI seq, int i)
   {
     allGroups = av.alignment.findAllGroups(seq);
@@ -220,6 +220,11 @@ public class SequenceRenderer
           getBoxColour(currentSequenceGroup.cs, seq, i);
           graphics.setColor(resBoxColour.darker());
         }
+        if (currentSequenceGroup.getShowunconserved())
+        {
+          // cheat - use this if we have a consensus for each group: s = getDisplayChar(currentSequenceGroup.getConsensus(), i, s, '.');
+          s = getDisplayChar(av.consensus, i, s, '.');
+        }
       }
       else
       {
@@ -240,6 +245,11 @@ public class SequenceRenderer
             graphics.setColor(resBoxColour);
           }
         }
+        if (av.getShowunconserved())
+        {
+          s = getDisplayChar(av.consensus, i, s, '.');                       
+        }
       }
 
       if (av.upperCasebold)
@@ -261,7 +271,7 @@ public class SequenceRenderer
         }
 
       }
-
+      
       charOffset = (av.charWidth - fm.charWidth(s)) / 2;
       graphics.drawString(String.valueOf(s), charOffset + av.charWidth
               * (i - start), y1);
@@ -269,6 +279,17 @@ public class SequenceRenderer
 
   }
 
+  
+  private char getDisplayChar(AlignmentAnnotation consensus, int position, char s, char c)
+  {
+    char conschar = consensus.annotations[position].displayCharacter.charAt(0);
+    if (conschar!='-' && s==conschar)
+    {
+      s= c;
+    }
+    return s;
+  }
+
   boolean inCurrentSequenceGroup(int res)
   {
     if (allGroups == null)