From c343764674a4046b5d459457289a2334e02cc07f Mon Sep 17 00:00:00 2001 From: Renia Correya Date: Wed, 12 Jun 2024 14:59:17 +0100 Subject: [PATCH] JAL-4392 Feature implementation of group consensus secondary structures --- resources/lang/Messages.properties | 1 + src/jalview/datamodel/SequenceGroup.java | 17 ++++++++++++----- src/jalview/gui/AlignFrame.java | 7 +++++++ src/jalview/jbgui/GAlignFrame.java | 26 ++++++++++++++++++++++++-- src/jalview/renderer/AnnotationRenderer.java | 18 ++++++++++++++++-- src/jalview/viewmodel/AlignmentViewport.java | 20 +++++++++++++++++++- 6 files changed, 79 insertions(+), 10 deletions(-) diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index 2b9b76f..f7bdec6 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -278,6 +278,7 @@ label.all_sequences_columns = All Sequences and Columns label.hide_selected_annotations = Hide selected annotations label.show_selected_annotations = Show selected annotations label.group_consensus = Group Consensus +label.group_ss_consensus = Group Secondary Structure Consensus label.group_conservation = Group Conservation label.show_consensus_histogram = Show Consensus Histogram label.show_consensus_logo = Show Consensus Logo diff --git a/src/jalview/datamodel/SequenceGroup.java b/src/jalview/datamodel/SequenceGroup.java index 5416ac4..75d4460 100755 --- a/src/jalview/datamodel/SequenceGroup.java +++ b/src/jalview/datamodel/SequenceGroup.java @@ -32,6 +32,7 @@ import java.util.List; import java.util.Map; import jalview.analysis.AAFrequency; +import jalview.analysis.AlignmentUtils; import jalview.analysis.Conservation; import jalview.renderer.ResidueShader; import jalview.renderer.ResidueShaderI; @@ -166,6 +167,8 @@ public class SequenceGroup implements AnnotatedCollectionI private boolean showSSConsensusHistogram; private AnnotatedCollectionI context; + + public Map hSSConsensusProfileMap; /** * Creates a new SequenceGroup object. @@ -622,11 +625,15 @@ public class SequenceGroup implements AnnotatedCollectionI cs.setConsensus(cnsns); upd = true; } - - Map hSSConsensusProfileMap = new HashMap(); + + hSSConsensusProfileMap = new HashMap(); List ssSources = new ArrayList(); + AnnotatedCollectionI aa = this.getContext(); - //ssSources = AlignmentUtils.extractSSSourceInAlignmentAnnotation(ssConsensus.toArray()); + if(aa !=null ) + { + ssSources = AlignmentUtils.extractSSSourceInAlignmentAnnotation(aa.getAlignmentAnnotation()); + } if(ssSources != null) { ssSources.add(MessageManager.getString("option.ss_providers_all")); @@ -775,7 +782,7 @@ public class SequenceGroup implements AnnotatedCollectionI : endRes + 1; aa.annotations = null; aa.annotations = new Annotation[aWidth]; // should be alignment width - + AAFrequency.completeSSConsensus(aa, profile, startRes, endRes + 1, ignoreGapsInConsensus, showSequenceLogo, nseq); // TODO: setting // container @@ -1250,7 +1257,7 @@ public class SequenceGroup implements AnnotatedCollectionI { return null; } - if (ssConsensus == null) + if (ssConsensus == null && ssSources!=null) { ssConsensus = new ArrayList(); diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 0470a28..766b35e 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -5825,6 +5825,13 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } + @Override + protected void showGroupSSConsensus_actionPerformed(ActionEvent e) + { + viewport.setShowGroupSSConsensus(showGroupSSConsensus.getState()); + alignPanel.updateAnnotation(applyAutoAnnotationSettings.getState()); + + } /* * (non-Javadoc) * diff --git a/src/jalview/jbgui/GAlignFrame.java b/src/jalview/jbgui/GAlignFrame.java index 3d249bb..a8cdcdd 100755 --- a/src/jalview/jbgui/GAlignFrame.java +++ b/src/jalview/jbgui/GAlignFrame.java @@ -196,7 +196,9 @@ public class GAlignFrame extends JInternalFrame protected JMenuItem expandViews = new JMenuItem(); - protected JCheckBoxMenuItem showSSConsensus = new JCheckBoxMenuItem(); + protected JCheckBoxMenuItem showSSConsensus = new JCheckBoxMenuItem(); + + protected JCheckBoxMenuItem showGroupSSConsensus = new JCheckBoxMenuItem(); protected JCheckBoxMenuItem showGroupConsensus = new JCheckBoxMenuItem(); @@ -871,6 +873,19 @@ public class GAlignFrame extends JInternalFrame } }); + + showGroupSSConsensus + .setText(MessageManager.getString("label.group_ss_consensus")); + showGroupSSConsensus.addActionListener(new ActionListener() + { + + @Override + public void actionPerformed(ActionEvent e) + { + showGroupSSConsensus_actionPerformed(e); + } + + }); showGroupConsensus .setText(MessageManager.getString("label.group_consensus")); @@ -1966,10 +1981,11 @@ public class GAlignFrame extends JInternalFrame autoAnnMenu.add(showConsensusHistogram); autoAnnMenu.add(showSequenceLogo); autoAnnMenu.add(normaliseSequenceLogo); - autoAnnMenu.add(showSSConsensus); + //autoAnnMenu.add(showSSConsensus); autoAnnMenu.addSeparator(); autoAnnMenu.add(showGroupConservation); autoAnnMenu.add(showGroupConsensus); + autoAnnMenu.add(showGroupSSConsensus); annotationsMenu.add(autoAnnMenu); sort.add(sortIDMenuItem); @@ -2323,6 +2339,12 @@ public class GAlignFrame extends JInternalFrame // TODO Auto-generated method stub } + + protected void showGroupSSConsensus_actionPerformed(ActionEvent e) + { + // TODO Auto-generated method stub + + } protected void showGroupConservation_actionPerformed(ActionEvent e) { diff --git a/src/jalview/renderer/AnnotationRenderer.java b/src/jalview/renderer/AnnotationRenderer.java index 2b73002..7c360c2 100644 --- a/src/jalview/renderer/AnnotationRenderer.java +++ b/src/jalview/renderer/AnnotationRenderer.java @@ -436,7 +436,20 @@ public class AnnotationRenderer if(aa.autoCalculated && aa.label.startsWith(MessageManager.getString("label.ssconsensus_label"))) { - if(hSSconsensus!=null) { + + if(aa.groupRef != null && aa.groupRef.hSSConsensusProfileMap != null + && aa.groupRef.isShowSequenceLogo()) { + for (String source : aa.groupRef.hSSConsensusProfileMap.keySet()) { + if(aa.description.startsWith(source)) { + + return AAFrequency.extractProfile( + aa.groupRef.hSSConsensusProfileMap.get(source).get(column), + aa.groupRef.getIgnoreGapsConsensus()); + } + } + } + + if(hSSconsensus!=null && aa.groupRef == null) { for (String source : hSSconsensus.keySet()) { if(aa.description.startsWith(source)) { @@ -557,7 +570,8 @@ public class AnnotationRenderer // settings appropriately // TODO: generalise this to have render styles for consensus/profile // data - if (row.groupRef != null && row == row.groupRef.getConsensus()) + if (row.groupRef != null && + (row == row.groupRef.getConsensus() || row.groupRef.getSSConsensus(null).contains(row))) { renderHistogram = row.groupRef.isShowConsensusHistogram(); renderProfile = row.groupRef.isShowSequenceLogo(); diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index cc431a5..ee07c3a 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -1111,6 +1111,9 @@ public abstract class AlignmentViewport * should consensus rows be shown for groups */ protected boolean showGroupConsensus = false; + + + protected boolean showGroupSSConsensus = false; /** * should consensus profile be rendered by default @@ -1191,6 +1194,12 @@ public abstract class AlignmentViewport { return showGroupConsensus; } + + public boolean isShowGroupSSConsensus() + { + return showGroupSSConsensus; + } + /** * @param showGroupConsensus @@ -1201,6 +1210,11 @@ public abstract class AlignmentViewport this.showGroupConsensus = showGroupConsensus; } + public void setShowGroupSSConsensus(boolean showGroupSSConsensus) + { + this.showGroupSSConsensus = showGroupSSConsensus; + } + /** * @param showSSConsensus * the showSSConsensus to set @@ -2327,6 +2341,7 @@ public abstract class AlignmentViewport boolean updateCalcs = false; boolean conv = isShowGroupConservation(); boolean cons = isShowGroupConsensus(); + boolean sscons = isShowGroupSSConsensus(); boolean showprf = isShowSequenceLogo(); boolean showConsHist = isShowConsensusHistogram(); boolean normLogo = isNormaliseSequenceLogo(); @@ -2377,7 +2392,10 @@ public abstract class AlignmentViewport { updateCalcs = true; alignment.addAnnotation(sg.getConsensus(), 0); - + } + if(sscons) + { + updateCalcs = true; List secondaryStructureSources = getSecondaryStructureSources(); if(secondaryStructureSources !=null) { List ssAa = sg.getSSConsensus(secondaryStructureSources); -- 1.7.10.2