Make sure annots are alignment width
[jalview.git] / src / jalview / io / AMSAFile.java
index 1f3fca0..e7e6d97 100644 (file)
@@ -45,9 +45,12 @@ public class AMSAFile
     AlignmentAnnotation aa;\r
     if (al.getAlignmentAnnotation() != null)\r
     {\r
+\r
       for (int i = 0; i < al.getAlignmentAnnotation().length; i++)\r
       {\r
         aa = al.getAlignmentAnnotation()[i];\r
+\r
+\r
         if (aa.autoCalculated || !aa.visible)\r
         {\r
           continue;\r
@@ -61,7 +64,8 @@ public class AMSAFile
 \r
         out.append("\n");\r
 \r
-        int nochunks = (aa.annotations.length / len) + 1;\r
+        int nochunks = Math.min(aa.annotations.length, al.getWidth())\r
+                        / len + 1;\r
 \r
         for (int j = 0; j < nochunks; j++)\r
         {\r