Merge branch 'Release_2_8_0b1_Branch' into try_r20b1_merge
[jalview.git] / src / jalview / schemes / RNAHelicesColourChooser.java
index 1edca4b..45c374d 100644 (file)
@@ -98,8 +98,24 @@ public class RNAHelicesColourChooser
       return;
     }
 
-    currentAnnotation = av.getAlignment().getAlignmentAnnotation()[0];// annotations.getSelectedIndex()];
-
+    // This loop will find the first rna structure annotation by which to colour
+    //  the sequences.
+    AlignmentAnnotation[] annotations = av.getAlignment().getAlignmentAnnotation();
+    for (int i = 0; i < annotations.length; i++) {
+       
+       // is this a sensible way of determining type of annotation?
+       if (annotations[i].getRNAStruc() != null) { 
+               currentAnnotation = annotations[i];
+               break;
+       }
+    }
+    if (currentAnnotation == null)   
+    {
+       System.err.println("Jalview is about to try and colour by RNAHelices even"
+                       + " though there are no RNA secondary structure annotations present!");
+       currentAnnotation = av.getAlignment().getAlignmentAnnotation()[0];// annotations.getSelectedIndex()];
+    }
+    
     RNAHelicesColour rhc = null;
 
     rhc = new RNAHelicesColour(currentAnnotation);