X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fanalysis%2FAlignSeq.java;h=401ad01c22b7a9377201b65858544131c46d60bc;hb=6fc9aca27f606f6e3a0121597896e1a5dae35c36;hp=60ad85c7a30678cb1e9faa98edadf007d5df0660;hpb=efc31b4a8d5cee63555586804a2b79c06bdb5a14;p=jalview.git diff --git a/src/jalview/analysis/AlignSeq.java b/src/jalview/analysis/AlignSeq.java index 60ad85c..401ad01 100755 --- a/src/jalview/analysis/AlignSeq.java +++ b/src/jalview/analysis/AlignSeq.java @@ -69,8 +69,8 @@ public class AlignSeq int maxj; int[] aseq1; int[] aseq2; - String astr1 = ""; - String astr2 = ""; + public String astr1 = ""; + public String astr2 = ""; /** DOCUMENT ME!! */ public int seq1start; @@ -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); } @@ -406,7 +406,7 @@ public class AlignSeq /** * DOCUMENT ME! */ - public void printAlignment() + public void printAlignment(java.io.PrintStream os) { // Find the biggest id length for formatting purposes int maxid = s1.getName().length(); @@ -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,42 @@ 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)); + + try{ + os.print(output.toString()); + }catch(Exception ex){} } /** @@ -659,14 +655,14 @@ public class AlignSeq public static String extractGaps(String gapChar, String seq) { StringTokenizer str = new StringTokenizer(seq, gapChar); - String newString = ""; + StringBuffer newString = new StringBuffer(); while (str.hasMoreTokens()) { - newString = newString + str.nextToken(); + newString.append( str.nextToken() ); } - return newString; + return newString.toString(); } /**