GPL license added
[jalview.git] / src / jalview / io / ClustalFile.java
index 4138a88..9b56526 100755 (executable)
@@ -1,3 +1,22 @@
+/*\r
+* Jalview - A Sequence Alignment Editor and Viewer\r
+* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+*\r
+* This program is free software; you can redistribute it and/or\r
+* modify it under the terms of the GNU General Public License\r
+* as published by the Free Software Foundation; either version 2\r
+* of the License, or (at your option) any later version.\r
+*\r
+* This program is distributed in the hope that it will be useful,\r
+* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+* GNU General Public License for more details.\r
+*\r
+* You should have received a copy of the GNU General Public License\r
+* along with this program; if not, write to the Free Software\r
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
+*/\r
+\r
 package jalview.io;\r
 \r
 import jalview.datamodel.*;\r
@@ -60,7 +79,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 +143,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 +177,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