1 Clazz.declarePackage ("jalview.datamodel");
\r
2 Clazz.load (["jalview.datamodel.Sequence", "java.lang.Exception"], "jalview.datamodel.BinarySequence", ["jalview.schemes.ResidueProperties"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
4 if (!Clazz.isClassDefined ("jalview.datamodel.BinarySequence.InvalidSequenceTypeException")) {
\r
5 jalview.datamodel.BinarySequence.$BinarySequence$InvalidSequenceTypeException$ ();
\r
10 Clazz.instantialize (this, arguments);
\r
11 }, jalview.datamodel, "BinarySequence", jalview.datamodel.Sequence);
\r
12 Clazz.makeConstructor (c$,
\r
13 function (s, isNa) {
\r
14 Clazz.superConstructor (this, jalview.datamodel.BinarySequence, ["", s, 0, s.length]);
\r
17 Clazz.defineMethod (c$, "initMatrixGetNoRes",
\r
19 var nores = (this.isNa) ? 10 : 23;
\r
20 this.dbinary = Clazz.newDoubleArray (this.getSequence ().length * nores, 0);
\r
21 for (var i = 0; i < this.dbinary.length; i++) {
\r
22 this.dbinary[i] = 0.0;
\r
26 Clazz.defineMethod (c$, "getSymbolmatrix",
\r
28 return (this.isNa) ? jalview.schemes.ResidueProperties.nucleotideIndex : jalview.schemes.ResidueProperties.aaIndex;
\r
30 Clazz.defineMethod (c$, "encode",
\r
32 var nores = this.initMatrixGetNoRes ();
\r
33 var sindex = this.getSymbolmatrix ();
\r
34 for (var i = 0; i < this.getSequence ().length; i++) {
\r
35 var aanum = nores - 1;
\r
37 aanum = sindex[this.getCharAt (i).charCodeAt (0)];
\r
39 if (Clazz.exceptionOf (e, NullPointerException)) {
\r
45 if (aanum >= nores) {
\r
47 }this.dbinary[(i * nores) + aanum] = 1.0;
\r
50 Clazz.defineMethod (c$, "matrixEncode",
\r
52 if (this.isNa != matrix.isDNA ()) {
\r
53 throw Clazz.innerTypeInstance (jalview.datamodel.BinarySequence.InvalidSequenceTypeException, this, null, "matrix " + matrix.getClass ().getCanonicalName () + " is not a valid matrix for " + (this.isNa ? "nucleotide" : "protein") + "sequences");
\r
54 }this.matrixEncode (matrix.isDNA () ? jalview.schemes.ResidueProperties.nucleotideIndex : jalview.schemes.ResidueProperties.aaIndex, matrix.getMatrix ());
\r
55 }, "jalview.schemes.ScoreMatrix");
\r
56 Clazz.defineMethod (c$, "matrixEncode",
\r
57 function (aaIndex, matrix) {
\r
58 var nores = this.initMatrixGetNoRes ();
\r
59 for (var i = 0, iSize = this.getSequence ().length; i < iSize; i++) {
\r
60 var aanum = nores - 1;
\r
62 aanum = aaIndex[this.getCharAt (i).charCodeAt (0)];
\r
64 if (Clazz.exceptionOf (e, NullPointerException)) {
\r
70 if (aanum >= nores) {
\r
72 }for (var j = 0; j < nores; j++) {
\r
73 this.dbinary[(i * nores) + j] = matrix[aanum][j];
\r
77 Clazz.defineMethod (c$, "toBinaryString",
\r
80 for (var i = 0; i < this.binary.length; i++) {
\r
81 out += ( new Integer (this.binary[i])).toString ();
\r
82 if (i < (this.binary.length - 1)) {
\r
87 Clazz.defineMethod (c$, "getDBinary",
\r
89 return this.dbinary;
\r
91 c$.$BinarySequence$InvalidSequenceTypeException$ = function () {
\r
92 Clazz.pu$h(self.c$);
\r
93 c$ = Clazz.decorateAsClass (function () {
\r
94 Clazz.prepareCallback (this, arguments);
\r
95 Clazz.instantialize (this, arguments);
\r
96 }, jalview.datamodel.BinarySequence, "InvalidSequenceTypeException", Exception);
\r