ignores blank lines read in and write out
authoramwaterhouse <Andrew Waterhouse>
Fri, 27 May 2005 15:40:31 +0000 (15:40 +0000)
committeramwaterhouse <Andrew Waterhouse>
Fri, 27 May 2005 15:40:31 +0000 (15:40 +0000)
src/jalview/io/ClustalFile.java

index 4138a88..3594afa 100755 (executable)
@@ -60,7 +60,8 @@ public class ClustalFile extends AlignFile {
                  headers.addElement(id);\r
                }\r
 \r
-               tempseq.append(str.nextToken());\r
+                if(str.hasMoreTokens())\r
+                  tempseq.append(str.nextToken());\r
              }\r
            }\r
          }\r
@@ -123,6 +124,7 @@ public class ClustalFile extends AlignFile {
     return print(getSeqsAsArray());\r
   }\r
   public static String print(SequenceI[] s) {\r
+\r
     StringBuffer out = new StringBuffer("CLUSTAL\n\n");\r
 \r
     int max = 0;\r
@@ -156,18 +158,20 @@ public class ClustalFile extends AlignFile {
         int start = i*len;\r
         int end = start + len;\r
 \r
-        if (end < s[j].getSequence().length() && start < s[j].getSequence().length() ) {\r
-          out.append(s[j].getSequence().substring(start,end) + "\n");\r
-        } else {\r
-          if (start < s[j].getSequence().length()) {\r
-            out.append(s[j].getSequence().substring(start) + "\n");\r
-          }\r
+        if (end < s[j].getSequence().length() && start < s[j].getSequence().length() )\r
+          out.append(s[j].getSequence().substring(start,end));\r
+        else\r
+        {\r
+          if (start < s[j].getSequence().length())\r
+            out.append(s[j].getSequence().substring(start));\r
         }\r
+        out.append("\n");\r
         j++;\r
       }\r
       out.append("\n");\r
 \r
     }\r
+\r
     return out.toString();\r
   }\r
 \r