JAL-1687 ignore case when determining if sequence matches consensus
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 17 Mar 2015 16:18:22 +0000 (16:18 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 17 Mar 2015 16:18:22 +0000 (16:18 +0000)
src/jalview/gui/SequenceRenderer.java

index 46dcdad..70acb7b 100755 (executable)
@@ -37,6 +37,8 @@ import java.awt.Graphics;
  */
 public class SequenceRenderer implements jalview.api.SequenceRenderer
 {
+  final static int CHAR_TO_UPPER = 'A' - 'a';
+
   AlignViewport av;
 
   FontMetrics fm;
@@ -424,18 +426,30 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer
     }
   }
 
+  /**
+   * Returns 'conservedChar' to represent the given position if the sequence
+   * character at that position is equal to the consensus (ignoring case), else
+   * returns the sequence character
+   * 
+   * @param usesrep
+   * @param position
+   * @param sequenceChar
+   * @param conservedChar
+   * @return
+   */
   private char getDisplayChar(final boolean usesrep, int position,
-          char s, char c)
+          char sequenceChar, char conservedChar)
   {
-    // TODO - use currentSequenceGroup rather than alignemnt 
+    // TODO - use currentSequenceGroup rather than alignment
     // currentSequenceGroup.getConsensus()
     char conschar = (usesrep) ? av.getAlignment().getSeqrep().getCharAt(position) : av.getAlignmentConsensusAnnotation().annotations[position].displayCharacter
             .charAt(0);
-    if (conschar != '-' && s == conschar)
+    if (conschar != '-'
+            && (sequenceChar == conschar || sequenceChar + CHAR_TO_UPPER == conschar))
     {
-      s = c;
+      sequenceChar = conservedChar;
     }
-    return s;
+    return sequenceChar;
   }
 
   /**