JAL-1520 switch between Protein and non-canonical RNA secondary structure rendering...
authorj.procter@dundee.ac.uk <jprocter@jims-mbp-2.dyn.lifesci.dundee.ac.uk>
Fri, 18 Jul 2014 11:08:09 +0000 (12:08 +0100)
committerj.procter@dundee.ac.uk <jprocter@jims-mbp-2.dyn.lifesci.dundee.ac.uk>
Fri, 18 Jul 2014 11:08:09 +0000 (12:08 +0100)
src/jalview/datamodel/AlignmentAnnotation.java
src/jalview/renderer/AnnotationRenderer.java

index 9659cd7..601339a 100755 (executable)
@@ -1112,4 +1112,9 @@ public class AlignmentAnnotation
   {
     this.calcId = calcId;
   }
+
+  public boolean isRNA()
+  {
+    return isrna;
+  }
 }
index 5b89772..e731910 100644 (file)
@@ -297,6 +297,7 @@ public class AnnotationRenderer
       profcolour = av.getAlignment().isNucleotide() ? new jalview.schemes.NucleotideColourScheme()
               : new jalview.schemes.ZappoColourScheme();
     }
+    boolean rna = av.getAlignment().isNucleotide();
     columnSelection = av.getColumnSelection();
     hconsensus = av.getSequenceConsensusHash();// hconsensus;
     hStrucConsensus = av.getRnaStructureConsensusHash(); // hStrucConsensus;
@@ -353,6 +354,8 @@ public class AnnotationRenderer
     return null;
   }
 
+  boolean rna = false;
+
   /**
    * Render the annotation rows associated with an alignment.
    * 
@@ -402,7 +405,7 @@ public class AnnotationRenderer
     AlignmentAnnotation consensusAnnot = av
             .getAlignmentConsensusAnnotation(), structConsensusAnnot = av
             .getAlignmentStrucConsensusAnnotation();
-    boolean renderHistogram = true, renderProfile = true, normaliseProfile = false;
+    boolean renderHistogram = true, renderProfile = true, normaliseProfile = false, isRNA = rna;
 
     BitSet graphGroupDrawn = new BitSet();
     int charOffset = 0; // offset for a label
@@ -416,6 +419,7 @@ public class AnnotationRenderer
     for (int i = 0; i < aa.length; i++)
     {
       AlignmentAnnotation row = aa[i];
+      isRNA = row.isRNA();
       {
         // check if this is a consensus annotation row and set the display
         // settings appropriately
@@ -696,23 +700,31 @@ public class AnnotationRenderer
                 // System.out.println("\t type :"+lastSS+"\t x :"+x+"\t nbre annot :"+nb_annot);
                 switch (lastSS)
                 {
-
-                case '$':
-                  drawHelixAnnot(g, row_annotations, lastSSX, x, y,
-                          iconOffset, startRes, column, validRes, validEnd);
-                  break;
-
-                case 0xCE:
-                  drawSheetAnnot(g, row_annotations, lastSSX, x, y,
-                          iconOffset, startRes, column, validRes, validEnd);
-                  break;
-
                 case '(': // Stem case for RNA secondary structure
                 case ')': // and opposite direction
                   drawStemAnnot(g, row_annotations, lastSSX, x, y,
                           iconOffset, startRes, column, validRes, validEnd);
                   temp = x;
                   break;
+
+                case 'H':
+                  if (!isRNA)
+                  {
+                    drawHelixAnnot(g, row_annotations, lastSSX, x, y,
+                            iconOffset, startRes, column, validRes,
+                            validEnd);
+                    break;
+                  }
+
+                case 'E':
+                  if (!isRNA)
+                  {
+                    drawSheetAnnot(g, row_annotations, lastSSX, x, y,
+                            iconOffset, startRes, column, validRes,
+                            validEnd);
+                    break;
+                  }
+
                 case '{':
                 case '}':
                 case '[':
@@ -727,13 +739,11 @@ public class AnnotationRenderer
                 case 'c':
                 case 'D':
                 case 'd':
-                case 'E':
                 case 'e':
                 case 'F':
                 case 'f':
                 case 'G':
                 case 'g':
-                case 'H':
                 case 'h':
                 case 'I':
                 case 'i':
@@ -828,17 +838,25 @@ public class AnnotationRenderer
         {
           switch (lastSS)
           {
-          case '$':
-            drawHelixAnnot(g, row_annotations, lastSSX, x, y, iconOffset,
-                    startRes, column, validRes, validEnd);
-            break;
 
-          case 0xCE:
-            drawSheetAnnot(g, row_annotations, lastSSX, x, y, iconOffset,
-                    startRes, column, validRes, validEnd);
-            break;
-          case 's':
-          case 'S': // Stem case for RNA secondary structure
+          case 'H':
+            if (!isRNA)
+            {
+              drawHelixAnnot(g, row_annotations, lastSSX, x, y, iconOffset,
+                      startRes, column, validRes, validEnd);
+              break;
+            }
+
+          case 'E':
+            if (!isRNA)
+            {
+              drawSheetAnnot(g, row_annotations, lastSSX, x, y, iconOffset,
+                      startRes, column, validRes, validEnd);
+              break;
+            }
+
+          case '(':
+          case ')': // Stem case for RNA secondary structure
 
             drawStemAnnot(g, row_annotations, lastSSX, x, y, iconOffset,
                     startRes, column, validRes, validEnd);
@@ -858,13 +876,11 @@ public class AnnotationRenderer
           case 'c':
           case 'D':
           case 'd':
-          case 'E':
           case 'e':
           case 'F':
           case 'f':
           case 'G':
           case 'g':
-          case 'H':
           case 'h':
           case 'I':
           case 'i':
@@ -1008,13 +1024,13 @@ public class AnnotationRenderer
     return !usedFaded;
   }
 
-  private final Color GLYPHLINE_COLOR = Color.gray;
+  public static final Color GLYPHLINE_COLOR = Color.gray;
 
-  private final Color SHEET_COLOUR = Color.green;
+  public static final Color SHEET_COLOUR = Color.green;
 
-  private final Color HELIX_COLOUR = Color.red;
+  public static final Color HELIX_COLOUR = Color.red;
 
-  private final Color STEM_COLOUR = Color.blue;
+  public static final Color STEM_COLOUR = Color.blue;
 
   private Color sdNOTCANONICAL_COLOUR;