JAL-1807 test
[jalviewjs.git] / bin / jalview / schemes / Consensus.js
1 Clazz.declarePackage ("jalview.schemes");
2 Clazz.load (null, "jalview.schemes.Consensus", ["jalview.schemes.ResidueProperties"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.mask = null;
5 this.threshold = 0;
6 this.maskstr = null;
7 Clazz.instantialize (this, arguments);
8 }, jalview.schemes, "Consensus");
9 Clazz.makeConstructor (c$, 
10 function (mask, threshold) {
11 this.maskstr = mask;
12 this.setMask (mask);
13 this.threshold = threshold;
14 }, "~S,~N");
15 Clazz.defineMethod (c$, "setMask", 
16 function (s) {
17 this.mask = this.setNums (s);
18 }, "~S");
19 Clazz.defineMethod (c$, "isConserved", 
20 function (cons2, col, size) {
21 return this.isConserved (cons2, col, size, true);
22 }, "~A,~N,~N");
23 Clazz.defineMethod (c$, "isConserved", 
24 function (cons2, col, size, includeGaps) {
25 var tot = 0;
26 if (!includeGaps) {
27 size -= cons2[col][cons2[col].length - 1];
28 }for (var i = 0; i < this.mask.length; i++) {
29 tot += cons2[col][this.mask[i]];
30 }
31 if (tot > ((this.threshold * size) / 100)) {
32 return true;
33 }return false;
34 }, "~A,~N,~N,~B");
35 Clazz.defineMethod (c$, "setNums", 
36 function (s) {
37 var out =  Clazz.newIntArray (s.length, 0);
38 var i = 0;
39 while (i < s.length) {
40 out[i] = jalview.schemes.ResidueProperties.aaIndex[s.charCodeAt (i)];
41 i++;
42 }
43 return out;
44 }, "~S");
45 });