JAL-4436 Implementation of add colour by secondary structure consensus
authorRenia Correya <rcorreya001@dundee.ac.uk>
Wed, 3 Jul 2024 09:32:15 +0000 (10:32 +0100)
committerRenia Correya <rcorreya001@dundee.ac.uk>
Wed, 3 Jul 2024 09:32:15 +0000 (10:32 +0100)
resources/lang/Messages.properties
src/jalview/api/ViewStyleI.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/PopupMenu.java
src/jalview/gui/SliderPanel.java
src/jalview/jbgui/GAlignFrame.java
src/jalview/renderer/ResidueShader.java
src/jalview/renderer/ResidueShaderI.java
src/jalview/viewmodel/AlignmentViewport.java
src/jalview/viewmodel/styles/ViewStyle.java

index f7bdec6..507abb2 100644 (file)
@@ -83,6 +83,7 @@ action.remove_redundancy = Remove Redundancy...
 action.pairwise_alignment = Pairwise Alignment
 action.user_defined = User Defined...
 action.by_conservation = By Conservation
+action.by_consensus_secondary_structure = By Secondary Structure Consensus
 action.wrap = Wrap
 action.show_gaps = Show Gaps
 action.show_hidden_markers = Show Hidden Markers
@@ -260,6 +261,7 @@ label.to_this_alignment = Add To This Alignment
 label.apply_colour_to_all_groups = Apply Colour To All Groups
 label.modify_identity_threshold = Modify Identity Threshold...
 label.modify_conservation_threshold = Modify Conservation Threshold...
+label.modify_consensus_secondary_structure_threshold = Modify Secondary Structure Consensus Threshold...
 label.input_from_textbox = Input from textbox
 label.centre_column_labels = Centre column labels
 label.automatic_scrolling = Automatic Scrolling
@@ -902,6 +904,7 @@ label.copied_sequences = Copied sequences
 label.cut_sequences = Cut Sequences
 label.conservation_colour_increment = Conservation Colour Increment ({0})
 label.percentage_identity_threshold = Percentage Identity Threshold ({0})
+label.consensus_secondary_structure_threshold = Consensus Secondary Structure Threshold ({0})
 label.error_unsupported_owwner_user_colour_scheme = Unsupported owner for User Colour scheme dialog
 label.save_alignment_to_file = Save Alignment to file
 label.save_features_to_file = Save Features to File
index 9e87c87..1c7775e 100644 (file)
@@ -38,6 +38,8 @@ public interface ViewStyleI
   boolean getColourAppliesToAllGroups();
 
   boolean getAbovePIDThreshold();
+  
+  boolean getByConsensusSecondaryStructureSelected();
 
   void setIncrement(int inc);
 
@@ -64,6 +66,8 @@ public interface ViewStyleI
   boolean getScaleRightWrapped();
 
   void setAbovePIDThreshold(boolean b);
+  
+  void setByConsensusSecondaryStructureSelected(boolean b);
 
   void setThreshold(int thresh);
 
index 766b35e..93d6424 100644 (file)
@@ -893,6 +893,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     conservationMenuItem.setEnabled(!nucleotide);
     modifyConservation
             .setEnabled(!nucleotide && conservationMenuItem.isSelected());
+    byConsensusSecondaryStructureMenuItem.setEnabled(!nucleotide);
+    modifyConsensusSecondaryStructureThreshold.setEnabled(!nucleotide 
+            && byConsensusSecondaryStructureMenuItem.isSelected());
     showGroupConservation.setEnabled(!nucleotide);
 
     showComplementMenuItem
@@ -926,6 +929,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     modifyPID.setEnabled(abovePIDThreshold.isSelected());
     conservationMenuItem.setSelected(av.getConservationSelected());
     modifyConservation.setEnabled(conservationMenuItem.isSelected());
+    byConsensusSecondaryStructureMenuItem.setSelected(
+            av.getByConsensusSecondaryStructureSelected());
+    modifyConsensusSecondaryStructureThreshold.setEnabled(
+            byConsensusSecondaryStructureMenuItem.isSelected());
     seqLimits.setSelected(av.getShowJVSuffix());
     idRightAlign.setSelected(av.isRightAlignIds());
     centreColumnLabelsMenuItem.setState(av.isCentreColumnLabels());
