X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=bin%2Fjalview%2Fio%2FFastaFile.js;h=5dc3155d4d9267fe5afe9fef7fa5aba9835db1c9;hp=38f827fb3e17cab52f257357b9b7af426518d2f1;hb=7301a2415adab88038b291fc54caeeb3a5a47a44;hpb=6154cb57a6eac3bb1344b8342495f5bb701ee921 diff --git a/bin/jalview/io/FastaFile.js b/bin/jalview/io/FastaFile.js index 38f827f..5dc3155 100644 --- a/bin/jalview/io/FastaFile.js +++ b/bin/jalview/io/FastaFile.js @@ -1,94 +1,94 @@ -Clazz.declarePackage ("jalview.io"); -Clazz.load (["jalview.io.AlignFile"], "jalview.io.FastaFile", ["jalview.datamodel.AlignmentAnnotation", "$.Annotation", "java.lang.StringBuffer"], function () { -c$ = Clazz.decorateAsClass (function () { -this.len = 72; -this.out = null; -Clazz.instantialize (this, arguments); -}, jalview.io, "FastaFile", jalview.io.AlignFile); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, jalview.io.FastaFile, []); -}); -Clazz.overrideMethod (c$, "parse", -function () { -var sb = new StringBuffer (); -var firstLine = true; -var line; -var uline; -var seq = null; -var annotation = false; -while ((uline = this.nextLine ()) != null) { -line = uline.trim (); -if (line.length > 0) { -if (line.charAt (0) == '>') { -if (line.startsWith (">#_")) { -if (annotation) { -this.annotations.addElement (this.makeAnnotation (seq, sb)); -}} else { -annotation = false; -}if (!firstLine) { -seq.setSequence (sb.toString ()); -if (!annotation) { -this.seqs.addElement (seq); -}}seq = this.parseId (line.substring (1)); -firstLine = false; -sb = new StringBuffer (); -if (line.startsWith (">#_")) { -annotation = true; -}} else { -sb.append (annotation ? uline : line); -}}} -if (annotation) { -this.annotations.addElement (this.makeAnnotation (seq, sb)); -} else if (!firstLine) { -seq.setSequence (sb.toString ()); -this.seqs.addElement (seq); -}}); -Clazz.defineMethod (c$, "makeAnnotation", -($fz = function (seq, sb) { -var anots = new Array (sb.length ()); -var cb; -for (var i = 0; i < anots.length; i++) { -var cn = sb.charAt (i); -if (cn != ' ') { -anots[i] = new jalview.datamodel.Annotation ("" + cn, null, ' ', NaN); -}} -var aa = new jalview.datamodel.AlignmentAnnotation (seq.getName ().substring (2), seq.getDescription (), anots); -return aa; -}, $fz.isPrivate = true, $fz), "jalview.datamodel.SequenceI,StringBuffer"); -Clazz.defineMethod (c$, "addAnnotations", -function (al) { -this.addProperties (al); -for (var i = 0; i < this.annotations.size (); i++) { -var aa = this.annotations.elementAt (i); -aa.setPadGaps (true, al.getGapCharacter ()); -al.addAnnotation (aa); -} -}, "jalview.datamodel.Alignment"); -Clazz.defineMethod (c$, "print", -function (s) { -this.out = new StringBuffer (); -var i = 0; -while ((i < s.length) && (s[i] != null)) { -this.out.append (">" + this.printId (s[i])); -if (s[i].getDescription () != null) { -this.out.append (" " + s[i].getDescription ()); -}this.out.append (this.newline); -var nochunks = (Clazz.doubleToInt (s[i].getLength () / this.len)) + 1; -for (var j = 0; j < nochunks; j++) { -var start = j * this.len; -var end = start + this.len; -if (end < s[i].getLength ()) { -this.out.append (s[i].getSequenceAsString (start, end) + this.newline); -} else if (start < s[i].getLength ()) { -this.out.append (s[i].getSequenceAsString (start, s[i].getLength ()) + this.newline); -}} -i++; -} -return this.out.toString (); -}, "~A"); -Clazz.defineMethod (c$, "print", -function () { -return this.print (this.getSeqsAsArray ()); -}); -}); +Clazz.declarePackage ("jalview.io"); +Clazz.load (["jalview.io.AlignFile"], "jalview.io.FastaFile", ["jalview.datamodel.AlignmentAnnotation", "$.Annotation", "java.lang.StringBuffer"], function () { +c$ = Clazz.decorateAsClass (function () { +this.len = 72; +this.out = null; +Clazz.instantialize (this, arguments); +}, jalview.io, "FastaFile", jalview.io.AlignFile); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, jalview.io.FastaFile, []); +}); +Clazz.overrideMethod (c$, "parse", +function () { +var sb = new StringBuffer (); +var firstLine = true; +var line; +var uline; +var seq = null; +var annotation = false; +while ((uline = this.nextLine ()) != null) { +line = uline.trim (); +if (line.length > 0) { +if (line.charAt (0) == '>') { +if (line.startsWith (">#_")) { +if (annotation) { +this.annotations.addElement (this.makeAnnotation (seq, sb)); +}} else { +annotation = false; +}if (!firstLine) { +seq.setSequence (sb.toString ()); +if (!annotation) { +this.seqs.addElement (seq); +}}seq = this.parseId (line.substring (1)); +firstLine = false; +sb = new StringBuffer (); +if (line.startsWith (">#_")) { +annotation = true; +}} else { +sb.append (annotation ? uline : line); +}}} +if (annotation) { +this.annotations.addElement (this.makeAnnotation (seq, sb)); +} else if (!firstLine) { +seq.setSequence (sb.toString ()); +this.seqs.addElement (seq); +}}); +Clazz.defineMethod (c$, "makeAnnotation", +($fz = function (seq, sb) { +var anots = new Array (sb.length ()); +var cb; +for (var i = 0; i < anots.length; i++) { +var cn = sb.charAt (i); +if (cn != ' ') { +anots[i] = new jalview.datamodel.Annotation ("" + cn, null, ' ', NaN); +}} +var aa = new jalview.datamodel.AlignmentAnnotation (seq.getName ().substring (2), seq.getDescription (), anots); +return aa; +}, $fz.isPrivate = true, $fz), "jalview.datamodel.SequenceI,StringBuffer"); +Clazz.defineMethod (c$, "addAnnotations", +function (al) { +this.addProperties (al); +for (var i = 0; i < this.annotations.size (); i++) { +var aa = this.annotations.elementAt (i); +aa.setPadGaps (true, al.getGapCharacter ()); +al.addAnnotation (aa); +} +}, "jalview.datamodel.Alignment"); +Clazz.defineMethod (c$, "print", +function (s) { +this.out = new StringBuffer (); +var i = 0; +while ((i < s.length) && (s[i] != null)) { +this.out.append (">" + this.printId (s[i])); +if (s[i].getDescription () != null) { +this.out.append (" " + s[i].getDescription ()); +}this.out.append (this.newline); +var nochunks = (Clazz.doubleToInt (s[i].getLength () / this.len)) + 1; +for (var j = 0; j < nochunks; j++) { +var start = j * this.len; +var end = start + this.len; +if (end < s[i].getLength ()) { +this.out.append (s[i].getSequenceAsString (start, end) + this.newline); +} else if (start < s[i].getLength ()) { +this.out.append (s[i].getSequenceAsString (start, s[i].getLength ()) + this.newline); +}} +i++; +} +return this.out.toString (); +}, "~A"); +Clazz.defineMethod (c$, "print", +function () { +return this.print (this.getSeqsAsArray ()); +}); +});