X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=bin%2Fjalview%2Fio%2FPileUpfile.js;h=a6effa102b904217dc1a06d4558dd2e5b37f4fba;hp=b8bb68ccfddf8a86319de1a9eabab7bcbe474b6f;hb=7301a2415adab88038b291fc54caeeb3a5a47a44;hpb=6154cb57a6eac3bb1344b8342495f5bb701ee921 diff --git a/bin/jalview/io/PileUpfile.js b/bin/jalview/io/PileUpfile.js index b8bb68c..a6effa1 100644 --- a/bin/jalview/io/PileUpfile.js +++ b/bin/jalview/io/PileUpfile.js @@ -1,82 +1,82 @@ -Clazz.declarePackage ("jalview.io"); -Clazz.load (["jalview.io.MSFfile"], "jalview.io.PileUpfile", ["jalview.util.Format", "java.lang.StringBuffer"], function () { -c$ = Clazz.declareType (jalview.io, "PileUpfile", jalview.io.MSFfile); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, jalview.io.PileUpfile, []); -}); -Clazz.defineMethod (c$, "print", -function () { -return this.print (this.getSeqsAsArray ()); -}); -Clazz.defineMethod (c$, "print", -function (s) { -var out = new StringBuffer ("PileUp"); -out.append (this.newline); -out.append (this.newline); -var max = 0; -var maxid = 0; -var i = 0; -var bigChecksum = 0; -var checksums = Clazz.newIntArray (s.length, 0); -while (i < s.length) { -checksums[i] = this.checkSum (s[i].getSequenceAsString ()); -bigChecksum += checksums[i]; -i++; -} -out.append (" MSF: " + s[0].getSequence ().length + " Type: P Check: " + bigChecksum % 10000 + " .."); -out.append (this.newline); -out.append (this.newline); -out.append (this.newline); -i = 0; -while ((i < s.length) && (s[i] != null)) { -var seq = s[i].getSequenceAsString (); -out.append (" Name: " + this.printId (s[i]) + " oo Len: " + seq.length + " Check: " + checksums[i] + " Weight: 1.00"); -out.append (this.newline); -if (seq.length > max) { -max = seq.length; -}if (s[i].getName ().length > maxid) { -maxid = s[i].getName ().length; -}i++; -} -if (maxid < 10) { -maxid = 10; -}maxid++; -out.append (this.newline); -out.append (this.newline); -out.append ("//"); -out.append (this.newline); -out.append (this.newline); -var len = 50; -var nochunks = (Clazz.doubleToInt (max / len)) + 1; -if ((max % len) == 0) { -nochunks--; -}for (i = 0; i < nochunks; i++) { -var j = 0; -while ((j < s.length) && (s[j] != null)) { -var name = this.printId (s[j]); -out.append ( new jalview.util.Format ("%-" + maxid + "s").form (name + " ")); -for (var k = 0; k < 5; k++) { -var start = (i * 50) + (k * 10); -var end = start + 10; -if ((end < s[j].getSequence ().length) && (start < s[j].getSequence ().length)) { -out.append (s[j].getSequence (start, end)); -if (k < 4) { -out.append (" "); -} else { -out.append (this.newline); -}} else { -if (start < s[j].getSequence ().length) { -out.append (s[j].getSequenceAsString ().substring (start)); -out.append (this.newline); -} else { -if (k == 0) { -out.append (this.newline); -}}}} -j++; -} -out.append (this.newline); -} -return out.toString (); -}, "~A"); -}); +Clazz.declarePackage ("jalview.io"); +Clazz.load (["jalview.io.MSFfile"], "jalview.io.PileUpfile", ["jalview.util.Format", "java.lang.StringBuffer"], function () { +c$ = Clazz.declareType (jalview.io, "PileUpfile", jalview.io.MSFfile); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, jalview.io.PileUpfile, []); +}); +Clazz.defineMethod (c$, "print", +function () { +return this.print (this.getSeqsAsArray ()); +}); +Clazz.defineMethod (c$, "print", +function (s) { +var out = new StringBuffer ("PileUp"); +out.append (this.newline); +out.append (this.newline); +var max = 0; +var maxid = 0; +var i = 0; +var bigChecksum = 0; +var checksums = Clazz.newIntArray (s.length, 0); +while (i < s.length) { +checksums[i] = this.checkSum (s[i].getSequenceAsString ()); +bigChecksum += checksums[i]; +i++; +} +out.append (" MSF: " + s[0].getSequence ().length + " Type: P Check: " + bigChecksum % 10000 + " .."); +out.append (this.newline); +out.append (this.newline); +out.append (this.newline); +i = 0; +while ((i < s.length) && (s[i] != null)) { +var seq = s[i].getSequenceAsString (); +out.append (" Name: " + this.printId (s[i]) + " oo Len: " + seq.length + " Check: " + checksums[i] + " Weight: 1.00"); +out.append (this.newline); +if (seq.length > max) { +max = seq.length; +}if (s[i].getName ().length > maxid) { +maxid = s[i].getName ().length; +}i++; +} +if (maxid < 10) { +maxid = 10; +}maxid++; +out.append (this.newline); +out.append (this.newline); +out.append ("//"); +out.append (this.newline); +out.append (this.newline); +var len = 50; +var nochunks = (Clazz.doubleToInt (max / len)) + 1; +if ((max % len) == 0) { +nochunks--; +}for (i = 0; i < nochunks; i++) { +var j = 0; +while ((j < s.length) && (s[j] != null)) { +var name = this.printId (s[j]); +out.append ( new jalview.util.Format ("%-" + maxid + "s").form (name + " ")); +for (var k = 0; k < 5; k++) { +var start = (i * 50) + (k * 10); +var end = start + 10; +if ((end < s[j].getSequence ().length) && (start < s[j].getSequence ().length)) { +out.append (s[j].getSequence (start, end)); +if (k < 4) { +out.append (" "); +} else { +out.append (this.newline); +}} else { +if (start < s[j].getSequence ().length) { +out.append (s[j].getSequenceAsString ().substring (start)); +out.append (this.newline); +} else { +if (k == 0) { +out.append (this.newline); +}}}} +j++; +} +out.append (this.newline); +} +return out.toString (); +}, "~A"); +});