JAL-1807 test
[jalviewjs.git] / bin / jalview / datamodel / HiddenSequences.js
1 Clazz.declarePackage ("jalview.datamodel");
2 Clazz.load (null, "jalview.datamodel.HiddenSequences", ["jalview.datamodel.Alignment", "java.util.ArrayList"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.hiddenSequences = null;
5 this.alignment = null;
6 Clazz.instantialize (this, arguments);
7 }, jalview.datamodel, "HiddenSequences");
8 Clazz.makeConstructor (c$, 
9 function (al) {
10 this.alignment = al;
11 }, "jalview.datamodel.AlignmentI");
12 Clazz.defineMethod (c$, "getSize", 
13 function () {
14 if (this.hiddenSequences == null) {
15 return 0;
16 }var count = 0;
17 for (var i = 0; i < this.hiddenSequences.length; i++) {
18 if (this.hiddenSequences[i] != null) {
19 count++;
20 }}
21 return count;
22 });
23 Clazz.defineMethod (c$, "getWidth", 
24 function () {
25 var width = 0;
26 for (var i = 0; i < this.hiddenSequences.length; i++) {
27 if (this.hiddenSequences[i] != null && this.hiddenSequences[i].getLength () > width) {
28 width = this.hiddenSequences[i].getLength ();
29 }}
30 return width;
31 });
32 Clazz.defineMethod (c$, "adjustHeightSequenceDeleted", 
33 function (seqIndex) {
34 if (this.hiddenSequences == null) {
35 return;
36 }var alHeight = this.alignment.getHeight ();
37 var tmp =  new Array (alHeight + this.getSize ());
38 var deletionIndex = this.adjustForHiddenSeqs (seqIndex);
39 for (var i = 0; i < this.hiddenSequences.length; i++) {
40 if (this.hiddenSequences[i] == null) {
41 continue;
42 }if (i > deletionIndex) {
43 tmp[i - 1] = this.hiddenSequences[i];
44 } else {
45 tmp[i] = this.hiddenSequences[i];
46 }}
47 this.hiddenSequences = tmp;
48 }, "~N");
49 Clazz.defineMethod (c$, "adjustHeightSequenceAdded", 
50 function () {
51 if (this.hiddenSequences == null) {
52 return;
53 }var alHeight = this.alignment.getHeight ();
54 var tmp =  new Array (alHeight + this.getSize ());
55 System.arraycopy (this.hiddenSequences, 0, tmp, 0, this.hiddenSequences.length);
56 this.hiddenSequences = tmp;
57 });
58 Clazz.defineMethod (c$, "hideSequence", 
59 function (sequence) {
60 if (this.hiddenSequences == null) {
61 this.hiddenSequences =  new Array (this.alignment.getHeight ());
62 }var alignmentIndex = this.alignment.findIndex (sequence);
63 alignmentIndex = this.adjustForHiddenSeqs (alignmentIndex);
64 if (this.hiddenSequences[alignmentIndex] != null) {
65 System.out.println ("ERROR!!!!!!!!!!!");
66 }this.hiddenSequences[alignmentIndex] = sequence;
67 this.alignment.deleteSequence (sequence);
68 }, "jalview.datamodel.SequenceI");
69 Clazz.defineMethod (c$, "showAll", 
70 function (hiddenRepSequences) {
71 var revealedSeqs =  new java.util.ArrayList ();
72 for (var i = 0; i < this.hiddenSequences.length; i++) {
73 if (this.hiddenSequences[i] != null) {
74 var tmp = this.showSequence (i, hiddenRepSequences);
75 for (var seq, $seq = tmp.iterator (); $seq.hasNext () && ((seq = $seq.next ()) || true);) {
76 revealedSeqs.add (seq);
77 }
78 }}
79 return revealedSeqs;
80 }, "java.util.Map");
81 Clazz.defineMethod (c$, "showSequence", 
82 function (alignmentIndex, hiddenRepSequences) {
83 var revealedSeqs =  new java.util.ArrayList ();
84 var repSequence = this.alignment.getSequenceAt (alignmentIndex);
85 if (repSequence != null && hiddenRepSequences != null && hiddenRepSequences.containsKey (repSequence)) {
86 hiddenRepSequences.remove (repSequence);
87 revealedSeqs.add (repSequence);
88 }var start = this.adjustForHiddenSeqs (alignmentIndex - 1);
89 var end = this.adjustForHiddenSeqs (alignmentIndex);
90 if (end >= this.hiddenSequences.length) {
91 end = this.hiddenSequences.length - 1;
92 }var asequences;
93 {
94 for (var index = end; index > start; index--) {
95 var seq = this.hiddenSequences[index];
96 this.hiddenSequences[index] = null;
97 if (seq != null) {
98 if (seq.getLength () > 0) {
99 revealedSeqs.add (seq);
100 asequences.add (alignmentIndex, seq);
101 } else {
102 System.out.println (seq.getName () + " has been deleted whilst hidden");
103 }}}
104 }return revealedSeqs;
105 }, "~N,java.util.Map");
106 Clazz.defineMethod (c$, "getHiddenSequence", 
107 function (alignmentIndex) {
108 return this.hiddenSequences[alignmentIndex];
109 }, "~N");
110 Clazz.defineMethod (c$, "findIndexWithoutHiddenSeqs", 
111 function (alignmentIndex) {
112 var index = 0;
113 var hiddenSeqs = 0;
114 if (this.hiddenSequences.length <= alignmentIndex) {
115 alignmentIndex = this.hiddenSequences.length - 1;
116 }while (index <= alignmentIndex) {
117 if (this.hiddenSequences[index] != null) {
118 hiddenSeqs++;
119 }index++;
120 }
121 ;return (alignmentIndex - hiddenSeqs);
122 }, "~N");
123 Clazz.defineMethod (c$, "adjustForHiddenSeqs", 
124 function (alignmentIndex) {
125 var index = 0;
126 var hSize = this.hiddenSequences.length;
127 while (index <= alignmentIndex && index < hSize) {
128 if (this.hiddenSequences[index] != null) {
129 alignmentIndex++;
130 }index++;
131 }
132 ;return alignmentIndex;
133 }, "~N");
134 Clazz.defineMethod (c$, "getFullAlignment", 
135 function () {
136 var isize = this.hiddenSequences.length;
137 var seq =  new Array (isize);
138 var index = 0;
139 for (var i = 0; i < this.hiddenSequences.length; i++) {
140 if (this.hiddenSequences[i] != null) {
141 seq[i] = this.hiddenSequences[i];
142 } else {
143 seq[i] = this.alignment.getSequenceAt (index);
144 index++;
145 }}
146 var fAlignmt =  new jalview.datamodel.Alignment (seq);
147 fAlignmt.annotations = this.alignment.getAlignmentAnnotation ();
148 fAlignmt.alignmentProperties = this.alignment.getProperties ();
149 fAlignmt.groups = this.alignment.getGroups ();
150 fAlignmt.$hasRNAStructure = this.alignment.hasRNAStructure ();
151 return fAlignmt;
152 });
153 Clazz.defineMethod (c$, "isHidden", 
154 function (seq) {
155 if (this.hiddenSequences != null) {
156 for (var i = 0; i < this.hiddenSequences.length; i++) {
157 if (this.hiddenSequences[i] != null && this.hiddenSequences[i] === seq) {
158 return true;
159 }}
160 }return false;
161 }, "jalview.datamodel.SequenceI");
162 });