patch and error reports re JAL-554
authorjprocter <Jim Procter>
Thu, 3 Jun 2010 15:12:42 +0000 (15:12 +0000)
committerjprocter <Jim Procter>
Thu, 3 Jun 2010 15:12:42 +0000 (15:12 +0000)
src/jalview/io/AnnotationFile.java

index aeaf2f3..2721fb2 100755 (executable)
@@ -982,45 +982,55 @@ public class AnnotationFile
     int graphGroup = -1;\r
     String group = st.nextToken();\r
     // First make sure we are not overwriting the graphIndex\r
-    for (int i = 0; i < al.getAlignmentAnnotation().length; i++)\r
-    {\r
-      if (al.getAlignmentAnnotation()[i].label.equalsIgnoreCase(group))\r
-      {\r
-        graphGroup = al.getAlignmentAnnotation()[i].graphGroup + 1;\r
-        al.getAlignmentAnnotation()[i].graphGroup = graphGroup;\r
-        break;\r
-      }\r
-    }\r
-\r
-    // Now update groups\r
-    while (st.hasMoreTokens())\r
+    if (al.getAlignmentAnnotation() != null)\r
     {\r
-      group = st.nextToken();\r
       for (int i = 0; i < al.getAlignmentAnnotation().length; i++)\r
       {\r
         if (al.getAlignmentAnnotation()[i].label.equalsIgnoreCase(group))\r
         {\r
+          graphGroup = al.getAlignmentAnnotation()[i].graphGroup + 1;\r
           al.getAlignmentAnnotation()[i].graphGroup = graphGroup;\r
           break;\r
         }\r
       }\r
+\r
+      // Now update groups\r
+      while (st.hasMoreTokens())\r
+      {\r
+        group = st.nextToken();\r
+        for (int i = 0; i < al.getAlignmentAnnotation().length; i++)\r
+        {\r
+          if (al.getAlignmentAnnotation()[i].label.equalsIgnoreCase(group))\r
+          {\r
+            al.getAlignmentAnnotation()[i].graphGroup = graphGroup;\r
+            break;\r
+          }\r
+        }\r
+      }\r
+    }\r
+    else\r
+    {\r
+      System.err\r
+              .println("Couldn't combine annotations. None are added to alignment yet!");\r
     }\r
   }\r
 \r
   void addLine(AlignmentI al, StringTokenizer st)\r
   {\r
     String group = st.nextToken();\r
-    AlignmentAnnotation annotation = null;\r
-\r
-    for (int i = 0; i < al.getAlignmentAnnotation().length; i++)\r
+    AlignmentAnnotation annotation = null, alannot[] = al\r
+            .getAlignmentAnnotation();\r
+    if (alannot != null)\r
     {\r
-      if (al.getAlignmentAnnotation()[i].label.equalsIgnoreCase(group))\r
+      for (int i = 0; i < alannot.length; i++)\r
       {\r
-        annotation = al.getAlignmentAnnotation()[i];\r
-        break;\r
+        if (alannot[i].label.equalsIgnoreCase(group))\r
+        {\r
+          annotation = alannot[i];\r
+          break;\r
+        }\r
       }\r
     }\r
-\r
     if (annotation == null)\r
     {\r
       return;\r
@@ -1153,13 +1163,16 @@ public class AnnotationFile
         centerlab = Boolean.valueOf(value).booleanValue();\r
       }\r
       AlignmentAnnotation[] alr = al.getAlignmentAnnotation();\r
-      for (int i = 0; i < alr.length; i++)\r
+      if (alr != null)\r
       {\r
-        if (alr[i].label.equalsIgnoreCase(label))\r
+        for (int i = 0; i < alr.length; i++)\r
         {\r
-          alr[i].centreColLabels = centerlab;\r
-          alr[i].scaleColLabel = scaletofit;\r
-          alr[i].showAllColLabels = showalllabs;\r
+          if (alr[i].label.equalsIgnoreCase(label))\r
+          {\r
+            alr[i].centreColLabels = centerlab;\r
+            alr[i].scaleColLabel = scaletofit;\r
+            alr[i].showAllColLabels = showalllabs;\r
+          }\r
         }\r
       }\r
     }\r
@@ -1290,19 +1303,35 @@ public class AnnotationFile
   void setBelowAlignment(AlignmentI al, StringTokenizer st)\r
   {\r
     String token;\r
-    AlignmentAnnotation aa;\r
+    AlignmentAnnotation aa, ala[] = al.getAlignmentAnnotation();\r
+    if (ala == null)\r
+    {\r
+      System.err\r
+              .print("Warning - no annotation to set below for sequence associated annotation:");\r
+    }\r
     while (st.hasMoreTokens())\r
     {\r
       token = st.nextToken();\r
-      for (int i = 0; i < al.getAlignmentAnnotation().length; i++)\r
+      if (ala == null)\r
+      {\r
+        System.err.print(" "+token);\r
+      }\r
+      else\r
       {\r
-        aa = al.getAlignmentAnnotation()[i];\r
-        if (aa.sequenceRef == refSeq && aa.label.equals(token))\r
+        for (int i = 0; i < al.getAlignmentAnnotation().length; i++)\r
         {\r
-          aa.belowAlignment = true;\r
+          aa = al.getAlignmentAnnotation()[i];\r
+          if (aa.sequenceRef == refSeq && aa.label.equals(token))\r
+          {\r
+            aa.belowAlignment = true;\r
+          }\r
         }\r
       }\r
     }\r
+    if (ala==null)\r
+    {\r
+      System.err.print("\n");\r
+    }\r
   }\r
 \r
   void addAlignmentDetails(AlignmentI al, StringTokenizer st)\r