From 7717b24f1e894ad268121890c479848c53df64b0 Mon Sep 17 00:00:00 2001 From: TZVanaalten Date: Fri, 14 Jul 2017 17:06:08 +0100 Subject: [PATCH] add partial button fix to annotation and statistics output --- src/jalview/analysis/AAFrequency.java | 5 +- src/jalview/api/AlignViewportI.java | 17 ++ src/jalview/appletgui/AlignViewport.java | 7 + src/jalview/datamodel/HiddenMarkovModel.java | 4 +- src/jalview/datamodel/SequenceGroup.java | 82 +++++++++- src/jalview/gui/AlignFrame.java | 175 ++++++++++++++++++++ src/jalview/gui/AlignViewport.java | 18 ++- src/jalview/gui/AnnotationLabels.java | 221 ++++++++++++++++++++------ src/jalview/jbgui/GAlignFrame.java | 26 ++- src/jalview/renderer/AnnotationRenderer.java | 6 +- src/jalview/schemes/HMMERColourScheme.java | 13 +- src/jalview/viewmodel/AlignmentViewport.java | 62 +++++++- 12 files changed, 576 insertions(+), 60 deletions(-) diff --git a/src/jalview/analysis/AAFrequency.java b/src/jalview/analysis/AAFrequency.java index 3cc57bf..57e00fe 100755 --- a/src/jalview/analysis/AAFrequency.java +++ b/src/jalview/analysis/AAFrequency.java @@ -107,6 +107,7 @@ public class AAFrequency } } + /** * Calculate the consensus symbol(s) for each column in the given range. * @@ -762,7 +763,7 @@ public class AAFrequency value = hmm.getMatchEmissionProbability(column, symbol); double freq; - if (alph == AMINO && removeBelowBackground) + if (AMINO.equals(alph) && removeBelowBackground) { freq = ResidueProperties.aminoBackgroundFrequencies.get(symbol); if (value < freq) @@ -770,7 +771,7 @@ public class AAFrequency value = 0d; } } - else if (alph == DNA && removeBelowBackground) + else if (DNA.equals(alph) && removeBelowBackground) { freq = ResidueProperties.nucleotideBackgroundFrequencies .get(symbol); diff --git a/src/jalview/api/AlignViewportI.java b/src/jalview/api/AlignViewportI.java index 9e6d1c0..6ebde3c 100644 --- a/src/jalview/api/AlignViewportI.java +++ b/src/jalview/api/AlignViewportI.java @@ -86,6 +86,12 @@ public interface AlignViewportI extends ViewStyleI boolean isNormaliseSequenceLogo(); + boolean isShowInformationHistogram(); + + boolean isShowHMMSequenceLogo(); + + boolean isNormaliseHMMSequenceLogo(); + ColourSchemeI getGlobalColourScheme(); /** @@ -113,6 +119,8 @@ public interface AlignViewportI extends ViewStyleI boolean isIgnoreGapsConsensus(); + boolean isIgnoreBelowBackground(); + boolean isCalculationInProgress(AlignmentAnnotation alignmentAnnotation); AlignmentAnnotation getAlignmentQualityAnnot(); @@ -127,6 +135,13 @@ public interface AlignViewportI extends ViewStyleI AlignmentAnnotation getAlignmentConsensusAnnotation(); /** + * get the container for alignment information content annotation + * + * @return + */ + AlignmentAnnotation getAlignmentInformationAnnotation(); + + /** * get the container for alignment gap annotation * * @return @@ -486,6 +501,7 @@ public interface AlignViewportI extends ViewStyleI * * @return */ + @Override boolean isProteinFontAsCdna(); /** @@ -493,5 +509,6 @@ public interface AlignViewportI extends ViewStyleI * * @return */ + @Override void setProteinFontAsCdna(boolean b); } diff --git a/src/jalview/appletgui/AlignViewport.java b/src/jalview/appletgui/AlignViewport.java index 73cd9e9..6c7b39a 100644 --- a/src/jalview/appletgui/AlignViewport.java +++ b/src/jalview/appletgui/AlignViewport.java @@ -469,4 +469,11 @@ public class AlignViewport extends AlignmentViewport implements // TODO implement for applet } + @Override + public boolean isNormaliseHMMSequenceLogo() + { + // TODO Auto-generated method stub + return normaliseHMMSequenceLogo; + } + } diff --git a/src/jalview/datamodel/HiddenMarkovModel.java b/src/jalview/datamodel/HiddenMarkovModel.java index bcfa1c9..4514a41 100644 --- a/src/jalview/datamodel/HiddenMarkovModel.java +++ b/src/jalview/datamodel/HiddenMarkovModel.java @@ -16,6 +16,8 @@ import java.util.Scanner; */ public class HiddenMarkovModel { + + // Stores file properties. Do not directly access this field as it contains // only string value - use the getter methods. For example, to find the length // of theHMM, use getModelLength()to return an int value @@ -378,7 +380,7 @@ public class HiddenMarkovModel public Integer getNodeAlignmentColumn(int nodeIndex) { Integer value = nodes.get(nodeIndex).getAlignmentColumn(); - return value; + return value - 1; } public char getConsensusResidue(int nodeIndex) diff --git a/src/jalview/datamodel/SequenceGroup.java b/src/jalview/datamodel/SequenceGroup.java index 688c7ae..39ee2cb 100755 --- a/src/jalview/datamodel/SequenceGroup.java +++ b/src/jalview/datamodel/SequenceGroup.java @@ -128,10 +128,18 @@ public class SequenceGroup implements AnnotatedCollectionI AlignmentAnnotation conservation = null; + AlignmentAnnotation informationContent = null; + private boolean showConsensusHistogram; private AnnotatedCollectionI context; + private boolean showHMMSequenceLogo; + + private boolean normaliseHMMSequenceLogo; + + private boolean showInformationHistogram; + /** * Creates a new SequenceGroup object. */ @@ -203,6 +211,9 @@ public class SequenceGroup implements AnnotatedCollectionI showSequenceLogo = seqsel.showSequenceLogo; normaliseSequenceLogo = seqsel.normaliseSequenceLogo; showConsensusHistogram = seqsel.showConsensusHistogram; + showHMMSequenceLogo = seqsel.showHMMSequenceLogo; + normaliseHMMSequenceLogo = seqsel.normaliseHMMSequenceLogo; + showInformationHistogram = seqsel.showInformationHistogram; idColour = seqsel.idColour; outlineColour = seqsel.outlineColour; seqrep = seqsel.seqrep; @@ -553,7 +564,8 @@ public class SequenceGroup implements AnnotatedCollectionI */ public boolean recalcConservation(boolean defer) { - if (cs == null && consensus == null && conservation == null) + if (cs == null && consensus == null && conservation == null + && informationContent == null) { return false; } @@ -564,6 +576,12 @@ public class SequenceGroup implements AnnotatedCollectionI { ProfilesI cnsns = AAFrequency.calculate(sequences, startRes, endRes + 1, showSequenceLogo); + if (informationContent != null) + { + // _updateInformationRow(cnsns, sequences.size()); TODO don't know what + // to do here + upd = true; + } if (consensus != null) { _updateConsensusRow(cnsns, sequences.size()); @@ -659,6 +677,30 @@ public class SequenceGroup implements AnnotatedCollectionI // ignoreGapsInConsensusCalculation); } + private void _updateInformationRow(ProfilesI cnsns, long nseq) + { + if (consensus == null) + { + getConsensus(); + } + consensus.label = "Consensus for " + getName(); + consensus.description = "Percent Identity"; + consensusData = cnsns; + // preserve width if already set + int aWidth = (consensus.annotations != null) + ? (endRes < consensus.annotations.length + ? consensus.annotations.length : endRes + 1) + : endRes + 1; + consensus.annotations = null; + consensus.annotations = new Annotation[aWidth]; // should be alignment width + + AAFrequency.completeConsensus(consensus, cnsns, startRes, endRes + 1, + ignoreGapsInConsensus, showSequenceLogo, nseq); // TODO: setting + // container + // for + // ignoreGapsInConsensusCalculation); + } + /** * @param s * sequence to either add or remove from group @@ -1477,5 +1519,43 @@ public class SequenceGroup implements AnnotatedCollectionI return (startRes <= apos && endRes >= apos) && sequences.contains(seq); } + public boolean isShowInformationHistogram() + { + return showInformationHistogram; + } + + public void setShowInformationHistogram(boolean state) + { + if (showInformationHistogram != state && informationContent != null) + { + this.showInformationHistogram = state; + // recalcConservation(); TODO don't know what to do here next + } + this.showInformationHistogram = state; + + } + + public boolean isShowHMMSequenceLogo() + { + // TODO Auto-generated method stub + return showHMMSequenceLogo; + } + + public void setshowHMMSequenceLogo(boolean state) + { + showHMMSequenceLogo = state; + + } + + public boolean isNormaliseHMMSequenceLogo() + { + // TODO Auto-generated method stub + return normaliseHMMSequenceLogo; + } + + public void setNormaliseHMMSequenceLogo(boolean state) + { + normaliseSequenceLogo = state; + } } diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 334d380..cce4e67 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -87,7 +87,9 @@ import jalview.jbgui.GAlignFrame; import jalview.schemes.ColourSchemeI; import jalview.schemes.ColourSchemes; import jalview.schemes.ResidueColourScheme; +import jalview.schemes.ResidueProperties; import jalview.schemes.TCoffeeColourScheme; +import jalview.util.Comparison; import jalview.util.MessageManager; import jalview.viewmodel.AlignmentViewport; import jalview.viewmodel.ViewportRanges; @@ -123,7 +125,9 @@ import java.awt.event.MouseEvent; import java.awt.print.PageFormat; import java.awt.print.PrinterJob; import java.beans.PropertyChangeEvent; +import java.io.BufferedReader; import java.io.File; +import java.io.FileReader; import java.io.FileWriter; import java.io.PrintWriter; import java.net.URL; @@ -131,8 +135,11 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Deque; import java.util.Enumeration; +import java.util.HashMap; import java.util.Hashtable; import java.util.List; +import java.util.Map; +import java.util.Scanner; import java.util.Vector; import javax.swing.JCheckBoxMenuItem; @@ -154,6 +161,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, IProgressIndicator, AlignViewControllerGuiI, ColourChangeListener { + Map distribution = new HashMap<>(); // temporary + public static final int DEFAULT_WIDTH = 700; public static final int DEFAULT_HEIGHT = 500; @@ -181,6 +190,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, */ String fileName = null; + /** * Creates a new AlignFrame object with specific width and height. * @@ -920,6 +930,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, showConsensusHistogram.setSelected(av.isShowConsensusHistogram()); showSequenceLogo.setSelected(av.isShowSequenceLogo()); normaliseSequenceLogo.setSelected(av.isNormaliseSequenceLogo()); + showInformationHistogram.setSelected(av.isShowInformationHistogram()); + showHMMSequenceLogo.setSelected(av.isShowHMMSequenceLogo()); + normaliseHMMSequenceLogo.setSelected(av.isNormaliseHMMSequenceLogo()); ColourMenuHelper.setColourSelected(colourMenu, av.getGlobalColourScheme()); @@ -4666,6 +4679,144 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, getViewport().getAlignment().addAnnotation(annotation); annotation.setHMM(hmm); isAnnotation = true; + + BufferedReader input = new BufferedReader(new FileReader( + "H:/Desktop/Distributions/BadAlignment-8.csv")); + String line = input.readLine(); + + while (!("".equals(line)) && line != null) + { + Scanner scanner = new Scanner(line); + if (scanner.hasNext()) + { + scanner.useDelimiter(","); + String value = scanner.next(); + + distribution.put(value, scanner.nextFloat()); + line = input.readLine(); + } + } + + + AlignmentI alignment = getViewport().getAlignment(); + Integer alpha = 0; + final int AMINO = 0; + final int DNA = 1; + if ("amino".equals(hmm.getAlphabetType())) + { + alpha = AMINO; + } + else if ("DNA".equals(hmm.getAlphabetType())) + { + alpha = DNA; + } + + + int size = 0; + + for (int l = 1; l < hmm.getLength() + 1; l++) + { + for (int n = 0; n < alignment.getHeight(); n++) + { + + char character = alignment.getSequenceAt(n) + .getCharAt(hmm.getNodeAlignmentColumn(l)); + character = Character.toUpperCase(character); + + boolean containedN; + boolean containedA; + + containedN = ResidueProperties.nucleotideBackgroundFrequencies + .containsKey(character); + containedA = ResidueProperties.aminoBackgroundFrequencies + .containsKey(character); + + if (!Comparison.isGap(character) + && ((alpha == DNA && containedN) + || (alpha == AMINO && containedA))) + { + size++; + } + + } + } + + for (int l = 1; l < hmm.getLength() + 1; l++) + { + for (int n = 0; n < alignment.getHeight(); n++) + { + Double prob; + char character; + character = alignment.getSequenceAt(n) + .getCharAt(hmm.getNodeAlignmentColumn(l)); + character = Character.toUpperCase(character); + boolean containedN; + boolean containedA; + + containedN = ResidueProperties.nucleotideBackgroundFrequencies + .containsKey(character); + containedA = ResidueProperties.aminoBackgroundFrequencies + .containsKey(character); + + if (!Comparison.isGap(character) + && ((alpha == DNA && containedN) + || (alpha == AMINO && containedA))) + { + prob = hmm.getMatchEmissionProbability( + hmm.getNodeAlignmentColumn(l), character); + if (prob == 0d) + { + System.out.println("?"); + } + + double freq = 0; + if (alpha == AMINO) + { + freq = ResidueProperties.aminoBackgroundFrequencies + .get(character); + } + if (alpha == DNA) + { + freq = ResidueProperties.nucleotideBackgroundFrequencies + .get(character); + } + Double doubleValue = Math.log(prob / freq); + + String value = String.format("%.1f", doubleValue); + if ("-0.0".equals(value)) + { + value = "0.0"; + } + if (distribution.containsKey(value)) + { + float prev = distribution.get(value); + prev = prev + (10000f / size); + distribution.put(value, prev); + } + else + { + distribution.put(value, 10000f / size); + } + + + } + + } + } + + PrintWriter writer = new PrintWriter( + new File( + "H:/Desktop/Distributions/BadAlignment-8.csv")); + for (Map.Entry entry : distribution + .entrySet()) + { + writer.println(entry.getKey() + "," + entry.getValue()); + + } + + writer.close(); + + } else if (FileFormat.Jnet.equals(format)) { @@ -5285,6 +5436,30 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } @Override + protected void showInformationHistogram_actionPerformed(ActionEvent e) + { + viewport.setShowInformationHistogram( + showInformationHistogram.getState()); + alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState()); + } + + @Override + protected void showHMMSequenceLogo_actionPerformed(ActionEvent e) + { + viewport.setShowHMMSequenceLogo(showHMMSequenceLogo.getState()); + alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState()); + } + + @Override + protected void normaliseHMMSequenceLogo_actionPerformed(ActionEvent e) + { + showHMMSequenceLogo.setState(true); + viewport.setShowHMMSequenceLogo(true); + viewport.setNormaliseHMMSequenceLogo(normaliseSequenceLogo.getState()); + alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState()); + } + + @Override protected void applyAutoAnnotationSettings_actionPerformed(ActionEvent e) { alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState()); diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 86e1144..2005b91 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -652,10 +652,10 @@ public class AlignViewport extends AlignmentViewport implements */ public SequenceI[][] collateForPDB(PDBEntry[] pdbEntries) { - List seqvectors = new ArrayList(); + List seqvectors = new ArrayList<>(); for (PDBEntry pdb : pdbEntries) { - List choosenSeqs = new ArrayList(); + List choosenSeqs = new ArrayList<>(); for (SequenceI sq : alignment.getSequences()) { Vector pdbRefEntries = sq.getDatasetSequence() @@ -708,6 +708,11 @@ public class AlignViewport extends AlignmentViewport implements normaliseSequenceLogo = state; } + public void setNormaliseHMMSequenceLogo(boolean state) + { + normaliseHMMSequenceLogo = state; + } + /** * * @return true if alignment characters should be displayed @@ -718,7 +723,7 @@ public class AlignViewport extends AlignmentViewport implements return validCharWidth; } - private Hashtable calcIdParams = new Hashtable(); + private Hashtable calcIdParams = new Hashtable<>(); public AutoCalcSetting getCalcIdSettingsFor(String calcId) { @@ -1149,4 +1154,11 @@ public class AlignViewport extends AlignmentViewport implements fr.setTransparency(featureSettings.getTransparency()); } + @Override + public boolean isNormaliseHMMSequenceLogo() + { + // TODO Auto-generated method stub + return normaliseHMMSequenceLogo; + } + } diff --git a/src/jalview/gui/AnnotationLabels.java b/src/jalview/gui/AnnotationLabels.java index ce87c72..445ee11 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -74,6 +74,7 @@ public class AnnotationLabels extends JPanel implements MouseListener, private static final Pattern LEFT_ANGLE_BRACKET_PATTERN = Pattern .compile("<"); + String TOGGLE_LABELSCALE = MessageManager .getString("label.scale_label_to_column"); @@ -435,25 +436,14 @@ public class AnnotationLabels extends JPanel implements MouseListener, pop.add(item); } } - else if (label.indexOf("Consensus") > -1 - || label.indexOf("Information Content") > -1) + else if (label.indexOf("Consensus") > -1) { - // identifier for type of histogram and/or logo to be shown - int type = 2; - if (label.indexOf("Consensus") > -1) - { - type = 0; - } - else if (label.indexOf("Information Content") > -1) - { - type = 1; - } + pop.addSeparator(); // av and sequencegroup need to implement same interface for final AlignmentAnnotation aaa = aa[selectedRow]; - if (type == 0) - { + final JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem( MessageManager.getString("label.ignore_gaps_consensus"), (aa[selectedRow].groupRef != null) ? aa[selectedRow].groupRef @@ -480,37 +470,6 @@ public class AnnotationLabels extends JPanel implements MouseListener, } }); pop.add(cbmi); - } - if (type == 1) - { - final JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem( - "Ignore Below Background Frequency", - (aa[selectedRow].groupRef != null) - ? aa[selectedRow].groupRef - .getIgnoreBelowBackground() - : ap.av.isIgnoreBelowBackground()); - - cbmi.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - if (aaa.groupRef != null) - { - // TODO: pass on reference to ap so the view can be updated. - aaa.groupRef.setIgnoreBelowBackground(cbmi.getState()); - ap.getAnnotationPanel() - .paint(ap.getAnnotationPanel().getGraphics()); - } - else - { - ap.av.setIgnoreBelowBackground(cbmi.getState(), ap); - } - ap.alignmentChanged(); - } - }); - pop.add(cbmi); - } // av and sequencegroup need to implement same interface for if (aaa.groupRef != null) { @@ -649,6 +608,178 @@ public class AnnotationLabels extends JPanel implements MouseListener, consclipbrd.addActionListener(this); pop.add(consclipbrd); } + else if (label.indexOf("Information Content") > -1) // TODO create labels + // in message resource + // for these + { + pop.addSeparator(); + final AlignmentAnnotation aaa = aa[selectedRow]; + + final JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem( + "Ignore Below Background Frequency", + (aa[selectedRow].groupRef != null) + ? aa[selectedRow].groupRef + .getIgnoreBelowBackground() + : ap.av.isIgnoreBelowBackground()); + + cbmi.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + if (aaa.groupRef != null) + { + // TODO: pass on reference to ap so the view can be updated. + aaa.groupRef.setIgnoreBelowBackground(cbmi.getState()); + ap.getAnnotationPanel() + .paint(ap.getAnnotationPanel().getGraphics()); + } + else + { + ap.av.setIgnoreBelowBackground(cbmi.getState(), ap); + } + ap.alignmentChanged(); + } + }); + pop.add(cbmi); + if (aaa.groupRef != null) + { + final JCheckBoxMenuItem chist = new JCheckBoxMenuItem( + MessageManager.getString("label.show_group_histogram"), + aa[selectedRow].groupRef.isShowInformationHistogram()); + chist.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + // TODO: pass on reference + // to ap + // so the + // view + // can be + // updated. + aaa.groupRef.setShowInformationHistogram(chist.getState()); + ap.repaint(); + // ap.annotationPanel.paint(ap.annotationPanel.getGraphics()); + } + }); + pop.add(chist); + final JCheckBoxMenuItem cprofl = new JCheckBoxMenuItem( + MessageManager.getString("label.show_group_logo"), + aa[selectedRow].groupRef.isShowHMMSequenceLogo()); + cprofl.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + // TODO: pass on reference + // to ap + // so the + // view + // can be + // updated. + aaa.groupRef.setshowHMMSequenceLogo(cprofl.getState()); + ap.repaint(); + // ap.annotationPanel.paint(ap.annotationPanel.getGraphics()); + } + }); + pop.add(cprofl); + final JCheckBoxMenuItem cproflnorm = new JCheckBoxMenuItem( + MessageManager.getString("label.normalise_group_logo"), + aa[selectedRow].groupRef.isNormaliseHMMSequenceLogo()); + cproflnorm.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + + // TODO: pass on reference + // to ap + // so the + // view + // can be + // updated. + aaa.groupRef + .setNormaliseHMMSequenceLogo(cproflnorm.getState()); + // automatically enable logo display if we're clicked + aaa.groupRef.setshowHMMSequenceLogo(true); + ap.repaint(); + // ap.annotationPanel.paint(ap.annotationPanel.getGraphics()); + } + }); + pop.add(cproflnorm); + } + else + { + final JCheckBoxMenuItem chist = new JCheckBoxMenuItem( + MessageManager.getString("label.show_histogram"), + av.isShowInformationHistogram()); + chist.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + // TODO: pass on reference + // to ap + // so the + // view + // can be + // updated. + av.setShowInformationHistogram(chist.getState()); + ap.alignFrame.setMenusForViewport(); + ap.repaint(); + // ap.annotationPanel.paint(ap.annotationPanel.getGraphics()); + } + }); + pop.add(chist); + final JCheckBoxMenuItem cprof = new JCheckBoxMenuItem( + MessageManager.getString("label.show_logo"), + av.isShowHMMSequenceLogo()); + cprof.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + // TODO: pass on reference + // to ap + // so the + // view + // can be + // updated. + av.setShowHMMSequenceLogo(cprof.getState()); + ap.alignFrame.setMenusForViewport(); + ap.repaint(); + // ap.annotationPanel.paint(ap.annotationPanel.getGraphics()); + } + }); + pop.add(cprof); + final JCheckBoxMenuItem cprofnorm = new JCheckBoxMenuItem( + MessageManager.getString("label.normalise_logo"), + av.isNormaliseHMMSequenceLogo()); + cprofnorm.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + // TODO: pass on reference + // to ap + // so the + // view + // can be + // updated. + av.setShowHMMSequenceLogo(true); + av.setNormaliseHMMSequenceLogo(cprofnorm.getState()); + ap.alignFrame.setMenusForViewport(); + ap.repaint(); + // ap.annotationPanel.paint(ap.annotationPanel.getGraphics()); + } + }); + pop.add(cprofnorm); + } + final JMenuItem consclipbrd = new JMenuItem(COPYCONS_SEQ); + consclipbrd.addActionListener(this); + pop.add(consclipbrd); + } } pop.show(this, evt.getX(), evt.getY()); } diff --git a/src/jalview/jbgui/GAlignFrame.java b/src/jalview/jbgui/GAlignFrame.java index 88cc0a8..085e9fc 100755 --- a/src/jalview/jbgui/GAlignFrame.java +++ b/src/jalview/jbgui/GAlignFrame.java @@ -193,13 +193,19 @@ public class GAlignFrame extends JInternalFrame protected JCheckBoxMenuItem normaliseSequenceLogo = new JCheckBoxMenuItem(); + protected JCheckBoxMenuItem showInformationHistogram = new JCheckBoxMenuItem(); + + protected JCheckBoxMenuItem showHMMSequenceLogo = new JCheckBoxMenuItem(); + + protected JCheckBoxMenuItem normaliseHMMSequenceLogo = new JCheckBoxMenuItem(); + protected JCheckBoxMenuItem applyAutoAnnotationSettings = new JCheckBoxMenuItem(); private SequenceAnnotationOrder annotationSortOrder; private boolean showAutoCalculatedAbove = false; - private Map accelerators = new HashMap(); + private Map accelerators = new HashMap<>(); private SplitContainerI splitFrame; @@ -2647,4 +2653,22 @@ public class GAlignFrame extends JInternalFrame protected void showComplement_actionPerformed(boolean complement) { } + + protected void showInformationHistogram_actionPerformed(ActionEvent e) + { + // TODO Auto-generated method stub + + } + + protected void showHMMSequenceLogo_actionPerformed(ActionEvent e) + { + // TODO Auto-generated method stub + + } + + protected void normaliseHMMSequenceLogo_actionPerformed(ActionEvent e) + { + // TODO Auto-generated method stub + + } } diff --git a/src/jalview/renderer/AnnotationRenderer.java b/src/jalview/renderer/AnnotationRenderer.java index 95bbf28..1f3d5a9 100644 --- a/src/jalview/renderer/AnnotationRenderer.java +++ b/src/jalview/renderer/AnnotationRenderer.java @@ -87,6 +87,8 @@ public class AnnotationRenderer private boolean av_ignoreGapsConsensus; + private boolean av_ignoreBelowBackground; + /** * attributes set from AwtRenderPanelI */ @@ -335,6 +337,7 @@ public class AnnotationRenderer complementConsensus = av.getComplementConsensusHash(); hStrucConsensus = av.getRnaStructureConsensusHash(); av_ignoreGapsConsensus = av.isIgnoreGapsConsensus(); + av_ignoreBelowBackground = av.isIgnoreBelowBackground(); } @@ -357,7 +360,8 @@ public class AnnotationRenderer if (aa.label.startsWith("Information")) { return AAFrequency.getHMMProfileFor(aa, column, - true); // TODO detect setting + av_ignoreBelowBackground); // TODO check if this follows standard + // pipeline } if (aa.autoCalculated && (aa.label.startsWith("Consensus") || aa.label diff --git a/src/jalview/schemes/HMMERColourScheme.java b/src/jalview/schemes/HMMERColourScheme.java index a7fc8b8..f545fe6 100644 --- a/src/jalview/schemes/HMMERColourScheme.java +++ b/src/jalview/schemes/HMMERColourScheme.java @@ -51,19 +51,22 @@ public class HMMERColourScheme extends ResidueColourScheme } Double prob; prob = hmm.getMatchEmissionProbability(position, symbol); + if (prob == 0) + { + return Color.red; + } double freq = ResidueProperties.aminoBackgroundFrequencies.get(symbol); - Double value = prob - freq; - + Double value = Math.log(prob / freq); Color colour = null; - if (value >= 0) + if (value > 0) { colour = ColorUtils.getGraduatedColour(value.floatValue(), 0, - Color.WHITE, 1f, Color.green); + Color.WHITE, 3f, Color.blue); } else if (value < 0) { - return Color.YELLOW; + return Color.ORANGE; } return colour; diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index dfd120b..61b0b00 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -699,7 +699,7 @@ public abstract class AlignmentViewport implements AlignViewportI, protected AlignmentAnnotation[] groupConservation; - protected AlignmentAnnotation hmmConsensus; + protected AlignmentAnnotation informationContent; /** * results of alignment consensus analysis for visible portion of view @@ -793,6 +793,12 @@ public abstract class AlignmentViewport implements AlignViewportI, } @Override + public AlignmentAnnotation getAlignmentInformationAnnotation() + { + return informationContent; + } + + @Override public AlignmentAnnotation getAlignmentGapAnnotation() { return gapcounts; @@ -996,6 +1002,21 @@ public abstract class AlignmentViewport implements AlignViewportI, 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 @@ -1005,6 +1026,15 @@ public abstract class AlignmentViewport implements AlignViewportI, } /** + * @return the showInformationProfile + */ + @Override + public boolean isShowHMMSequenceLogo() + { + return showHMMSequenceLogo; + } + + /** * @param showSequenceLogo * the new value */ @@ -1022,6 +1052,15 @@ public abstract class AlignmentViewport implements AlignViewportI, this.showSequenceLogo = showSequenceLogo; } + public void setShowHMMSequenceLogo(boolean showHMMSequenceLogo) + { + if (showHMMSequenceLogo != this.showHMMSequenceLogo) + { + this.showHMMSequenceLogo = showHMMSequenceLogo; + } + this.showHMMSequenceLogo = showHMMSequenceLogo; + } + /** * @param showConsensusHistogram * the showConsensusHistogram to set @@ -1032,6 +1071,15 @@ public abstract class AlignmentViewport implements AlignViewportI, } /** + * @param showInformationHistogram + * the showInformationHistogram to set + */ + public void setShowInformationHistogram(boolean showInformationHistogram) + { + this.showInformationHistogram = showInformationHistogram; + } + + /** * @return the showGroupConservation */ public boolean isShowGroupConservation() @@ -1077,6 +1125,17 @@ public abstract class AlignmentViewport implements AlignViewportI, } /** + * + * @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; @@ -1304,6 +1363,7 @@ public abstract class AlignmentViewport implements AlignViewportI, return ignoreGapsInConsensusCalculation; } + @Override public boolean isIgnoreBelowBackground() { return ignoreBelowBackGroundFrequencyCalculation; -- 1.7.10.2