X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=site%2Fj2s%2Fjalview%2Fdatamodel%2FBinarySequence.js;h=e6cf2e570d22f168866d2b002552022ed5715b70;hp=8677473076b156ca6f7c28821235b362debdbafd;hb=b9b7a352eee79b7764c3b09c9d19663075061d8c;hpb=7301a2415adab88038b291fc54caeeb3a5a47a44 diff --git a/site/j2s/jalview/datamodel/BinarySequence.js b/site/j2s/jalview/datamodel/BinarySequence.js index 8677473..e6cf2e5 100644 --- a/site/j2s/jalview/datamodel/BinarySequence.js +++ b/site/j2s/jalview/datamodel/BinarySequence.js @@ -1,99 +1,99 @@ -Clazz.declarePackage ("jalview.datamodel"); -Clazz.load (["jalview.datamodel.Sequence", "java.lang.Exception"], "jalview.datamodel.BinarySequence", ["jalview.schemes.ResidueProperties"], function () { -c$ = Clazz.decorateAsClass (function () { -if (!Clazz.isClassDefined ("jalview.datamodel.BinarySequence.InvalidSequenceTypeException")) { -jalview.datamodel.BinarySequence.$BinarySequence$InvalidSequenceTypeException$ (); -} -this.binary = null; -this.dbinary = null; -this.isNa = false; -Clazz.instantialize (this, arguments); -}, jalview.datamodel, "BinarySequence", jalview.datamodel.Sequence); -Clazz.makeConstructor (c$, -function (s, isNa) { -Clazz.superConstructor (this, jalview.datamodel.BinarySequence, ["", s, 0, s.length]); -this.isNa = isNa; -}, "~S,~B"); -Clazz.defineMethod (c$, "initMatrixGetNoRes", - function () { -var nores = (this.isNa) ? 10 : 23; -this.dbinary = Clazz.newDoubleArray (this.getSequence ().length * nores, 0); -for (var i = 0; i < this.dbinary.length; i++) { -this.dbinary[i] = 0.0; -} -return nores; -}); -Clazz.defineMethod (c$, "getSymbolmatrix", - function () { -return (this.isNa) ? jalview.schemes.ResidueProperties.nucleotideIndex : jalview.schemes.ResidueProperties.aaIndex; -}); -Clazz.defineMethod (c$, "encode", -function () { -var nores = this.initMatrixGetNoRes (); -var sindex = this.getSymbolmatrix (); -for (var i = 0; i < this.getSequence ().length; i++) { -var aanum = nores - 1; -try { -aanum = sindex[this.getCharAt (i).charCodeAt (0)]; -} catch (e) { -if (Clazz.exceptionOf (e, NullPointerException)) { -aanum = nores - 1; -} else { -throw e; -} -} -if (aanum >= nores) { -aanum = nores - 1; -}this.dbinary[(i * nores) + aanum] = 1.0; -} -}); -Clazz.defineMethod (c$, "matrixEncode", -function (matrix) { -if (this.isNa != matrix.isDNA ()) { -throw Clazz.innerTypeInstance (jalview.datamodel.BinarySequence.InvalidSequenceTypeException, this, null, "matrix " + matrix.getClass ().getCanonicalName () + " is not a valid matrix for " + (this.isNa ? "nucleotide" : "protein") + "sequences"); -}this.matrixEncode (matrix.isDNA () ? jalview.schemes.ResidueProperties.nucleotideIndex : jalview.schemes.ResidueProperties.aaIndex, matrix.getMatrix ()); -}, "jalview.schemes.ScoreMatrix"); -Clazz.defineMethod (c$, "matrixEncode", - function (aaIndex, matrix) { -var nores = this.initMatrixGetNoRes (); -for (var i = 0, iSize = this.getSequence ().length; i < iSize; i++) { -var aanum = nores - 1; -try { -aanum = aaIndex[this.getCharAt (i).charCodeAt (0)]; -} catch (e) { -if (Clazz.exceptionOf (e, NullPointerException)) { -aanum = nores - 1; -} else { -throw e; -} -} -if (aanum >= nores) { -aanum = nores - 1; -}for (var j = 0; j < nores; j++) { -this.dbinary[(i * nores) + j] = matrix[aanum][j]; -} -} -}, "~A,~A"); -Clazz.defineMethod (c$, "toBinaryString", -function () { -var out = ""; -for (var i = 0; i < this.binary.length; i++) { -out += ( new Integer (this.binary[i])).toString (); -if (i < (this.binary.length - 1)) { -out += " "; -}} -return out; -}); -Clazz.defineMethod (c$, "getDBinary", -function () { -return this.dbinary; -}); -c$.$BinarySequence$InvalidSequenceTypeException$ = function () { -Clazz.pu$h(self.c$); -c$ = Clazz.decorateAsClass (function () { -Clazz.prepareCallback (this, arguments); -Clazz.instantialize (this, arguments); -}, jalview.datamodel.BinarySequence, "InvalidSequenceTypeException", Exception); -c$ = Clazz.p0p (); -}; -}); +Clazz.declarePackage ("jalview.datamodel"); +Clazz.load (["jalview.datamodel.Sequence", "java.lang.Exception"], "jalview.datamodel.BinarySequence", ["jalview.schemes.ResidueProperties"], function () { +c$ = Clazz.decorateAsClass (function () { +if (!Clazz.isClassDefined ("jalview.datamodel.BinarySequence.InvalidSequenceTypeException")) { +jalview.datamodel.BinarySequence.$BinarySequence$InvalidSequenceTypeException$ (); +} +this.binary = null; +this.dbinary = null; +this.isNa = false; +Clazz.instantialize (this, arguments); +}, jalview.datamodel, "BinarySequence", jalview.datamodel.Sequence); +Clazz.makeConstructor (c$, +function (s, isNa) { +Clazz.superConstructor (this, jalview.datamodel.BinarySequence, ["", s, 0, s.length]); +this.isNa = isNa; +}, "~S,~B"); +Clazz.defineMethod (c$, "initMatrixGetNoRes", + function () { +var nores = (this.isNa) ? 10 : 23; +this.dbinary = Clazz.newDoubleArray (this.getSequence ().length * nores, 0); +for (var i = 0; i < this.dbinary.length; i++) { +this.dbinary[i] = 0.0; +} +return nores; +}); +Clazz.defineMethod (c$, "getSymbolmatrix", + function () { +return (this.isNa) ? jalview.schemes.ResidueProperties.nucleotideIndex : jalview.schemes.ResidueProperties.aaIndex; +}); +Clazz.defineMethod (c$, "encode", +function () { +var nores = this.initMatrixGetNoRes (); +var sindex = this.getSymbolmatrix (); +for (var i = 0; i < this.getSequence ().length; i++) { +var aanum = nores - 1; +try { +aanum = sindex[this.getCharAt (i).charCodeAt (0)]; +} catch (e) { +if (Clazz.exceptionOf (e, NullPointerException)) { +aanum = nores - 1; +} else { +throw e; +} +} +if (aanum >= nores) { +aanum = nores - 1; +}this.dbinary[(i * nores) + aanum] = 1.0; +} +}); +Clazz.defineMethod (c$, "matrixEncode", +function (matrix) { +if (this.isNa != matrix.isDNA ()) { +throw Clazz.innerTypeInstance (jalview.datamodel.BinarySequence.InvalidSequenceTypeException, this, null, "matrix " + matrix.getClass ().getCanonicalName () + " is not a valid matrix for " + (this.isNa ? "nucleotide" : "protein") + "sequences"); +}this.matrixEncode (matrix.isDNA () ? jalview.schemes.ResidueProperties.nucleotideIndex : jalview.schemes.ResidueProperties.aaIndex, matrix.getMatrix ()); +}, "jalview.schemes.ScoreMatrix"); +Clazz.defineMethod (c$, "matrixEncode", + function (aaIndex, matrix) { +var nores = this.initMatrixGetNoRes (); +for (var i = 0, iSize = this.getSequence ().length; i < iSize; i++) { +var aanum = nores - 1; +try { +aanum = aaIndex[this.getCharAt (i).charCodeAt (0)]; +} catch (e) { +if (Clazz.exceptionOf (e, NullPointerException)) { +aanum = nores - 1; +} else { +throw e; +} +} +if (aanum >= nores) { +aanum = nores - 1; +}for (var j = 0; j < nores; j++) { +this.dbinary[(i * nores) + j] = matrix[aanum][j]; +} +} +}, "~A,~A"); +Clazz.defineMethod (c$, "toBinaryString", +function () { +var out = ""; +for (var i = 0; i < this.binary.length; i++) { +out += ( new Integer (this.binary[i])).toString (); +if (i < (this.binary.length - 1)) { +out += " "; +}} +return out; +}); +Clazz.defineMethod (c$, "getDBinary", +function () { +return this.dbinary; +}); +c$.$BinarySequence$InvalidSequenceTypeException$ = function () { +Clazz.pu$h(self.c$); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +Clazz.instantialize (this, arguments); +}, jalview.datamodel.BinarySequence, "InvalidSequenceTypeException", Exception); +c$ = Clazz.p0p (); +}; +});