}\r
\r
public static String print(SequenceI[] s) {\r
- StringBuffer out = new StringBuffer("PileUp\n\n");\r
+ return print(s, false);\r
+ }\r
+ public static String print(SequenceI[] s, boolean is_NA) {\r
+ StringBuffer out = new StringBuffer("!!"+(is_NA ? "NA":"AA")+"_MULTIPLE_ALIGNMENT 1.0\n\n"); // TODO: JBPNote : Jalview doesn't remember NA or AA yet.\r
\r
int max = 0;\r
int maxid = 0;\r
-\r
int i = 0;\r
String big = "";\r
+\r
while (i < s.length && s[i] != null) {\r
- big += s[i].getSequence();\r
+ String sq;\r
+ big += (sq=s[i].getSequence());\r
+ if (sq.length() > max) {\r
+ max = sq.length();\r
+ }\r
i++;\r
}\r
+ Format maxLenpad = new Format("%"+(new String(""+max)).length()+"d");\r
+ Format maxChkpad = new Format("%"+(new String("1"+max)).length()+"d");\r
i = 0;\r
- int bigcheck = checkSum(big);\r
-\r
- out.append(" MSF: " + s[0].getSequence().length() + " Type: P Check: " + bigcheck + " ..\n\n\n");\r
-\r
+ long bigcheck = checkSum(big);\r
+ long maxNB=0;\r
+ out.append(" MSF: " + s[0].getSequence().length() + " Type: "+(is_NA?"N":"P")+" Check: " + bigcheck + " ..\n\n\n");\r
+ String nameBlock[] = new String[s.length];\r
+ String idBlock[] = new String[s.length];\r
while (i < s.length && s[i] != null) {\r
String seq = s[i].getSequence();\r
String name = s[i].getName()+ "/" + s[i].getStart() + "-" + s[i].getEnd();\r
int check = checkSum(s[i].getSequence());\r
- out.append(" Name: " + name + " oo Len: " + s[i].getSequence().length() + " Check: " + check + " Weight: 1.00\n");\r
- if (seq.length() > max) {\r
- max = seq.length();\r
- }\r
+ nameBlock[i]=new String(" Name: "+name+" ");\r
+ idBlock[i] = new String("Len: " + maxLenpad.form(s[i].getSequence().length()) + " Check:" + maxChkpad.form(check) + " Weight: 1.00\n");\r
+\r
if (name.length() > maxid) {\r
maxid = name.length();\r
}\r
+ if (nameBlock[i].length()>maxNB) {\r
+ maxNB=nameBlock[i].length();\r
+ }\r
+\r
i++;\r
}\r
-\r
if (maxid < 10) {\r
maxid = 10;\r
}\r
+ if (maxNB<15) {\r
+ maxNB=15;\r
+ }\r
+ Format nbFormat = new Format("%-"+maxNB+"s");\r
+ for (i=0;i<s.length && s[i]!=null;i++) {\r
+ out.append(nbFormat.form(nameBlock[i])+idBlock[i]);\r
+ }\r
maxid++;\r
out.append( "\n\n//\n\n");\r
\r