@@ -3706,6 +3713,14 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
             viewport.getResidueShading(), alignPanel.getViewName());
     SliderPanel.showConservationSlider();
   }
+  
+  @Override
+  protected void modifyConsensusSecondaryStructureThreshold_actionPerformed()
+  {
+    SliderPanel.setConsensusSecondaryStructureSlider(alignPanel,
+            viewport.getResidueShading(), alignPanel.getViewName());
+    SliderPanel.showConsensusSecondaryStructureSlider();
+  }
 
   /**
    * Action on selecting or deselecting (Colour) By Conservation
@@ -3727,6 +3742,24 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       SliderPanel.hideConservationSlider();
     }
   }
+  
+  @Override
+  public void colourByConsensusSecondaryStructureMenuItem_actionPerformed(boolean selected)
+  {
+    modifyConsensusSecondaryStructureThreshold.setEnabled(selected);
+    viewport.setByConsensusSecondaryStructureSelected(selected); 
+    viewport.getResidueShading().setConsensusSecondaryStructureColouring(selected);
+
+    changeColour(viewport.getGlobalColourScheme());
+    if (selected)
+    {
+      modifyConsensusSecondaryStructureThreshold_actionPerformed();
+    }
+    else
+    {
+      SliderPanel.hideConsensusSecondaryStructureSlider();
+    }
+  }
 
   /**
    * Action on selecting or deselecting (Colour) Above PID Threshold
@@ -6210,6 +6243,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     colourMenu.addSeparator();
     colourMenu.add(conservationMenuItem);
     colourMenu.add(modifyConservation);
+    colourMenu.add(byConsensusSecondaryStructureMenuItem);
+    colourMenu.add(modifyConsensusSecondaryStructureThreshold);
     colourMenu.add(abovePIDThreshold);
     colourMenu.add(modifyPID);
 
index 9d23474..07fe819 100644 (file)
@@ -128,6 +128,10 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
 
   protected JMenuItem modifyConservation = new JMenuItem();
 
+  protected JCheckBoxMenuItem byConsensusSecondaryStructureMenuItem = new JCheckBoxMenuItem();
+
+  protected JMenuItem modifyConsensusSecondaryStructureThreshold = new JMenuItem();
+
   JMenu sequenceMenu = new JMenu();
 
   JMenuItem makeReferenceSeq = new JMenuItem();
@@ -649,6 +653,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
       ColourMenuHelper.setColourSelected(colourMenu, sg.getColourScheme());
 
       conservationMenuItem.setEnabled(!sg.isNucleotide());
+      
+      byConsensusSecondaryStructureMenuItem.setEnabled(!sg.isNucleotide());
 
       if (sg.cs != null)
       {
@@ -660,9 +666,15 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
         {
           abovePIDColour.setSelected(true);
         }
+        if(sg.cs.isConsensusSecondaryStructureColouring()) 
+        {
+          byConsensusSecondaryStructureMenuItem.setSelected(true);
+        }
       }
       modifyConservation.setEnabled(conservationMenuItem.isSelected());
       modifyPID.setEnabled(abovePIDColour.isSelected());
+      modifyConsensusSecondaryStructureThreshold.setEnabled(
+              byConsensusSecondaryStructureMenuItem.isSelected());
       displayNonconserved.setSelected(sg.getShowNonconserved());
       showText.setSelected(sg.getDisplayText());
       showColourText.setSelected(sg.getColourText());
@@ -1623,6 +1635,18 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
                 conservationMenuItem.isSelected());
       }
     });
+    
+    byConsensusSecondaryStructureMenuItem.setText(
+            MessageManager.getString("action.by_consensus_secondary_structure"));
+    byConsensusSecondaryStructureMenuItem.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        colourByConsensusSecondaryStructureMenuItem_actionPerformed(
+                byConsensusSecondaryStructureMenuItem.isSelected());
+      }
+    });
 
     annotationColour = new JRadioButtonMenuItem(
             MessageManager.getString("action.by_annotation"));
@@ -1641,6 +1665,17 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
         modifyConservation_actionPerformed();
       }
     });
+    
+    modifyConsensusSecondaryStructureThreshold.setText(MessageManager
+            .getString("label.modify_consensus_secondary_structure_threshold"));
+    modifyConsensusSecondaryStructureThreshold.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        modifyConsensusSecondaryStructureThreshold_actionPerformed();
+      }
+    });
   }
 
   /**
@@ -1669,6 +1704,8 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
     colourMenu.addSeparator();
     colourMenu.add(conservationMenuItem);
     colourMenu.add(modifyConservation);
+    colourMenu.add(byConsensusSecondaryStructureMenuItem);
+    colourMenu.add(modifyConsensusSecondaryStructureThreshold);
     colourMenu.add(abovePIDColour);
     colourMenu.add(modifyPID);
   }
@@ -1682,6 +1719,17 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
       SliderPanel.showConservationSlider();
     }
   }
+  
+  protected void modifyConsensusSecondaryStructureThreshold_actionPerformed()
+  {
+    SequenceGroup sg = getGroup();
+    if (sg.cs != null)
+    {
+      SliderPanel.setConsensusSecondaryStructureSlider(ap, sg.cs, sg.getName());
+      SliderPanel.showConsensusSecondaryStructureSlider();
+    }
+  }
+  
 
   protected void modifyPID_actionPerformed()
   {
@@ -2026,6 +2074,34 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
 
     refresh();
   }
+  
+  public void colourByConsensusSecondaryStructureMenuItem_actionPerformed(boolean selected)
+  {
+    SequenceGroup sg = getGroup();
+    if (sg.cs == null)
+    {
+      return;
+    }
+
+    if (selected)
+    {
+      
+      sg.cs.setConsensusSecondaryStructureColouring(selected);
+
+      SliderPanel.setConsensusSecondaryStructureSlider(ap, sg.getGroupColourScheme(),
+              sg.getName());
+      SliderPanel.showConsensusSecondaryStructureSlider();
+    }
+    else
+    // remove ConsensusSecondaryStructureColouring
+    {
+      sg.cs.setConsensusSecondaryStructureColouring(selected);
+      SliderPanel.hideConsensusSecondaryStructureSlider();
+    }
+    modifyConsensusSecondaryStructureThreshold.setEnabled(selected);
+
+    refresh();
+  }
 
   /**
    * Shows a dialog where group name and description may be edited
index 1d59853..62ac54f 100755 (executable)
@@ -49,12 +49,16 @@ public class SliderPanel extends GSliderPanel
   private static final String BACKGROUND = "Background";
 
   static JInternalFrame conservationSlider;
+  
+  static JInternalFrame consensusSecondaryStructureSlider;
 
   static JInternalFrame PIDSlider;
 
   AlignmentPanel ap;
 
   boolean forConservation = true;
+  
+  boolean forConsensusSecondaryStructure = false;
 
   ResidueShaderI cs;
 
@@ -73,6 +77,10 @@ public class SliderPanel extends GSliderPanel
     {
       return (SliderPanel) PIDSlider.getContentPane();
     }
+    if (consensusSecondaryStructureSlider != null && consensusSecondaryStructureSlider.isVisible())
+    {
+      return (SliderPanel) consensusSecondaryStructureSlider.getContentPane();
+    }
     return null;
   }
 
@@ -89,11 +97,13 @@ public class SliderPanel extends GSliderPanel
    *          DOCUMENT ME!
    */
   public SliderPanel(final AlignmentPanel ap, int value,
-          boolean forConserve, ResidueShaderI scheme)
+          boolean forConserve, boolean forConsensusSS, ResidueShaderI scheme)
   {
     this.ap = ap;
     this.cs = scheme;
     forConservation = forConserve;
+    forConsensusSecondaryStructure = forConsensusSS;
+    
     undoButton.setVisible(false);
     applyButton.setVisible(false);
 
@@ -104,6 +114,12 @@ public class SliderPanel extends GSliderPanel
       slider.setMinimum(0);
       slider.setMaximum(100);
     }
