From a474ac9fbd7de4a6e77b3c445ea0205d3854af0f Mon Sep 17 00:00:00 2001 From: jprocter Date: Fri, 11 Jun 2010 07:59:41 +0000 Subject: [PATCH] patched for JAL-531 - only display full symbol distribution stats on tooltip/annotation label when the sequenceLogo is displayed. --- src/jalview/appletgui/AlignFrame.java | 3 +- src/jalview/appletgui/AlignViewport.java | 2 +- src/jalview/datamodel/SequenceGroup.java | 13 ++++--- src/jalview/gui/AlignFrame.java | 3 +- src/jalview/gui/AlignViewport.java | 59 ++++++++++++++++-------------- src/jalview/gui/AlignmentPanel.java | 2 +- src/jalview/gui/AnnotationLabels.java | 8 ++-- src/jalview/gui/Jalview2XML.java | 2 +- 8 files changed, 48 insertions(+), 44 deletions(-) diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index b8ed2f1..0aefe9b 100755 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -1683,8 +1683,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, for (int g = 0; g < gps.length; g++) { // gps[g].setShowunconserved(viewport.getShowUnconserved()); - gps[g].setIncludeAllConsSymbols(viewport - .isIncludeAllConsensusSymbols()); + gps[g].setshowSequenceLogo(viewport.isShowSequenceLogo()); viewport.alignment.addGroup(gps[g]); Color col = new Color((int) (Math.random() * 255), (int) (Math .random() * 255), (int) (Math.random() * 255)); diff --git a/src/jalview/appletgui/AlignViewport.java b/src/jalview/appletgui/AlignViewport.java index 85c8ab5..ff3fe55 100755 --- a/src/jalview/appletgui/AlignViewport.java +++ b/src/jalview/appletgui/AlignViewport.java @@ -559,7 +559,7 @@ public class AlignViewport hconsensus = new Hashtable[aWidth]; AAFrequency.calculate(alignment.getSequencesArray(), 0, alignment - .getWidth(), hconsensus, includeAllConsensusSymbols); + .getWidth(), hconsensus, true); // always calculate the full profile AAFrequency.completeConsensus(consensus, hconsensus, 0, aWidth, ignoreGapsInConsensusCalculation, includeAllConsensusSymbols); diff --git a/src/jalview/datamodel/SequenceGroup.java b/src/jalview/datamodel/SequenceGroup.java index cc71e4a..451250e 100755 --- a/src/jalview/datamodel/SequenceGroup.java +++ b/src/jalview/datamodel/SequenceGroup.java @@ -1079,17 +1079,18 @@ public class SequenceGroup } /** - * @param includeAllConsSymbols - * the includeAllConsSymbols to set + * @param showSequenceLogo + * indicates if a sequence logo is shown for consensus annotation */ - public void setIncludeAllConsSymbols(boolean includeAllConsSymbols) + public void setshowSequenceLogo(boolean showSequenceLogo) { - if (this.showSequenceLogo != includeAllConsSymbols && consensus != null) + // TODO: decouple calculation from settings update + if (this.showSequenceLogo != showSequenceLogo && consensus != null) { - this.showSequenceLogo = includeAllConsSymbols; + this.showSequenceLogo = showSequenceLogo; recalcConservation(); } - this.showSequenceLogo = includeAllConsSymbols; + this.showSequenceLogo = showSequenceLogo; } /** diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 0e607c7..de64ca3 100755 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -4641,8 +4641,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, for (int g = 0; g < gps.length; g++) { gps[g].setShowNonconserved(viewport.getShowUnconserved()); - gps[g].setIncludeAllConsSymbols(viewport - .isIncludeAllConsensusSymbols()); + gps[g].setshowSequenceLogo(viewport.isShowSequenceLogo()); viewport.alignment.addGroup(gps[g]); Color col = new Color((int) (Math.random() * 255), (int) (Math .random() * 255), (int) (Math.random() * 255)); diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index a44afa3..80b3134 100755 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -478,11 +478,6 @@ public class AlignViewport implements SelectionSource private boolean shownpfeats; /** - * consensus annotation includes all percentage for all symbols in column - */ - private boolean includeAllConsensusSymbols = true; - - /** * trigger update of conservation annotation */ public void updateConservation(final AlignmentPanel ap) @@ -558,10 +553,8 @@ public class AlignViewport implements SelectionSource hconsensus = new Hashtable[aWidth]; AAFrequency.calculate(alignment.getSequencesArray(), 0, alignment - .getWidth(), hconsensus, includeAllConsensusSymbols); - AAFrequency.completeConsensus(consensus, hconsensus, 0, aWidth, - ignoreGapsInConsensusCalculation, - includeAllConsensusSymbols); + .getWidth(), hconsensus, true); + updateAnnotation(true); if (globalColourScheme != null) { @@ -584,6 +577,26 @@ public class AlignViewport implements SelectionSource ap.paintAlignment(true); } } + + /** + * update the consensus annotation from the sequence profile data using + * current visualization settings. + */ + public void updateAnnotation() + { + updateAnnotation(false); + } + + protected void updateAnnotation(boolean immediate) + { + if (immediate + || (!updatingConsensus && consensus != null && hconsensus != null)) + { + AAFrequency.completeConsensus(consensus, hconsensus, 0, + hconsensus.length, ignoreGapsInConsensusCalculation, + showSequenceLogo); + } + } } /** @@ -2207,6 +2220,16 @@ public class AlignViewport implements SelectionSource */ public void setShowSequenceLogo(boolean showSequenceLogo) { + if (showSequenceLogo != this.showSequenceLogo) + { + // TODO: decouple settings setting from calculation when refactoring + // annotation update method from alignframe to viewport + this.showSequenceLogo = showSequenceLogo; + if (consensusThread != null) + { + consensusThread.updateAnnotation(); + } + } this.showSequenceLogo = showSequenceLogo; } @@ -2254,24 +2277,6 @@ public class AlignViewport implements SelectionSource } /** - * @return the includeAllConsensusSymbols - */ - public boolean isIncludeAllConsensusSymbols() - { - return includeAllConsensusSymbols; - } - - /** - * @param includeAllConsensusSymbols - * the includeAllConsensusSymbols to set - */ - public void setIncludeAllConsensusSymbols( - boolean includeAllConsensusSymbols) - { - this.includeAllConsensusSymbols = includeAllConsensusSymbols; - } - - /** * * @return flag to indicate if the consensus histogram should be rendered by * default diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index 72290a7..9ea1d1f 100755 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -1367,7 +1367,7 @@ public class AlignmentPanel extends GAlignmentPanel implements if (applyGlobalSettings || !oldrfs.containsKey(sg)) { // set defaults for this group's conservation/consensus - sg.setIncludeAllConsSymbols(showprf); + sg.setshowSequenceLogo(showprf); sg.setShowConsensusHistogram(showConsHist); } if (conv) diff --git a/src/jalview/gui/AnnotationLabels.java b/src/jalview/gui/AnnotationLabels.java index 1033936..07a9b03 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -592,10 +592,10 @@ public class AnnotationLabels extends JPanel implements MouseListener, } }); pop.add(chist); - final JCheckBoxMenuItem cprof = new JCheckBoxMenuItem( + final JCheckBoxMenuItem cprofl = new JCheckBoxMenuItem( "Show Group Logo", aa[selectedRow].groupRef .isShowSequenceLogo()); - cprof.addActionListener(new ActionListener() + cprofl.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -605,12 +605,12 @@ public class AnnotationLabels extends JPanel implements MouseListener, // view // can be // updated. - aaa.groupRef.setIncludeAllConsSymbols(cprof.getState()); + aaa.groupRef.setshowSequenceLogo(cprofl.getState()); ap.repaint(); // ap.annotationPanel.paint(ap.annotationPanel.getGraphics()); } }); - pop.add(cprof); + pop.add(cprofl); } else { diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index 8de14b1..af8b2c0 100755 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -2245,7 +2245,7 @@ public class Jalview2XML ; if (groups[i].hasShowSequenceLogo()) { - sg.setIncludeAllConsSymbols(groups[i].isShowSequenceLogo()); + sg.setshowSequenceLogo(groups[i].isShowSequenceLogo()); } if (groups[i].hasIgnoreGapsinConsensus()) { -- 1.7.10.2