Merge branch 'develop' into improvement/JAL-4409_implement_extra_schemes_in_getdown
[jalview.git] / src / jalview / renderer / ResidueShader.java
index c031170..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;
+    
   }
 
   /**
@@ -261,6 +279,36 @@ public class ResidueShader implements ResidueShaderI
 
     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
+     */
+    if (!Comparison.isGap(symbol))
+    {
+      colour = adjustColour(symbol, position, colour);
+    }
+
+    return colour;
+  }
 
   /**
    * Adjusts colour by applying thresholding or conservation shading, if in