reinstating class implementation.
[jalview.git] / src / jalview / io / FastaFile.java
index 75915c1..fe5e02f 100755 (executable)
@@ -33,6 +33,13 @@ import java.util.*;
  */\r
 public class FastaFile extends AlignFile\r
 {\r
+  /**\r
+   * Length of a sequence line\r
+   */\r
+  int len = 72;\r
+\r
+  StringBuffer out;\r
+\r
     /**\r
      * Creates a new FastaFile object.\r
      */\r
@@ -80,9 +87,10 @@ public class FastaFile extends AlignFile
                     if (annotation)\r
                     {\r
                       Annotation[] anots = new Annotation[sb.length()];\r
+                      String anotString = sb.toString();\r
                       for (int i = 0; i < sb.length(); i++)\r
                       {\r
-                        anots[i] = new Annotation(sb.substring(i, i+1),\r
+                        anots[i] = new Annotation(anotString.substring(i, i+1),\r
                                                   null,\r
                                                   ' ', 0);\r
                       }\r
@@ -90,9 +98,8 @@ public class FastaFile extends AlignFile
                           seq.getName().substring(2), seq.getDescription(),\r
                           anots);\r
 \r
-                      annotations.add(aa);\r
+                      annotations.addElement(aa);\r
                     }\r
-                    annotation = true;\r
                   }\r
                   else\r
                     annotation = false;\r
@@ -116,6 +123,9 @@ public class FastaFile extends AlignFile
                     firstLine = false;\r
 \r
                     sb = new StringBuffer();\r
+\r
+                    if (line.startsWith(">#_"))\r
+                      annotation = true;\r
                 }\r
                 else\r
                 {\r
@@ -127,9 +137,10 @@ public class FastaFile extends AlignFile
         if (annotation)\r
         {\r
           Annotation[] anots = new Annotation[sb.length()];\r
+          String anotString = sb.toString();\r
           for (int i = 0; i < sb.length(); i++)\r
           {\r
-            anots[i] = new Annotation(sb.substring(i, i + 1),\r
+            anots[i] = new Annotation(anotString.substring(i, i + 1),\r
                                       null,\r
                                       ' ', 0);\r
           }\r
@@ -137,7 +148,7 @@ public class FastaFile extends AlignFile
               seq.getName().substring(2), seq.getDescription(),\r
               anots);\r
 \r
-          annotations.add(aa);\r
+          annotations.addElement(aa);\r
         }\r
 \r
         else if (!firstLine)\r
@@ -155,7 +166,6 @@ public class FastaFile extends AlignFile
         }\r
     }\r
 \r
-\r
     /**\r
      * DOCUMENT ME!\r
      *\r
@@ -168,8 +178,7 @@ public class FastaFile extends AlignFile
      */\r
     public String print(SequenceI[] s)\r
     {\r
-        int len = 72;\r
-        StringBuffer out = new StringBuffer();\r
+        out = new StringBuffer();\r
         int i = 0;\r
 \r
         while ((i < s.length) && (s[i] != null))\r