From: gmungoc Date: Tue, 17 Mar 2015 16:18:22 +0000 (+0000) Subject: JAL-1687 ignore case when determining if sequence matches consensus X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=330289271fe2239a59fa318d6b2b19fdd319f8a4;p=jalview.git JAL-1687 ignore case when determining if sequence matches consensus --- diff --git a/src/jalview/gui/SequenceRenderer.java b/src/jalview/gui/SequenceRenderer.java index 46dcdad..70acb7b 100755 --- a/src/jalview/gui/SequenceRenderer.java +++ b/src/jalview/gui/SequenceRenderer.java @@ -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; } /**