X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=bin%2Fjalview%2Fdatamodel%2FBinarySequence.js;h=90b6b9574c15de0f720e56ea86badbd0837692e7;hp=2285387101b668e84ca47ccc2c6f89aed8bdbcc6;hb=8ffd05b3abe52c0b6b79b011c0966361f82d5fe6;hpb=6154cb57a6eac3bb1344b8342495f5bb701ee921 diff --git a/bin/jalview/datamodel/BinarySequence.js b/bin/jalview/datamodel/BinarySequence.js index 2285387..90b6b95 100644 --- a/bin/jalview/datamodel/BinarySequence.js +++ b/bin/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", -($fz = 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; -}, $fz.isPrivate = true, $fz)); -Clazz.defineMethod (c$, "getSymbolmatrix", -($fz = function () { -return (this.isNa) ? jalview.schemes.ResidueProperties.nucleotideIndex : jalview.schemes.ResidueProperties.aaIndex; -}, $fz.isPrivate = true, $fz)); -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", -($fz = 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]; -} -} -}, $fz.isPrivate = true, $fz), "~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 (); -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", +($fz = 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; +}, $fz.isPrivate = true, $fz)); +Clazz.defineMethod (c$, "getSymbolmatrix", +($fz = function () { +return (this.isNa) ? jalview.schemes.ResidueProperties.nucleotideIndex : jalview.schemes.ResidueProperties.aaIndex; +}, $fz.isPrivate = true, $fz)); +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", +($fz = 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]; +} +} +}, $fz.isPrivate = true, $fz), "~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 (); +c$ = Clazz.decorateAsClass (function () { +Clazz.prepareCallback (this, arguments); +Clazz.instantialize (this, arguments); +}, jalview.datamodel.BinarySequence, "InvalidSequenceTypeException", Exception); +c$ = Clazz.p0p (); +}; +});