X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=bin%2Fjalview%2Fviewmodel%2FPCAModel.js;h=75279350d3665da6b149d999dcada5b6c5c91e6f;hp=cdb986834609f778bfc520aeb32478049959b76a;hb=8ffd05b3abe52c0b6b79b011c0966361f82d5fe6;hpb=6154cb57a6eac3bb1344b8342495f5bb701ee921 diff --git a/bin/jalview/viewmodel/PCAModel.js b/bin/jalview/viewmodel/PCAModel.js index cdb9868..7527935 100644 --- a/bin/jalview/viewmodel/PCAModel.js +++ b/bin/jalview/viewmodel/PCAModel.js @@ -1,134 +1,134 @@ -Clazz.declarePackage ("jalview.viewmodel"); -Clazz.load (null, "jalview.viewmodel.PCAModel", ["jalview.analysis.PCA", "jalview.datamodel.SequencePoint", "java.lang.StringBuffer", "java.util.Vector"], function () { -c$ = Clazz.decorateAsClass (function () { -this.pca = null; -this.top = 0; -this.seqstrings = null; -this.seqs = null; -this.score_matrix = null; -this.nucleotide = false; -this.points = null; -this.jvCalcMode = true; -Clazz.instantialize (this, arguments); -}, jalview.viewmodel, "PCAModel"); -Clazz.makeConstructor (c$, -function (seqstrings2, seqs2, nucleotide2) { -this.seqstrings = seqstrings2; -this.seqs = seqs2; -this.nucleotide = nucleotide2; -this.score_matrix = nucleotide2 ? "PID" : "BLOSUM62"; -}, "jalview.datamodel.AlignmentView,~A,~B"); -Clazz.defineMethod (c$, "isJvCalcMode", -function () { -return this.jvCalcMode; -}); -Clazz.defineMethod (c$, "run", -function () { -this.pca = new jalview.analysis.PCA (this.seqstrings.getSequenceStrings (' '), this.nucleotide, this.score_matrix); -this.pca.setJvCalcMode (this.jvCalcMode); -this.pca.run (); -var ii = 0; -while ((ii < this.seqs.length) && (this.seqs[ii] != null)) { -ii++; -} -var comps = Clazz.newDoubleArray (ii, ii, 0); -for (var i = 0; i < ii; i++) { -if (this.pca.getEigenvalue (i) > 1e-4) { -comps[i] = this.pca.component (i); -}} -this.top = this.pca.getM ().rows - 1; -this.points = new java.util.Vector (); -var scores = this.pca.getComponents (this.top - 1, this.top - 2, this.top - 3, 100); -for (var i = 0; i < this.pca.getM ().rows; i++) { -var sp = new jalview.datamodel.SequencePoint (this.seqs[i], scores[i]); -this.points.addElement (sp); -} -}); -Clazz.defineMethod (c$, "updateRc", -function (rc) { -rc.setPoints (this.points, this.pca.getM ().rows); -}, "jalview.api.RotatableCanvasI"); -Clazz.defineMethod (c$, "isNucleotide", -function () { -return this.nucleotide; -}); -Clazz.defineMethod (c$, "setNucleotide", -function (nucleotide) { -this.nucleotide = nucleotide; -}, "~B"); -Clazz.defineMethod (c$, "getTop", -function () { -return this.top; -}); -Clazz.defineMethod (c$, "updateRcView", -function (dim1, dim2, dim3) { -var scores = this.pca.getComponents (dim1 - 1, dim2 - 1, dim3 - 1, 100); -for (var i = 0; i < this.pca.getM ().rows; i++) { -(this.points.elementAt (i)).coord = scores[i]; -} -}, "~N,~N,~N"); -Clazz.defineMethod (c$, "getDetails", -function () { -return this.pca.getDetails (); -}); -Clazz.defineMethod (c$, "getSeqtrings", -function () { -return this.seqstrings; -}); -Clazz.defineMethod (c$, "getPointsasCsv", -function (transformed, xdim, ydim, zdim) { -var csv = new StringBuffer (); -csv.append ("\"Sequence\""); -if (transformed) { -csv.append (","); -csv.append (xdim); -csv.append (","); -csv.append (ydim); -csv.append (","); -csv.append (zdim); -} else { -for (var d = 1, dmax = this.pca.component (1).length; d <= dmax; d++) { -csv.append ("," + d); -} -}csv.append ("\n"); -for (var s = 0; s < this.seqs.length; s++) { -csv.append ("\"" + this.seqs[s].getName () + "\""); -var fl; -if (!transformed) { -fl = this.pca.component (s); -for (var d = fl.length - 1; d >= 0; d--) { -csv.append (","); -csv.append (fl[d]); -} -} else { -fl = this.getPointPosition (s); -for (var d = 0; d < fl.length; d++) { -csv.append (","); -csv.append (fl[d]); -} -}csv.append ("\n"); -} -return csv.toString (); -}, "~B,~N,~N,~N"); -Clazz.defineMethod (c$, "getPointPosition", -function (s) { -var pts = Clazz.newDoubleArray (3, 0); -var p = this.points.elementAt (s).coord; -pts[0] = p[0]; -pts[1] = p[1]; -pts[2] = p[2]; -return pts; -}, "~N"); -Clazz.defineMethod (c$, "setJvCalcMode", -function (state) { -this.jvCalcMode = state; -}, "~B"); -Clazz.defineMethod (c$, "getScore_matrix", -function () { -return this.score_matrix; -}); -Clazz.defineMethod (c$, "setScore_matrix", -function (score_matrix) { -this.score_matrix = score_matrix; -}, "~S"); -}); +Clazz.declarePackage ("jalview.viewmodel"); +Clazz.load (null, "jalview.viewmodel.PCAModel", ["jalview.analysis.PCA", "jalview.datamodel.SequencePoint", "java.lang.StringBuffer", "java.util.Vector"], function () { +c$ = Clazz.decorateAsClass (function () { +this.pca = null; +this.top = 0; +this.seqstrings = null; +this.seqs = null; +this.score_matrix = null; +this.nucleotide = false; +this.points = null; +this.jvCalcMode = true; +Clazz.instantialize (this, arguments); +}, jalview.viewmodel, "PCAModel"); +Clazz.makeConstructor (c$, +function (seqstrings2, seqs2, nucleotide2) { +this.seqstrings = seqstrings2; +this.seqs = seqs2; +this.nucleotide = nucleotide2; +this.score_matrix = nucleotide2 ? "PID" : "BLOSUM62"; +}, "jalview.datamodel.AlignmentView,~A,~B"); +Clazz.defineMethod (c$, "isJvCalcMode", +function () { +return this.jvCalcMode; +}); +Clazz.defineMethod (c$, "run", +function () { +this.pca = new jalview.analysis.PCA (this.seqstrings.getSequenceStrings (' '), this.nucleotide, this.score_matrix); +this.pca.setJvCalcMode (this.jvCalcMode); +this.pca.run (); +var ii = 0; +while ((ii < this.seqs.length) && (this.seqs[ii] != null)) { +ii++; +} +var comps = Clazz.newDoubleArray (ii, ii, 0); +for (var i = 0; i < ii; i++) { +if (this.pca.getEigenvalue (i) > 1e-4) { +comps[i] = this.pca.component (i); +}} +this.top = this.pca.getM ().rows - 1; +this.points = new java.util.Vector (); +var scores = this.pca.getComponents (this.top - 1, this.top - 2, this.top - 3, 100); +for (var i = 0; i < this.pca.getM ().rows; i++) { +var sp = new jalview.datamodel.SequencePoint (this.seqs[i], scores[i]); +this.points.addElement (sp); +} +}); +Clazz.defineMethod (c$, "updateRc", +function (rc) { +rc.setPoints (this.points, this.pca.getM ().rows); +}, "jalview.api.RotatableCanvasI"); +Clazz.defineMethod (c$, "isNucleotide", +function () { +return this.nucleotide; +}); +Clazz.defineMethod (c$, "setNucleotide", +function (nucleotide) { +this.nucleotide = nucleotide; +}, "~B"); +Clazz.defineMethod (c$, "getTop", +function () { +return this.top; +}); +Clazz.defineMethod (c$, "updateRcView", +function (dim1, dim2, dim3) { +var scores = this.pca.getComponents (dim1 - 1, dim2 - 1, dim3 - 1, 100); +for (var i = 0; i < this.pca.getM ().rows; i++) { +(this.points.elementAt (i)).coord = scores[i]; +} +}, "~N,~N,~N"); +Clazz.defineMethod (c$, "getDetails", +function () { +return this.pca.getDetails (); +}); +Clazz.defineMethod (c$, "getSeqtrings", +function () { +return this.seqstrings; +}); +Clazz.defineMethod (c$, "getPointsasCsv", +function (transformed, xdim, ydim, zdim) { +var csv = new StringBuffer (); +csv.append ("\"Sequence\""); +if (transformed) { +csv.append (","); +csv.append ("" + xdim); +csv.append (","); +csv.append ("" + ydim); +csv.append (","); +csv.append ("" + zdim); +} else { +for (var d = 1, dmax = this.pca.component (1).length; d <= dmax; d++) { +csv.append ("," + d); +} +}csv.append ("\n"); +for (var s = 0; s < this.seqs.length; s++) { +csv.append ("\"" + this.seqs[s].getName () + "\""); +var fl; +if (!transformed) { +fl = this.pca.component (s); +for (var d = fl.length - 1; d >= 0; d--) { +csv.append (","); +csv.append (fl[d]); +} +} else { +fl = this.getPointPosition (s); +for (var d = 0; d < fl.length; d++) { +csv.append (","); +csv.append (fl[d]); +} +}csv.append ("\n"); +} +return csv.toString (); +}, "~B,~N,~N,~N"); +Clazz.defineMethod (c$, "getPointPosition", +function (s) { +var pts = Clazz.newDoubleArray (3, 0); +var p = this.points.elementAt (s).coord; +pts[0] = p[0]; +pts[1] = p[1]; +pts[2] = p[2]; +return pts; +}, "~N"); +Clazz.defineMethod (c$, "setJvCalcMode", +function (state) { +this.jvCalcMode = state; +}, "~B"); +Clazz.defineMethod (c$, "getScore_matrix", +function () { +return this.score_matrix; +}); +Clazz.defineMethod (c$, "setScore_matrix", +function (score_matrix) { +this.score_matrix = score_matrix; +}, "~S"); +});