From: amwaterhouse Date: Thu, 10 Nov 2005 11:01:23 +0000 (+0000) Subject: Use StringBUffer instead of String X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=246969832c1cfb30e97e0ee181fa9471dee59107;p=jalview.git Use StringBUffer instead of String --- diff --git a/src/jalview/analysis/AlignSeq.java b/src/jalview/analysis/AlignSeq.java index 7be4120..9d8f008 100755 --- a/src/jalview/analysis/AlignSeq.java +++ b/src/jalview/analysis/AlignSeq.java @@ -94,7 +94,7 @@ public class AlignSeq int[][] lookup = ResidueProperties.getBLOSUM62(); String[] intToStr = pep; int defInt = 23; - String output = ""; + StringBuffer output = new StringBuffer(); String type; Runtime rt; @@ -169,7 +169,7 @@ public class AlignSeq */ public String getOutput() { - return output; + return output.toString(); } /** @@ -263,7 +263,7 @@ public class AlignSeq } else { - output = output + ("Wrong type = dna or pep only"); + output.append("Wrong type = dna or pep only"); System.exit(0); } @@ -420,39 +420,33 @@ public class AlignSeq int nochunks = ((aseq1.length - count) / len) + 1; pid = 0; - output = output + ("Score = " + score[maxi][maxj] + "\n"); - output = output + - ("Length of alignment = " + (aseq1.length - count) + "\n"); - output = output + ("Sequence "); - output = output + (new Format("%" + maxid + "s").form(s1.getName())); - output = output + - (" : " + seq1start + " - " + seq1end + " (Sequence length = " + + output.append("Score = " + score[maxi][maxj] + "\n"); + output.append("Length of alignment = " + (aseq1.length - count) + "\n"); + output.append("Sequence "); + output.append(new Format("%" + maxid + "s").form(s1.getName())); + output.append(" : " + seq1start + " - " + seq1end + " (Sequence length = " + s1str.length() + ")\n"); - output = output + ("Sequence "); - output = output + (new Format("%" + maxid + "s").form(s2.getName())); - output = output + - (" : " + seq2start + " - " + seq2end + " (Sequence length = " + + output .append("Sequence "); + output.append(new Format("%" + maxid + "s").form(s2.getName())); + output .append(" : " + seq2start + " - " + seq2end + " (Sequence length = " + s2str.length() + ")\n\n"); for (int j = 0; j < nochunks; j++) { // Print the first aligned sequence - output = output + - (new Format("%" + (maxid) + "s").form(s1.getName()) + " "); + output.append(new Format("%" + (maxid) + "s").form(s1.getName()) + " "); for (int i = 0; i < len; i++) { if ((count + i + (j * len)) < aseq1.length) { - output = output + - (new Format("%s").form(intToStr[aseq1[count + i + + output.append(new Format("%s").form(intToStr[aseq1[count + i + (j * len)]])); } } - output = output + ("\n"); - output = output + - (new Format("%" + (maxid) + "s").form(" ") + " "); + output.append("\n"); + output.append(new Format("%" + (maxid) + "s").form(" ") + " "); // Print out the matching chars for (int i = 0; i < len; i++) @@ -464,7 +458,7 @@ public class AlignSeq !intToStr[aseq1[count + i + (j * len)]].equals("-")) { pid++; - output = output + ("|"); + output.append("|"); } else if (type.equals("pep")) { @@ -472,40 +466,40 @@ public class AlignSeq intToStr[aseq1[count + i + (j * len)]], intToStr[aseq2[count + i + (j * len)]]) > 0) { - output = output + ("."); + output.append("."); } else { - output = output + (" "); + output.append(" "); } } else { - output = output + (" "); + output.append(" "); } } } // Now print the second aligned sequence - output = output + ("\n"); - output = output + - (new Format("%" + (maxid) + "s").form(s2.getName()) + " "); + output = output.append("\n"); + output = output.append(new Format("%" + (maxid) + "s").form(s2.getName()) + " "); for (int i = 0; i < len; i++) { if ((count + i + (j * len)) < aseq1.length) { - output = output + - (new Format("%s").form(intToStr[aseq2[count + i + + output .append(new Format("%s").form(intToStr[aseq2[count + i + (j * len)]])); } } - output = output + ("\n\n"); + output = output .append("\n\n"); } pid = pid / (float) (aseq1.length - count) * 100; - output = output + (new Format("Percentage ID = %2.2f\n\n").form(pid)); + output = output.append(new Format("Percentage ID = %2.2f\n\n").form(pid)); + + System.out.println(output.toString()); } /**