+    if(forConsensusSS) {
+      label.setText(MessageManager.getString(
+              "label.enter_value_increase_conservation_visibility"));
+      slider.setMinimum(0);
+      slider.setMaximum(100);
+    }
     else
     {
       label.setText(MessageManager.getString(
@@ -154,7 +170,7 @@ public class SliderPanel extends GSliderPanel
 
     if (conservationSlider == null)
     {
-      sliderPanel = new SliderPanel(ap, rs.getConservationInc(), true, rs);
+      sliderPanel = new SliderPanel(ap, rs.getConservationInc(), true, false, rs);
       conservationSlider = new JInternalFrame();
       conservationSlider.setFrameIcon(null);
       conservationSlider.setContentPane(sliderPanel);
@@ -246,6 +262,86 @@ public class SliderPanel extends GSliderPanel
       conservationSlider.setLayer(JLayeredPane.PALETTE_LAYER);
     }
   }
+  
+  public static int setConsensusSecondaryStructureSlider(AlignmentPanel ap,
+          ResidueShaderI rs, String source)
+  {
+    SliderPanel sliderPanel = null;
+
+    if (consensusSecondaryStructureSlider == null)
+    {
+      sliderPanel = new SliderPanel(ap, rs.getConsensusSecondaryStructureThreshold(), false, true, rs);
+      consensusSecondaryStructureSlider = new JInternalFrame();
+      consensusSecondaryStructureSlider.setFrameIcon(null);
+      consensusSecondaryStructureSlider.setContentPane(sliderPanel);
+      consensusSecondaryStructureSlider.setLayer(JLayeredPane.PALETTE_LAYER);
+    }
+    else
+    {
+      sliderPanel = (SliderPanel) consensusSecondaryStructureSlider.getContentPane();
+      sliderPanel.valueField
+              .setText(String.valueOf(rs.getConsensusSecondaryStructureThreshold()));
+      sliderPanel.cs = rs;
+      sliderPanel.ap = ap;
+      sliderPanel.slider.setValue(rs.getConsensusSecondaryStructureThreshold());
+    }
+
+    consensusSecondaryStructureSlider.setTitle(MessageManager.formatMessage(
+            "label.consensus_secondary_structure_threshold", new String[]
+            { source == null ? BACKGROUND : source }));
+
+    List<SequenceGroup> groups = ap.av.getAlignment().getGroups();
+    if (groups != null && !groups.isEmpty())
+    {
+      sliderPanel.setAllGroupsCheckEnabled(true);
+      sliderPanel.allGroupsCheck
+              .setSelected(ap.av.getColourAppliesToAllGroups());
+    }
+    else
+    {
+      sliderPanel.setAllGroupsCheckEnabled(false);
+    }
+
+    return sliderPanel.getValue();
+  }
+  
+  
+  public static void hideConsensusSecondaryStructureSlider()
+  {
+    if (consensusSecondaryStructureSlider != null)
+    {
+      try
+      {
+        consensusSecondaryStructureSlider.setClosed(true);
+        consensusSecondaryStructureSlider = null;
+      } catch (PropertyVetoException ex)
+      {
+      }
+    }
+  }
+  
+  
+  public static void showConsensusSecondaryStructureSlider()
+  {
+    hidePIDSlider();
+    hideConservationSlider();
+
+    if (!consensusSecondaryStructureSlider.isVisible())
+    {
+      Desktop.addInternalFrame(consensusSecondaryStructureSlider,
+              consensusSecondaryStructureSlider.getTitle(), true, FRAME_WIDTH,
+              FRAME_HEIGHT, false, true);
+      consensusSecondaryStructureSlider.addInternalFrameListener(new InternalFrameAdapter()
+      {
+        @Override
+        public void internalFrameClosed(InternalFrameEvent e)
+        {
+          consensusSecondaryStructureSlider = null;
+        }
+      });
+      consensusSecondaryStructureSlider.setLayer(JLayeredPane.PALETTE_LAYER);
+    }
+  }
 
   /**
    * Method to 'set focus' of the PID slider panel
@@ -268,7 +364,7 @@ public class SliderPanel extends GSliderPanel
 
     if (PIDSlider == null)
     {
-      sliderPanel = new SliderPanel(ap, threshold, false, rs);
+      sliderPanel = new SliderPanel(ap, threshold, false, false, rs);
       PIDSlider = new JInternalFrame();
       PIDSlider.setFrameIcon(null);
       PIDSlider.setContentPane(sliderPanel);
@@ -335,7 +431,7 @@ public class SliderPanel extends GSliderPanel
    */
   public void valueChanged(int percent)
   {
-    if (!forConservation)
+    if (!forConservation && !forConsensusSecondaryStructure)
     {
       ap.av.setThreshold(percent);
     }
@@ -386,6 +482,11 @@ public class SliderPanel extends GSliderPanel
       scheme.setConservationApplied(true);
       scheme.setConservationInc(percent);
     }
+    else if(forConsensusSecondaryStructure)
+    {
+      scheme.setConsensusSecondaryStructureColouring(true);
+      scheme.setConsensusSecondaryStructureThreshold(percent);
+    }
     else
     {
       scheme.setThreshold(percent, ap.av.isIgnoreGapsConsensus());
@@ -467,6 +568,11 @@ public class SliderPanel extends GSliderPanel
   {
     return getValue(PIDSlider);
   }
+  
+  public static int getConsensusSecondaryStructureSliderValue()
+  {
+    return getValue(consensusSecondaryStructureSlider);
+  }
 
   /**
    * Answers true if the SliderPanel is for Conservation, false if it is for PID
@@ -499,6 +605,10 @@ public class SliderPanel extends GSliderPanel
     {
       title = PIDSlider.getTitle();
     }
+    else if(consensusSecondaryStructureSlider != null)
+    {
+      title = consensusSecondaryStructureSlider.getTitle();
+    }
     return title;
   }
 }
index a8cdcdd..de11724 100755 (executable)
@@ -132,7 +132,11 @@ public class GAlignFrame extends JInternalFrame
 
   protected JCheckBoxMenuItem abovePIDThreshold;
 
-  protected JMenuItem modifyPID;
+  protected JMenuItem modifyPID;  
+
+  protected JCheckBoxMenuItem byConsensusSecondaryStructureMenuItem;
+  
+  protected JMenuItem modifyConsensusSecondaryStructureThreshold;
 
   protected JRadioButtonMenuItem annotationColour;
 
@@ -2140,6 +2144,19 @@ public class GAlignFrame extends JInternalFrame
                 conservationMenuItem.isSelected());
       }
     });
+    
+
+    byConsensusSecondaryStructureMenuItem = new JCheckBoxMenuItem(
+            MessageManager.getString("action.by_consensus_secondary_structure"));
+    byConsensusSecondaryStructureMenuItem.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        colourByConsensusSecondaryStructureMenuItem_actionPerformed(
+                byConsensusSecondaryStructureMenuItem.isSelected());
+      }
+    });
 
     abovePIDThreshold = new JCheckBoxMenuItem(
             MessageManager.getString("label.above_identity_threshold"));
@@ -2171,6 +2188,18 @@ public class GAlignFrame extends JInternalFrame
         modifyConservation_actionPerformed();
       }
     });
+    
+    modifyConsensusSecondaryStructureThreshold = new JMenuItem(MessageManager
+            .getString("label.modify_consensus_secondary_structure_threshold"));
+    modifyConsensusSecondaryStructureThreshold.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        modifyConsensusSecondaryStructureThreshold_actionPerformed();
+      }
+    });
+    
 
     annotationColour = new JRadioButtonMenuItem(
             MessageManager.getString("action.by_annotation"));
@@ -2533,6 +2562,10 @@ public class GAlignFrame extends JInternalFrame
   protected void conservationMenuItem_actionPerformed(boolean selected)
   {
   }
+  
+  public void colourByConsensusSecondaryStructureMenuItem_actionPerformed(boolean selected)
+  {
+  }
 
   protected void printMenuItem_actionPerformed(ActionEvent e)
   {
@@ -2640,6 +2673,10 @@ public class GAlignFrame extends JInternalFrame
   protected void modifyConservation_actionPerformed()
   {
   }
+  
+  protected void modifyConsensusSecondaryStructureThreshold_actionPerformed()
+  {
+  }
 
   protected void saveAs_actionPerformed()
   {
index 9231901..eaccf17 100644 (file)
@@ -30,6 +30,7 @@ import jalview.datamodel.SequenceI;
 import jalview.schemes.ColourSchemeI;
 import jalview.util.ColorUtils;
 import jalview.util.Comparison;
+import jalview.util.MessageManager;
 
 import java.awt.Color;
 import java.util.Map;
@@ -72,6 +73,14 @@ public class ResidueShader implements ResidueShaderI
    * if true, apply shading of colour by conservation
    */
   private boolean conservationColouring;
+  
+  private boolean consensusSecondaryStructureColouring;
+
+  @Override
+  public boolean isConsensusSecondaryStructureColouring()
+  {
+    return consensusSecondaryStructureColouring;
+  }
 
   /*
    * the physico-chemical property conservation scores for columns, with values
@@ -96,6 +105,8 @@ public class ResidueShader implements ResidueShaderI
    * setting of the By Conservation slider
    */
   private int conservationIncrement = INITIAL_CONSERVATION;
+  
+  private int consensusSecondaryStructureThreshold = 30;
 
   public ResidueShader(ColourSchemeI cs)
   {
@@ -135,6 +146,8 @@ public class ResidueShader implements ResidueShaderI
     this.ignoreGaps = rs.ignoreGaps;
     this.pidThreshold = rs.pidThreshold;
     this.ssConsensusProfileMap = rs.ssConsensusProfileMap;
+    this.consensusSecondaryStructureColouring = rs.consensusSecondaryStructureColouring;
+    this.consensusSecondaryStructureThreshold = rs.consensusSecondaryStructureThreshold;
   }
 
   /**
@@ -184,6 +197,14 @@ public class ResidueShader implements ResidueShaderI
     }
 
   }
+  
+  @Override
+  public void setConsensusSecondaryStructureColouring(boolean colourByConsensusSecondaryStructure) 
+  {
+    
+    consensusSecondaryStructureColouring = colourByConsensusSecondaryStructure;
+    
+  }
 
   /**
    * @see jalview.renderer.ResidueShaderI#alignmentChanged(jalview.datamodel.AnnotatedCollectionI,
@@ -227,6 +248,18 @@ public class ResidueShader implements ResidueShaderI
     return conservationIncrement;
   }
 
+  @Override
+  public void setConsensusSecondaryStructureThreshold(int i)
+  {
+    consensusSecondaryStructureThreshold = i;
+  }
+  
+  @Override
+  public int getConsensusSecondaryStructureThreshold()
+  {
+    return consensusSecondaryStructureThreshold;
+  }
+  
   /**
    * @see jalview.renderer.ResidueShaderI#getThreshold()
    */
@@ -323,6 +356,11 @@ public class ResidueShader implements ResidueShaderI
     {
       colour = Color.white;
     }
+    
+    if(consensusSecondaryStructureColouring)
+    {
+      colour = applyByConsensusSecondaryStructure(colour, column);
+    }
 
     if (conservationColouring)
     {
@@ -435,6 +473,38 @@ public class ResidueShader implements ResidueShaderI
 
     return ColorUtils.bleachColour(currentColour, bleachFactor);
   }
+  
+  
+  protected Color applyByConsensusSecondaryStructure(Color currentColour, int column)
+  {
+    if (ssConsensusProfileMap == null && 
+            ssConsensusProfileMap.get(MessageManager.getString("option.ss_providers_all")) == null) 
+    {
+      return currentColour;
+    }
+    
+    ProfilesI consensusSSProfileForAllSources = 
+            ssConsensusProfileMap.get(MessageManager.getString("option.ss_providers_all"));
+    ProfileI profile = consensusSSProfileForAllSources.get(column);
+    
+    if(profile != null) 
+    { 
+        float pid = profile.getSSPercentageIdentity(ignoreGaps);
+
+        if(pid == 0) {
+          return Color.white;
+        }
+
+        float bleachFactor = 1f - (pid/100);
+        bleachFactor *= (consensusSecondaryStructureThreshold/20);
+
+        return ColorUtils.bleachColour(currentColour, bleachFactor);
+        
+    }
+    
+    return currentColour;
+
+  }
 
   /**
    * @see jalview.renderer.ResidueShaderI#getColourScheme()
index 42f4e2e..38a466b 100644 (file)
@@ -87,4 +87,13 @@ public interface ResidueShaderI
   Color findSSColour(char symbol, int position, SequenceI seq,
           String source);
 
+  int getConsensusSecondaryStructureThreshold();
+
+  void setConsensusSecondaryStructureThreshold(int i);
+
+  void setConsensusSecondaryStructureColouring(
+          boolean colourByConsensusSecondaryStructure);
+
+  boolean isConsensusSecondaryStructureColouring();
+
 }
\ No newline at end of file
index ee07c3a..684e355 100644 (file)
@@ -252,6 +252,12 @@ public abstract class AlignmentViewport
   {
     return viewStyle.getAbovePIDThreshold();
   }
+  
+  @Override
+  public boolean getByConsensusSecondaryStructureSelected()
+  {
+    return viewStyle.getByConsensusSecondaryStructureSelected();
+  }
 
   /**
    * @param inc
@@ -372,6 +378,12 @@ public abstract class AlignmentViewport
   {
     viewStyle.setAbovePIDThreshold(b);
   }
+  
+  @Override
+  public void setByConsensusSecondaryStructureSelected(boolean b)
+  {
+    viewStyle.setByConsensusSecondaryStructureSelected(b);
+  }
 
   /**
    * @param thresh
@@ -2401,7 +2413,7 @@ public abstract class AlignmentViewport
             List<AlignmentAnnotation> ssAa = sg.getSSConsensus(secondaryStructureSources);
             if(ssAa != null) {
               for(AlignmentAnnotation aa : ssAa) {
-                alignment.addAnnotation(aa, 0);
+                  alignment.addAnnotation(aa, 0);
               }
             }
           }
index e856262..c7c4086 100644 (file)
@@ -66,6 +66,8 @@ public class ViewStyle implements ViewStyleI
   private boolean colourByReferenceSeq = false;
 
   boolean conservationColourSelected = false;
+  
+  boolean byConsensusSecondaryStructureSelected = false;
 
   /**
    * show the reference sequence in the alignment view
@@ -189,6 +191,7 @@ public class ViewStyle implements ViewStyleI
     setColourAppliesToAllGroups(vs.getColourAppliesToAllGroups());
     setColourByReferenceSeq(vs.isColourByReferenceSeq());
     setColourText(vs.getColourText());
+    setByConsensusSecondaryStructureSelected(vs.getByConsensusSecondaryStructureSelected());
     setConservationColourSelected(vs.isConservationColourSelected());
     setConservationSelected(vs.getConservationSelected());
     setDisplayReferenceSeq(vs.isDisplayReferenceSeq());
@@ -255,6 +258,7 @@ public class ViewStyle implements ViewStyleI
             && getColourText() == vs.getColourText()
             && isConservationColourSelected() == vs
                     .isConservationColourSelected()
+            && getByConsensusSecondaryStructureSelected() == vs.getByConsensusSecondaryStructureSelected()
             && getConservationSelected() == vs.getConservationSelected()
             && isDisplayReferenceSeq() == vs.isDisplayReferenceSeq()
             && getFontSize() == vs.getFontSize()
@@ -393,6 +397,11 @@ public class ViewStyle implements ViewStyleI
     return abovePIDThreshold;
   }
 
+  @Override
+  public boolean getByConsensusSecondaryStructureSelected()
+  {
+    return byConsensusSecondaryStructureSelected;
+  }
   /**
    * DOCUMENT ME!
    * 
@@ -684,6 +693,12 @@ public class ViewStyle implements ViewStyleI
   {
     abovePIDThreshold = b;
   }
+  
+  @Override
+  public void setByConsensusSecondaryStructureSelected(boolean b)
+  {
+    byConsensusSecondaryStructureSelected = b;
+  }
 
   /**
    * DOCUMENT ME!