1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.datamodel; |
22 |
|
|
23 |
|
import static org.testng.Assert.assertTrue; |
24 |
|
|
25 |
|
import jalview.analysis.AlignmentGenerator; |
26 |
|
|
27 |
|
import java.util.Hashtable; |
28 |
|
import java.util.NoSuchElementException; |
29 |
|
|
30 |
|
import org.testng.annotations.BeforeClass; |
31 |
|
import org.testng.annotations.Test; |
32 |
|
|
|
|
| 0% |
Uncovered Elements: 91 (91) |
Complexity: 22 |
Complexity Density: 0.38 |
|
33 |
|
public class VisibleRowsIteratorTest |
34 |
|
{ |
35 |
|
AlignmentI al; |
36 |
|
|
37 |
|
AlignmentI al2; |
38 |
|
|
39 |
|
AlignmentI al3; |
40 |
|
|
41 |
|
Hashtable<SequenceI, SequenceCollectionI> hiddenRepSequences = new Hashtable<SequenceI, SequenceCollectionI>(); |
42 |
|
|
43 |
|
Hashtable<SequenceI, SequenceCollectionI> hiddenRepSequences2 = new Hashtable<SequenceI, SequenceCollectionI>(); |
44 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 3 |
Complexity Density: 0.3 |
|
45 |
0 |
@BeforeClass(groups = { "Functional" })... |
46 |
|
public void setup() |
47 |
|
{ |
48 |
|
|
49 |
0 |
AlignmentGenerator gen = new AlignmentGenerator(false); |
50 |
0 |
al = gen.generate(20, 15, 123, 5, 5); |
51 |
0 |
if (!hiddenRepSequences.isEmpty()) |
52 |
|
{ |
53 |
0 |
al.getHiddenSequences().showAll(hiddenRepSequences); |
54 |
|
} |
55 |
0 |
hideSequences(al, hiddenRepSequences, 2, 4); |
56 |
|
|
57 |
0 |
al2 = gen.generate(20, 15, 123, 5, 5); |
58 |
0 |
if (!hiddenRepSequences2.isEmpty()) |
59 |
|
{ |
60 |
0 |
al2.getHiddenSequences().showAll(hiddenRepSequences2); |
61 |
|
} |
62 |
0 |
hideSequences(al2, hiddenRepSequences2, 0, 2); |
63 |
|
|
64 |
0 |
al3 = gen.generate(20, 15, 123, 5, 5); |
65 |
|
} |
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
4-
|
|
71 |
0 |
@Test(groups = { "Functional" })... |
72 |
|
public void testHasNextAndNextWithHidden() |
73 |
|
{ |
74 |
0 |
VisibleRowsIterator it = new VisibleRowsIterator(0, 6, al); |
75 |
0 |
int count = 0; |
76 |
0 |
while (it.hasNext()) |
77 |
|
{ |
78 |
0 |
it.next(); |
79 |
0 |
count++; |
80 |
|
} |
81 |
0 |
assertTrue(count == 4, "hasNext() is false after 4 iterations"); |
82 |
|
} |
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
4-
|
|
88 |
0 |
@Test(groups = { "Functional" })... |
89 |
|
public void testHasNextAndNextNoHidden() |
90 |
|
{ |
91 |
0 |
VisibleRowsIterator it = new VisibleRowsIterator(0, 3, al3); |
92 |
0 |
int count = 0; |
93 |
0 |
while (it.hasNext()) |
94 |
|
{ |
95 |
0 |
it.next(); |
96 |
0 |
count++; |
97 |
|
} |
98 |
0 |
assertTrue(count == 4, "hasNext() is false after 4 iterations"); |
99 |
|
} |
100 |
|
|
101 |
|
|
102 |
|
|
103 |
|
|
104 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
4-
|
|
105 |
0 |
@Test(groups = { "Functional" })... |
106 |
|
public void testHasNextAndNextStartHidden() |
107 |
|
{ |
108 |
0 |
VisibleRowsIterator it = new VisibleRowsIterator(0, 6, al2); |
109 |
0 |
int count = 0; |
110 |
0 |
while (it.hasNext()) |
111 |
|
{ |
112 |
0 |
it.next(); |
113 |
0 |
count++; |
114 |
|
} |
115 |
0 |
assertTrue(count == 4, "hasNext() is false after 4 iterations"); |
116 |
|
} |
117 |
|
|
118 |
|
|
119 |
|
|
120 |
|
|
121 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
4-
|
|
122 |
0 |
@Test(groups = { "Functional" })... |
123 |
|
public void testHasNextAndNextEndHidden() |
124 |
|
{ |
125 |
0 |
VisibleRowsIterator it = new VisibleRowsIterator(0, 4, al); |
126 |
0 |
int count = 0; |
127 |
0 |
while (it.hasNext()) |
128 |
|
{ |
129 |
0 |
it.next(); |
130 |
0 |
count++; |
131 |
|
} |
132 |
0 |
assertTrue(count == 2, "hasNext() is false after 2 iterations"); |
133 |
|
} |
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
4-
|
|
139 |
0 |
@Test(... |
140 |
|
groups = |
141 |
|
{ "Functional" }, |
142 |
|
expectedExceptions = |
143 |
|
{ NoSuchElementException.class }) |
144 |
|
public void testLastNextWithHidden() throws NoSuchElementException |
145 |
|
{ |
146 |
0 |
VisibleRowsIterator it = new VisibleRowsIterator(0, 3, al); |
147 |
0 |
while (it.hasNext()) |
148 |
|
{ |
149 |
0 |
it.next(); |
150 |
|
} |
151 |
0 |
it.next(); |
152 |
|
} |
153 |
|
|
154 |
|
|
155 |
|
|
156 |
|
|
157 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
4-
|
|
158 |
0 |
@Test(... |
159 |
|
groups = |
160 |
|
{ "Functional" }, |
161 |
|
expectedExceptions = |
162 |
|
{ NoSuchElementException.class }) |
163 |
|
public void testLastNextNoHidden() throws NoSuchElementException |
164 |
|
{ |
165 |
0 |
VisibleRowsIterator it = new VisibleRowsIterator(0, 3, al3); |
166 |
0 |
while (it.hasNext()) |
167 |
|
{ |
168 |
0 |
it.next(); |
169 |
|
} |
170 |
0 |
it.next(); |
171 |
|
} |
172 |
|
|
173 |
|
|
174 |
|
|
175 |
|
|
176 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
4-
|
|
177 |
0 |
@Test(... |
178 |
|
groups = |
179 |
|
{ "Functional" }, |
180 |
|
expectedExceptions = |
181 |
|
{ NoSuchElementException.class }) |
182 |
|
public void testLastNextStartHidden() throws NoSuchElementException |
183 |
|
{ |
184 |
0 |
VisibleRowsIterator it = new VisibleRowsIterator(0, 3, al2); |
185 |
0 |
while (it.hasNext()) |
186 |
|
{ |
187 |
0 |
it.next(); |
188 |
|
} |
189 |
0 |
it.next(); |
190 |
|
} |
191 |
|
|
192 |
|
|
193 |
|
|
194 |
|
|
195 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
4-
|
|
196 |
0 |
@Test(... |
197 |
|
groups = |
198 |
|
{ "Functional" }, |
199 |
|
expectedExceptions = |
200 |
|
{ NoSuchElementException.class }) |
201 |
|
public void testLastNextEndHidden() throws NoSuchElementException |
202 |
|
{ |
203 |
0 |
VisibleRowsIterator it = new VisibleRowsIterator(0, 4, al); |
204 |
0 |
while (it.hasNext()) |
205 |
|
{ |
206 |
0 |
it.next(); |
207 |
|
} |
208 |
0 |
it.next(); |
209 |
|
} |
210 |
|
|
211 |
|
|
212 |
|
|
213 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
4-
|
|
214 |
0 |
@Test(... |
215 |
|
groups = |
216 |
|
{ "Functional" }, |
217 |
|
expectedExceptions = |
218 |
|
{ UnsupportedOperationException.class }) |
219 |
|
public void testRemove() throws UnsupportedOperationException |
220 |
|
{ |
221 |
0 |
VisibleRowsIterator it = new VisibleRowsIterator(0, 3, al); |
222 |
0 |
it.remove(); |
223 |
|
} |
224 |
|
|
225 |
|
|
226 |
|
|
227 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
228 |
0 |
private void hideSequences(AlignmentI alignment,... |
229 |
|
Hashtable<SequenceI, SequenceCollectionI> hiddenRepSequences, |
230 |
|
int start, int end) |
231 |
|
{ |
232 |
0 |
SequenceI[] allseqs = alignment.getSequencesArray(); |
233 |
0 |
SequenceGroup theseSeqs = new SequenceGroup(); |
234 |
|
|
235 |
0 |
for (int i = start; i <= end; i++) |
236 |
|
{ |
237 |
0 |
theseSeqs.addSequence(allseqs[i], false); |
238 |
0 |
alignment.getHiddenSequences().hideSequence(allseqs[i]); |
239 |
|
} |
240 |
|
|
241 |
0 |
hiddenRepSequences.put(allseqs[start], theseSeqs); |
242 |
|
} |
243 |
|
} |