JAL-4392 Consensus secondary structure: Display Secondary structure consensus for...
[jalview.git] / src / jalview / renderer / ResidueShader.java
index aa84816..b914c65 100644 (file)
@@ -61,6 +61,22 @@ public class ResidueShader implements ResidueShaderI
    * the consensus data for each column
    */
   private ProfilesI consensus;
+  
+  /*
+   * the consensus data for each column
+   */
+  private ProfilesI ssConsensus;
+  
+
+  public ProfilesI getSsConsensus()
+  {
+    return ssConsensus;
+  }
+
+  public void setSsConsensus(ProfilesI ssConsensus)
+  {
+    this.ssConsensus = ssConsensus;
+  }
 
   /*
    * if true, apply shading of colour by conservation
@@ -128,6 +144,7 @@ public class ResidueShader implements ResidueShaderI
     this.conservationIncrement = rs.conservationIncrement;
     this.ignoreGaps = rs.ignoreGaps;
     this.pidThreshold = rs.pidThreshold;
+    this.ssConsensus = rs.ssConsensus;
   }
 
   /**
@@ -137,6 +154,7 @@ public class ResidueShader implements ResidueShaderI
   public void setConsensus(ProfilesI cons)
   {
     consensus = cons;
+    
   }
 
   /**
@@ -235,6 +253,11 @@ public class ResidueShader implements ResidueShaderI
   @Override
   public Color findColour(char symbol, int position, SequenceI seq)
   {
+    if (colourScheme == null)
+    {
+      return Color.white; // Colour is 'None'
+    }
+
     /*
      * get 'base' colour
      */
@@ -243,9 +266,38 @@ public class ResidueShader implements ResidueShaderI
             : profile.getModalResidue();
     float pid = profile == null ? 0f
             : profile.getPercentageIdentity(ignoreGaps);
-    Color colour = colourScheme == null ? Color.white
-            : colourScheme.findColour(symbol, position, seq, modalResidue,
-                    pid);
+    Color colour = colourScheme.findColour(symbol, position, seq,
+            modalResidue, pid);
+
+    /*
+     * apply PID threshold and consensus fading if in force
+     */
+    if (!Comparison.isGap(symbol))
+    {
+      colour = adjustColour(symbol, position, colour);
+    }
+
+    return colour;
+  }
+  
+  @Override
+  public Color findSSColour(char symbol, int position, SequenceI seq)
+  {
+    if (colourScheme == null)
+    {
+      return Color.white; // Colour is 'None'
+    }
+
+    /*
+     * get 'base' colour
+     */
+    ProfileI profile = ssConsensus == null ? null : ssConsensus.get(position);
+    String modalSS = profile == null ? null
+            : profile.getModalSS();
+    float pid = profile == null ? 0f
+            : profile.getSSPercentageIdentity(ignoreGaps);
+    Color colour = colourScheme.findColour(symbol, position, seq,
+            modalSS, pid);
 
     /*
      * apply PID threshold and consensus fading if in force