Annotations must createSequenceMapping if seqRef not null
authoramwaterhouse <Andrew Waterhouse>
Wed, 10 May 2006 12:57:21 +0000 (12:57 +0000)
committeramwaterhouse <Andrew Waterhouse>
Wed, 10 May 2006 12:57:21 +0000 (12:57 +0000)
src/jalview/io/AnnotationReader.java
src/jalview/ws/JPredClient.java

index 4325dae..d42167a 100755 (executable)
@@ -35,11 +35,13 @@ public class AnnotationReader
       String line, label, description, token;\r
       int graphStyle, index;\r
       SequenceI refSeq = null;\r
-      int refSeqIndex = 0;\r
+      int refSeqIndex = 1;\r
       int existingAnnotations = 0;\r
       if(al.getAlignmentAnnotation()!=null)\r
        existingAnnotations = al.getAlignmentAnnotation().length;\r
 \r
+      int alWidth = al.getWidth();\r
+\r
       StringTokenizer st;\r
       Annotation[] annotations;\r
       AlignmentAnnotation annotation = null;\r
@@ -100,28 +102,32 @@ public class AnnotationReader
           }\r
           catch(Exception ex)\r
           {\r
-            refSeqIndex = 0;\r
+            refSeqIndex = 1;\r
           }\r
 \r
           continue;\r
         }\r
 \r
+\r
         graphStyle = AlignmentAnnotation.getGraphValueFromString(token);\r
         label = description = st.nextToken();\r
 \r
         line = st.nextToken();\r
+\r
         st = new StringTokenizer(line, "|", true);\r
-        annotations = new Annotation[st.countTokens()+refSeqIndex];\r
-        index = refSeqIndex;\r
+        annotations = new Annotation[alWidth];\r
+\r
+        index = 0;\r
         boolean emptyColumn = true;\r
-        while (st.hasMoreElements())\r
+\r
+\r
+        while (st.hasMoreElements() && index<alWidth)\r
         {\r
           token = st.nextToken().trim();\r
-\r
           if(token.equals("|"))\r
           {\r
             if(emptyColumn)\r
-              annotations[index++] = parseAnnotation("");\r
+              index++;\r
 \r
             emptyColumn = true;\r
           }\r
@@ -139,12 +145,16 @@ public class AnnotationReader
                                           0,\r
                                           graphStyle);\r
 \r
-       annotation = al.addAnnotation(annotation, refSeq);\r
-       al.setAnnotationIndex(annotation,  al.getAlignmentAnnotation().length - existingAnnotations-1);\r
-      }\r
+       if(refSeq!=null)\r
+       {\r
+         annotation.createSequenceMapping(refSeq, refSeqIndex);\r
+         refSeq.addAlignmentAnnotation(annotation);\r
+       }\r
 \r
-       al.adjustSequenceAnnotations();\r
+       al.addAnnotation(annotation);\r
 \r
+       al.setAnnotationIndex(annotation,  al.getAlignmentAnnotation().length - existingAnnotations-1);\r
+      }\r
 \r
     }catch(Exception ex)\r
     {\r
index 8a4368c..2d49ac6 100755 (executable)
@@ -515,7 +515,14 @@ public class JPredClient
                                               "JNet Output", annotations);\r
             }\r
 \r
-            al.addAnnotation(annot, seqRef);\r
+            if (seqRef != null)\r
+            {\r
+              annot.createSequenceMapping(seqRef, 0);\r
+              seqRef.addAlignmentAnnotation(annot);\r
+            }\r
+\r
+            al.addAnnotation(annot);\r
+\r
 \r
             if (noMsa)\r
             {\r