JAL-4392 Feature implementation of group consensus secondary structures
authorRenia Correya <rcorreya001@dundee.ac.uk>
Wed, 12 Jun 2024 13:59:17 +0000 (14:59 +0100)
committerRenia Correya <rcorreya001@dundee.ac.uk>
Wed, 12 Jun 2024 13:59:17 +0000 (14:59 +0100)
resources/lang/Messages.properties
src/jalview/datamodel/SequenceGroup.java
src/jalview/gui/AlignFrame.java
src/jalview/jbgui/GAlignFrame.java
src/jalview/renderer/AnnotationRenderer.java
src/jalview/viewmodel/AlignmentViewport.java

index 2b9b76f..f7bdec6 100644 (file)
@@ -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
index 5416ac4..75d4460 100755 (executable)
@@ -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<String, ProfilesI> hSSConsensusProfileMap;
 
   /**
    * Creates a new SequenceGroup object.
@@ -622,11 +625,15 @@ public class SequenceGroup implements AnnotatedCollectionI
         cs.setConsensus(cnsns);
         upd = true;
       }
-
-      Map<String, ProfilesI> hSSConsensusProfileMap = new HashMap<String, ProfilesI>();
+      
+      hSSConsensusProfileMap = new HashMap<String, ProfilesI>();
       List <String> ssSources = new ArrayList<String>();
+      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<AlignmentAnnotation>();
       
index 0470a28..766b35e 100644 (file)
@@ -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)
    * 
index 3d249bb..a8cdcdd 100755 (executable)
@@ -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)
   {
index 2b73002..7c360c2 100644 (file)
@@ -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();
index cc431a5..ee07c3a 100644 (file)
@@ -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<String> secondaryStructureSources = getSecondaryStructureSources();
           if(secondaryStructureSources !=null) {
             List<AlignmentAnnotation> ssAa = sg.getSSConsensus(secondaryStructureSources);