X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fviewmodel%2FAlignmentViewport.java;h=2651b794df0fec707ce7ebc428a87a3c65105d96;hb=6dda78dd65a8f6f25356d9fe95078afbba4eadcd;hp=a66855ed1396eb5fd33b9dae79370e322d47a69d;hpb=69c6df4548ec433efbd547f60b1d5b89459085b7;p=jalview.git diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index a66855e..2651b79 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -22,6 +22,7 @@ package jalview.viewmodel; import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; import jalview.analysis.Conservation; +import jalview.analysis.TreeModel; import jalview.api.AlignCalcManagerI; import jalview.api.AlignViewportI; import jalview.api.AlignmentViewPanel; @@ -33,10 +34,11 @@ import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.AlignmentView; import jalview.datamodel.Annotation; -import jalview.datamodel.CigarArray; import jalview.datamodel.ColumnSelection; import jalview.datamodel.HiddenColumns; import jalview.datamodel.HiddenSequences; +import jalview.datamodel.ProfileI; +import jalview.datamodel.Profiles; import jalview.datamodel.ProfilesI; import jalview.datamodel.SearchResultsI; import jalview.datamodel.Sequence; @@ -57,6 +59,7 @@ import jalview.viewmodel.styles.ViewStyle; import jalview.workers.AlignCalcManager; import jalview.workers.ComplementConsensusThread; import jalview.workers.ConsensusThread; +import jalview.workers.InformationThread; import jalview.workers.StrucConsensusThread; import java.awt.Color; @@ -96,6 +99,7 @@ public abstract class AlignmentViewport protected Deque redoList = new ArrayDeque<>(); + /** * alignment displayed in the viewport. Please use get/setter */ @@ -604,10 +608,16 @@ public abstract class AlignmentViewport public boolean autoCalculateConsensus = true; + public boolean autoCalculateInformation = true; + protected boolean autoCalculateStrucConsensus = true; protected boolean ignoreGapsInConsensusCalculation = false; + protected boolean ignoreBelowBackGroundFrequencyCalculation = false; + + protected boolean infoLetterHeight = false; + protected ResidueShaderI residueShading = new ResidueShader(); @Override @@ -699,12 +709,21 @@ public abstract class AlignmentViewport protected AlignmentAnnotation[] groupConservation; + protected List groupInformation = new ArrayList<>(); + + protected List information = new ArrayList<>(); + /** * results of alignment consensus analysis for visible portion of view */ protected ProfilesI hconsensus = null; /** + * results of information annotation analysis for the visible portion of view + */ + protected List hinformation = new ArrayList<>(); + + /** * results of cDNA complement consensus visible portion of view */ protected Hashtable[] hcomplementConsensus = null; @@ -754,6 +773,34 @@ public abstract class AlignmentViewport } @Override + public void setSequenceInformationHashes(List info) + { + hinformation = info; + } + + @Override + public void setSequenceInformationHash(ProfilesI info, int index) + { + if (hinformation.size() < index + 1) + { + return; + } + hinformation.set(index, info); + } + + @Override + public List getSequenceInformationHashes() + { + return hinformation; + } + + @Override + public ProfilesI getSequenceInformationHash(int index) + { + return hinformation.get(index); + } + + @Override public Hashtable[] getComplementConsensusHash() { return hcomplementConsensus; @@ -791,6 +838,18 @@ public abstract class AlignmentViewport } @Override + public List getInformationAnnotations() + { + return information; + } + + @Override + public AlignmentAnnotation getInformationAnnotation(int index) + { + return information.get(index); + } + + @Override public AlignmentAnnotation getAlignmentGapAnnotation() { return gapcounts; @@ -882,6 +941,20 @@ public abstract class AlignmentViewport } } + /** + * trigger update of information annotation + */ + @Override + public void updateInformation(final AlignmentViewPanel ap) + { + if (calculator + .getRegisteredWorkersOfClass(InformationThread.class) == null) + { + calculator.registerWorker(new InformationThread(this, ap)); + } + + } + // --------START Structure Conservation public void updateStrucConsensus(final AlignmentViewPanel ap) { @@ -948,13 +1021,15 @@ public abstract class AlignmentViewport groupConsensus = null; groupConservation = null; hconsensus = null; + hconservation = null; hcomplementConsensus = null; gapcounts = null; - // colour scheme may hold reference to consensus - residueShading = null; - // TODO remove listeners from changeSupport? + calculator = null; + residueShading = null; // may hold a reference to Consensus changeSupport = null; ranges = null; + currentTree = null; + selectionGroup = null; setAlignment(null); } @@ -998,6 +1073,21 @@ public abstract class AlignmentViewport protected boolean showConsensusHistogram = true; /** + * should hmm profile be rendered by default + */ + protected boolean showHMMSequenceLogo = false; + + /** + * should hmm profile be rendered normalised to row height + */ + protected boolean normaliseHMMSequenceLogo = false; + + /** + * should information histograms be rendered by default + */ + protected boolean showInformationHistogram = true; + + /** * @return the showConsensusProfile */ @Override @@ -1007,6 +1097,15 @@ public abstract class AlignmentViewport } /** + * @return the showInformationProfile + */ + @Override + public boolean isShowHMMSequenceLogo() + { + return showHMMSequenceLogo; + } + + /** * @param showSequenceLogo * the new value */ @@ -1024,6 +1123,16 @@ public abstract class AlignmentViewport this.showSequenceLogo = showSequenceLogo; } + public void setShowHMMSequenceLogo(boolean showHMMSequenceLogo) + { + if (showHMMSequenceLogo != this.showHMMSequenceLogo) + { + this.showHMMSequenceLogo = showHMMSequenceLogo; + calculator.updateAnnotationFor(InformationThread.class); + } + this.showHMMSequenceLogo = showHMMSequenceLogo; + } + /** * @param showConsensusHistogram * the showConsensusHistogram to set @@ -1034,6 +1143,15 @@ public abstract class AlignmentViewport } /** + * @param showInformationHistogram + * the showInformationHistogram to set + */ + public void setShowInformationHistogram(boolean showInformationHistogram) + { + this.showInformationHistogram = showInformationHistogram; + } + + /** * @return the showGroupConservation */ public boolean isShowGroupConservation() @@ -1079,6 +1197,17 @@ public abstract class AlignmentViewport } /** + * + * @return flag to indicate if the information content histogram should be + * rendered by default + */ + @Override + public boolean isShowInformationHistogram() + { + return this.showInformationHistogram; + } + + /** * when set, updateAlignment will always ensure sequences are of equal length */ private boolean padGaps = false; @@ -1237,6 +1366,26 @@ public abstract class AlignmentViewport } + public void setIgnoreBelowBackground(boolean b, AlignmentViewPanel ap) + { + ignoreBelowBackGroundFrequencyCalculation = b; + if (ap != null) + { + updateInformation(ap); + } + + } + + public void setInfoLetterHeight(boolean b, AlignmentViewPanel ap) + { + infoLetterHeight = b; + if (ap != null) + { + updateInformation(ap); + } + + } + private long sgrouphash = -1, colselhash = -1; /** @@ -1291,6 +1440,18 @@ public abstract class AlignmentViewport return ignoreGapsInConsensusCalculation; } + @Override + public boolean isIgnoreBelowBackground() + { + return ignoreBelowBackGroundFrequencyCalculation; + } + + @Override + public boolean isInfoLetterHeight() + { + return infoLetterHeight; + } + // property change stuff // JBPNote Prolly only need this in the applet version. private PropertyChangeSupport changeSupport = new PropertyChangeSupport( @@ -1336,7 +1497,10 @@ public abstract class AlignmentViewport public void removePropertyChangeListener( java.beans.PropertyChangeListener listener) { - changeSupport.removePropertyChangeListener(listener); + if (changeSupport != null) + { + changeSupport.removePropertyChangeListener(listener); + } } /** @@ -1675,13 +1839,6 @@ public abstract class AlignmentViewport } @Override - public CigarArray getViewAsCigars(boolean selectedRegionOnly) - { - return new CigarArray(alignment, alignment.getHiddenColumns(), - (selectedRegionOnly ? selectionGroup : null)); - } - - @Override public jalview.datamodel.AlignmentView getAlignmentView( boolean selectedOnly) { @@ -1862,6 +2019,16 @@ public abstract class AlignmentViewport { updateStrucConsensus(ap); } + initInformation(); + updateInformation(ap); + + List hmmSequences; + hmmSequences = alignment.getHMMConsensusSequences(); + + for (SequenceI seq : hmmSequences) + { + seq.updateHMMMapping(); + } // Reset endRes of groups if beyond alignment width int alWidth = alignment.getWidth(); @@ -1937,6 +2104,7 @@ public abstract class AlignmentViewport MessageManager.getString("label.consensus_descr"), new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH); initConsensus(consensus); + initGapCounts(); initComplementConsensus(); @@ -1994,6 +2162,33 @@ public abstract class AlignmentViewport } } + @Override + public void initInformation() + { + for (SequenceI seq : alignment.getHMMConsensusSequences()) + { + if (!seq.hasHMMAnnotation()) + { + AlignmentAnnotation info = new AlignmentAnnotation(seq.getName(), + MessageManager.getString("label.information_description"), + new Annotation[1], 0f, 6.52f, + AlignmentAnnotation.BAR_GRAPH); + info.hasText = true; + info.autoCalculated = true; + info.hasText = true; + info.autoCalculated = false; + info.sequenceRef = seq; + info.setCalcId("HMM"); + this.information.add(info); + hinformation.add(new Profiles(new ProfileI[1])); + alignment.addAnnotation(info); + seq.updateHMMMapping(); + seq.setHasInfo(true); + seq.addAlignmentAnnotation(info); + } + } + } + // these should be extracted from the view model - style and settings for // derived annotation private void initGapCounts() @@ -2143,6 +2338,9 @@ public abstract class AlignmentViewport boolean showprf = isShowSequenceLogo(); boolean showConsHist = isShowConsensusHistogram(); boolean normLogo = isNormaliseSequenceLogo(); + boolean showHMMPrf = isShowHMMSequenceLogo(); + boolean showInfoHist = isShowInformationHistogram(); + boolean normHMMLogo = isNormaliseHMMSequenceLogo(); /** * TODO reorder the annotation rows according to group/sequence ordering on @@ -2180,6 +2378,9 @@ public abstract class AlignmentViewport sg.setshowSequenceLogo(showprf); sg.setShowConsensusHistogram(showConsHist); sg.setNormaliseSequenceLogo(normLogo); + sg.setshowHMMSequenceLogo(showHMMPrf); + sg.setShowInformationHistogram(showInfoHist); + sg.setNormaliseHMMSequenceLogo(normHMMLogo); } if (conv) { @@ -2879,6 +3080,8 @@ public abstract class AlignmentViewport */ private SearchResultsI searchResults = null; + protected TreeModel currentTree = null; + @Override public boolean hasSearchResults() { @@ -2937,4 +3140,29 @@ public abstract class AlignmentViewport + ((ignoreGapsInConsensusCalculation) ? " without gaps" : "")); return sq; } + + public boolean hasReferenceAnnotation() + { + AlignmentAnnotation[] annots = this.alignment.getAlignmentAnnotation(); + for (AlignmentAnnotation annot : annots) + { + if ("RF".equals(annot.label) || annot.label.contains("Reference")) + { + return true; + } + } + return false; + } + + @Override + public void setCurrentTree(TreeModel tree) + { + currentTree = tree; + } + + @Override + public TreeModel getCurrentTree() + { + return currentTree; + } }