Use StringBUffer instead of String
authoramwaterhouse <Andrew Waterhouse>
Thu, 10 Nov 2005 11:01:23 +0000 (11:01 +0000)
committeramwaterhouse <Andrew Waterhouse>
Thu, 10 Nov 2005 11:01:23 +0000 (11:01 +0000)
src/jalview/analysis/AlignSeq.java

index 7be4120..9d8f008 100755 (executable)
@@ -94,7 +94,7 @@ public class AlignSeq
     int[][] lookup = ResidueProperties.getBLOSUM62();\r
     String[] intToStr = pep;\r
     int defInt = 23;\r
-    String output = "";\r
+    StringBuffer output = new StringBuffer();\r
     String type;\r
     Runtime rt;\r
 \r
@@ -169,7 +169,7 @@ public class AlignSeq
      */\r
     public String getOutput()\r
     {\r
-        return output;\r
+        return output.toString();\r
     }\r
 \r
     /**\r
@@ -263,7 +263,7 @@ public class AlignSeq
         }\r
         else\r
         {\r
-            output = output + ("Wrong type = dna or pep only");\r
+            output.append("Wrong type = dna or pep only");\r
             System.exit(0);\r
         }\r
 \r
@@ -420,39 +420,33 @@ public class AlignSeq
         int nochunks = ((aseq1.length - count) / len) + 1;\r
         pid = 0;\r
 \r
-        output = output + ("Score = " + score[maxi][maxj] + "\n");\r
-        output = output +\r
-            ("Length of alignment = " + (aseq1.length - count) + "\n");\r
-        output = output + ("Sequence ");\r
-        output = output + (new Format("%" + maxid + "s").form(s1.getName()));\r
-        output = output +\r
-            (" :  " + seq1start + " - " + seq1end + " (Sequence length = " +\r
+        output.append("Score = " + score[maxi][maxj] + "\n");\r
+        output.append("Length of alignment = " + (aseq1.length - count) + "\n");\r
+        output.append("Sequence ");\r
+        output.append(new Format("%" + maxid + "s").form(s1.getName()));\r
+        output.append(" :  " + seq1start + " - " + seq1end + " (Sequence length = " +\r
             s1str.length() + ")\n");\r
-        output = output + ("Sequence ");\r
-        output = output + (new Format("%" + maxid + "s").form(s2.getName()));\r
-        output = output +\r
-            (" :  " + seq2start + " - " + seq2end + " (Sequence length = " +\r
+        output .append("Sequence ");\r
+        output.append(new Format("%" + maxid + "s").form(s2.getName()));\r
+        output .append(" :  " + seq2start + " - " + seq2end + " (Sequence length = " +\r
             s2str.length() + ")\n\n");\r
 \r
         for (int j = 0; j < nochunks; j++)\r
         {\r
             // Print the first aligned sequence\r
-            output = output +\r
-                (new Format("%" + (maxid) + "s").form(s1.getName()) + " ");\r
+            output.append(new Format("%" + (maxid) + "s").form(s1.getName()) + " ");\r
 \r
             for (int i = 0; i < len; i++)\r
             {\r
                 if ((count + i + (j * len)) < aseq1.length)\r
                 {\r
-                    output = output +\r
-                        (new Format("%s").form(intToStr[aseq1[count + i +\r
+                    output.append(new Format("%s").form(intToStr[aseq1[count + i +\r
                             (j * len)]]));\r
                 }\r
             }\r
 \r
-            output = output + ("\n");\r
-            output = output +\r
-                (new Format("%" + (maxid) + "s").form(" ") + " ");\r
+            output.append("\n");\r
+            output.append(new Format("%" + (maxid) + "s").form(" ") + " ");\r
 \r
             // Print out the matching chars\r
             for (int i = 0; i < len; i++)\r
@@ -464,7 +458,7 @@ public class AlignSeq
                             !intToStr[aseq1[count + i + (j * len)]].equals("-"))\r
                     {\r
                         pid++;\r
-                        output = output + ("|");\r
+                        output.append("|");\r
                     }\r
                     else if (type.equals("pep"))\r
                     {\r
@@ -472,40 +466,40 @@ public class AlignSeq
                                     intToStr[aseq1[count + i + (j * len)]],\r
                                     intToStr[aseq2[count + i + (j * len)]]) > 0)\r
                         {\r
-                            output = output + (".");\r
+                            output.append(".");\r
                         }\r
                         else\r
                         {\r
-                            output = output + (" ");\r
+                            output.append(" ");\r
                         }\r
                     }\r
                     else\r
                     {\r
-                        output = output + (" ");\r
+                        output.append(" ");\r
                     }\r
                 }\r
             }\r
 \r
             // Now print the second aligned sequence\r
-            output = output + ("\n");\r
-            output = output +\r
-                (new Format("%" + (maxid) + "s").form(s2.getName()) + " ");\r
+            output = output.append("\n");\r
+            output = output.append(new Format("%" + (maxid) + "s").form(s2.getName()) + " ");\r
 \r
             for (int i = 0; i < len; i++)\r
             {\r
                 if ((count + i + (j * len)) < aseq1.length)\r
                 {\r
-                    output = output +\r
-                        (new Format("%s").form(intToStr[aseq2[count + i +\r
+                    output .append(new Format("%s").form(intToStr[aseq2[count + i +\r
                             (j * len)]]));\r
                 }\r
             }\r
 \r
-            output = output + ("\n\n");\r
+            output = output .append("\n\n");\r
         }\r
 \r
         pid = pid / (float) (aseq1.length - count) * 100;\r
-        output = output + (new Format("Percentage ID = %2.2f\n\n").form(pid));\r
+        output = output.append(new Format("Percentage ID = %2.2f\n\n").form(pid));\r
+\r
+        System.out.println(output.toString());\r
     }\r
 \r
     /**\r