JAL-1370 group and alignment reference sequences are not replaced with '.'
authorJim Procter <jprocter@issues.jalview.org>
Mon, 1 Jun 2015 16:04:01 +0000 (17:04 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Mon, 1 Jun 2015 16:04:01 +0000 (17:04 +0100)
when show Unconserved display is enabled

src/jalview/gui/SequenceRenderer.java

index 70acb7b..21286ad 100755 (executable)
@@ -323,11 +323,17 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer
     {
       boolean srep = av.isDisplayReferenceSeq();
       boolean getboxColour = false;
+      boolean isarep = av.getAlignment().getSeqrep() == seq;
+      boolean isgrep = currentSequenceGroup != null ? currentSequenceGroup
+              .getSeqrep() == seq : false;
+      char sr_c;
       for (int i = start; i <= end; i++)
       {
+
         graphics.setColor(av.getTextColour());
         getboxColour = false;
         s = seq.getCharAt(i);
+
         if (!renderGaps && jalview.util.Comparison.isGap(s))
         {
           continue;
@@ -364,11 +370,12 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer
           {
             graphics.setColor(currentSequenceGroup.textColour);
           }
-          if (currentSequenceGroup.getShowNonconserved()) // todo optimize
+          if (!isarep && !isgrep
+                  && currentSequenceGroup.getShowNonconserved()) // todo
+                                                                 // optimize
           {
             // todo - use sequence group consensus
-            s = getDisplayChar(srep, i, s,
-                    '.');
+            s = getDisplayChar(srep, i, s, '.', currentSequenceGroup);
 
           }
 
@@ -408,10 +415,9 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer
               graphics.setColor(av.getTextColour2());
             }
           }
-          if (av.getShowUnconserved())
+          if (!isarep && av.getShowUnconserved())
           {
-            s = getDisplayChar(srep, i, s,
-                    '.');
+            s = getDisplayChar(srep, i, s, '.', currentSequenceGroup);
 
           }
 
@@ -438,12 +444,20 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer
    * @return
    */
   private char getDisplayChar(final boolean usesrep, int position,
-          char sequenceChar, char conservedChar)
+          char sequenceChar, char conservedChar, SequenceGroup currentGroup)
   {
     // TODO - use currentSequenceGroup rather than alignment
     // currentSequenceGroup.getConsensus()
-    char conschar = (usesrep) ? av.getAlignment().getSeqrep().getCharAt(position) : av.getAlignmentConsensusAnnotation().annotations[position].displayCharacter
-            .charAt(0);
+    char conschar = (usesrep) ? (currentGroup == null ? av.getAlignment()
+            .getSeqrep().getCharAt(position)
+            : (currentGroup.getSeqrep() != null ? currentGroup.getSeqrep()
+                    .getCharAt(position) : av.getAlignment().getSeqrep()
+                    .getCharAt(position)))
+            : (currentGroup != null && currentGroup.getConsensus() != null) ? currentGroup
+                    .getConsensus().annotations[position].displayCharacter
+                    .charAt(0)
+                    : av.getAlignmentConsensusAnnotation().annotations[position].displayCharacter
+                            .charAt(0);
     if (conschar != '-'
             && (sequenceChar == conschar || sequenceChar + CHAR_TO_UPPER == conschar))
     {