X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fviewmodel%2FAlignmentViewport.java;h=2651b794df0fec707ce7ebc428a87a3c65105d96;hb=6dda78dd65a8f6f25356d9fe95078afbba4eadcd;hp=a0cbff48c46e79b5384dbcdc14264fcb5b37c965;hpb=ea2cf1fb34a7630388e87c058d994d2a4017f9e3;p=jalview.git diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index a0cbff4..2651b79 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -37,6 +37,8 @@ import jalview.datamodel.Annotation; 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) { @@ -1000,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 @@ -1009,6 +1097,15 @@ public abstract class AlignmentViewport } /** + * @return the showInformationProfile + */ + @Override + public boolean isShowHMMSequenceLogo() + { + return showHMMSequenceLogo; + } + + /** * @param showSequenceLogo * the new value */ @@ -1026,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 @@ -1036,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() @@ -1081,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; @@ -1239,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; /** @@ -1293,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( @@ -1860,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(); @@ -1935,6 +2104,7 @@ public abstract class AlignmentViewport MessageManager.getString("label.consensus_descr"), new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH); initConsensus(consensus); + initGapCounts(); initComplementConsensus(); @@ -1992,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() @@ -2141,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 @@ -2178,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) { @@ -2938,6 +3141,19 @@ public abstract class AlignmentViewport 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) {