Make sure annots are alignment width
[jalview.git] / src / jalview / gui / AlignFrame.java
index b27a98e..58650cb 100755 (executable)
@@ -3088,12 +3088,17 @@ public class AlignFrame
       sortByAnnotScore.removeAll();
       // almost certainly a quicker way to do this - but we keep it simple
       Hashtable scoreSorts=new Hashtable();
-      AlignmentAnnotation aann[] = viewport.alignment.getAlignmentAnnotation();
-      for (int i=0;i<aann.length; i++)
+      AlignmentAnnotation aann[];
+      Enumeration sq = viewport.alignment.getSequences().elements();
+      while (sq.hasMoreElements())
       {
-        if (aann[i].hasScore() && aann[i].sequenceRef!=null)
+        aann = ((SequenceI) sq.nextElement()).getAnnotation();
+        for (int i=0;aann!=null && i<aann.length; i++)
         {
-          scoreSorts.put(aann[i].label, aann[i].label);
+          if (aann[i].hasScore() && aann[i].sequenceRef!=null)
+          {
+            scoreSorts.put(aann[i].label, aann[i].label);
+          }
         }
       }
       Enumeration labels = scoreSorts.keys();