X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignViewport.java;h=fd1fa7d992089a066fec858fff415cce7c7f5747;hb=10211ab17c9941d56c0aa703d49b59ca8c04b5af;hp=19ec9e0065a1b3524eca4889afa9b3602beff12b;hpb=40f08a931412edd1bc0e776033792fe3d4c0a5fa;p=jalview.git diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 19ec9e0..fd1fa7d 100755 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) - * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1) + * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -130,8 +130,10 @@ public class AlignViewport implements SelectionSource boolean cursorMode = false; - // The following vector holds the features which are - // currently visible, in the correct order or rendering + /** + * Keys are the feature types which are + * currently visible. Note: Values are not used! + */ Hashtable featuresDisplayed = null; /** DOCUMENT ME!! */ @@ -142,7 +144,9 @@ public class AlignViewport implements SelectionSource AlignmentAnnotation conservation; AlignmentAnnotation quality; - + AlignmentAnnotation[] groupConsensus; + AlignmentAnnotation[] groupConservation; + boolean autoCalculateConsensus = true; /** DOCUMENT ME!! */ @@ -230,9 +234,11 @@ public class AlignViewport implements SelectionSource if (hiddenColumns != null) { this.colSel = hiddenColumns; - if (hiddenColumns.getHiddenColumns() != null) + if (hiddenColumns.getHiddenColumns() != null && hiddenColumns.getHiddenColumns().size()>0) { hasHiddenColumns = true; + } else { + hasHiddenColumns = false; } } init(); @@ -265,9 +271,11 @@ public class AlignViewport implements SelectionSource if (hiddenColumns != null) { this.colSel = hiddenColumns; - if (hiddenColumns.getHiddenColumns() != null) + if (hiddenColumns.getHiddenColumns() != null && hiddenColumns.getHiddenColumns().size()>0) { hasHiddenColumns = true; + } else { + hasHiddenColumns = false; } } init(); @@ -343,7 +351,15 @@ public class AlignViewport implements SelectionSource alignment.addAnnotation(quality); } + showGroupConservation = Cache.getDefault("SHOW_GROUP_CONSERVATION", false); + + { + + } } + showConsensusHistogram = Cache.getDefault("SHOW_CONSENSUS_HISTOGRAM", true); + showSequenceLogo = Cache.getDefault("SHOW_CONSENSUS_LOGO", false); + showGroupConsensus = Cache.getDefault("SHOW_GROUP_CONSENSUS", false); // TODO: add menu option action that nulls or creates consensus object depending on if the user wants to see the annotation or not in a specific alignment consensus = new AlignmentAnnotation("Consensus", "PID", new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH); @@ -395,146 +411,6 @@ public class AlignViewport implements SelectionSource return showSequenceFeatures; } - class ConservationThread extends Thread - { - AlignmentPanel ap; - - public ConservationThread(AlignmentPanel ap) - { - this.ap = ap; - } - - public void run() - { - try - { - updatingConservation = true; - - while (UPDATING_CONSERVATION) - { - try - { - if (ap != null) - { - ap.paintAlignment(false); - } - Thread.sleep(200); - } catch (Exception ex) - { - ex.printStackTrace(); - } - } - - UPDATING_CONSERVATION = true; - - int alWidth = alignment.getWidth(); - if (alWidth < 0) - { - return; - } - - Conservation cons = new jalview.analysis.Conservation("All", - jalview.schemes.ResidueProperties.propHash, 3, alignment - .getSequences(), 0, alWidth - 1); - - cons.calculate(); - cons.verdict(false, ConsPercGaps); - - if (quality != null) - { - cons.findQuality(); - } - - char[] sequence = cons.getConsSequence().getSequence(); - float minR; - float minG; - float minB; - float maxR; - float maxG; - float maxB; - minR = 0.3f; - minG = 0.0f; - minB = 0f; - maxR = 1.0f - minR; - maxG = 0.9f - minG; - maxB = 0f - minB; // scalable range for colouring both Conservation and - // Quality - - float min = 0f; - float max = 11f; - float qmin = 0f; - float qmax = 0f; - - char c; - - conservation.annotations = new Annotation[alWidth]; - - if (quality != null) - { - quality.graphMax = cons.qualityRange[1].floatValue(); - quality.annotations = new Annotation[alWidth]; - qmin = cons.qualityRange[0].floatValue(); - qmax = cons.qualityRange[1].floatValue(); - } - - for (int i = 0; i < alWidth; i++) - { - float value = 0; - - c = sequence[i]; - - if (Character.isDigit(c)) - { - value = (int) (c - '0'); - } - else if (c == '*') - { - value = 11; - } - else if (c == '+') - { - value = 10; - } - - float vprop = value - min; - vprop /= max; - conservation.annotations[i] = new Annotation(String.valueOf(c), - String.valueOf(value), ' ', value, new Color(minR - + (maxR * vprop), minG + (maxG * vprop), minB - + (maxB * vprop))); - - // Quality calc - if (quality != null) - { - value = ((Double) cons.quality.get(i)).floatValue(); - vprop = value - qmin; - vprop /= qmax; - quality.annotations[i] = new Annotation(" ", String - .valueOf(value), ' ', value, new Color(minR - + (maxR * vprop), minG + (maxG * vprop), minB - + (maxB * vprop))); - } - } - } catch (OutOfMemoryError error) - { - new OOMWarning("calculating conservation", error); - - conservation = null; - quality = null; - - } - - UPDATING_CONSERVATION = false; - updatingConservation = false; - - if (ap != null) - { - ap.paintAlignment(true); - } - - } - } - ConservationThread conservationThread; ConsensusThread consensusThread; @@ -560,6 +436,11 @@ 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) @@ -570,7 +451,7 @@ public class AlignViewport implements SelectionSource return; } - conservationThread = new ConservationThread(ap); + conservationThread = new ConservationThread(this, ap); conservationThread.start(); } @@ -634,38 +515,9 @@ public class AlignViewport implements SelectionSource hconsensus = new Hashtable[aWidth]; AAFrequency.calculate(alignment.getSequencesArray(), 0, alignment - .getWidth(), hconsensus); - - for (int i = 0; i < aWidth; i++) - { - float value = 0; - if (ignoreGapsInConsensusCalculation) - { - value = ((Float) hconsensus[i].get(AAFrequency.PID_NOGAPS)) - .floatValue(); - } - else - { - value = ((Float) hconsensus[i].get(AAFrequency.PID_GAPS)) - .floatValue(); - } - - String maxRes = hconsensus[i].get(AAFrequency.MAXRESIDUE) - .toString(); - String mouseOver = hconsensus[i].get(AAFrequency.MAXRESIDUE) - + " "; - - if (maxRes.length() > 1) - { - mouseOver = "[" + maxRes + "] "; - maxRes = "+"; - } - - mouseOver += ((int) value + "%"); - consensus.annotations[i] = new Annotation(maxRes, mouseOver, ' ', - value); - } - + .getWidth(), hconsensus, includeAllConsensusSymbols); + AAFrequency.completeConsensus(consensus,hconsensus,0,aWidth,ignoreGapsInConsensusCalculation, includeAllConsensusSymbols); + if (globalColourScheme != null) { globalColourScheme.setConsensus(hconsensus); @@ -2236,4 +2088,94 @@ public class AlignViewport implements SelectionSource public void setSortByTree(boolean sort) { sortByTree = sort; } + /** + * should conservation rows be shown for groups + */ + boolean showGroupConservation = false; + /** + * should consensus rows be shown for groups + */ + boolean showGroupConsensus = false; + /** + * should consensus profile be rendered by default + */ + public boolean showSequenceLogo = false; + /** + * should consensus histograms be rendered by default + */ + public boolean showConsensusHistogram = true; + /** + * @return the showConsensusProfile + */ + public boolean isShowSequenceLogo() + { + return showSequenceLogo; + } + /** + * @param showSequenceLogo the new value + */ + public void setShowSequenceLogo(boolean showSequenceLogo) + { + this.showSequenceLogo = showSequenceLogo; + } + /** + * @param showConsensusHistogram the showConsensusHistogram to set + */ + public void setShowConsensusHistogram(boolean showConsensusHistogram) + { + this.showConsensusHistogram = showConsensusHistogram; + } + + /** + * @return the showGroupConservation + */ + public boolean isShowGroupConservation() + { + return showGroupConservation; + } + /** + * @param showGroupConservation the showGroupConservation to set + */ + public void setShowGroupConservation(boolean showGroupConservation) + { + this.showGroupConservation = showGroupConservation; + } + /** + * @return the showGroupConsensus + */ + public boolean isShowGroupConsensus() + { + return showGroupConsensus; + } + /** + * @param showGroupConsensus the showGroupConsensus to set + */ + public void setShowGroupConsensus(boolean showGroupConsensus) + { + this.showGroupConsensus = showGroupConsensus; + } + /** + * @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 + */ + public boolean isShowConsensusHistogram() + { + return this.showConsensusHistogram; + } + }