1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.controller; |
22 |
|
|
23 |
|
import static org.testng.AssertJUnit.assertEquals; |
24 |
|
import static org.testng.AssertJUnit.assertTrue; |
25 |
|
|
26 |
|
import java.awt.Color; |
27 |
|
import java.util.Arrays; |
28 |
|
import java.util.BitSet; |
29 |
|
|
30 |
|
import org.testng.annotations.BeforeClass; |
31 |
|
import org.testng.annotations.Test; |
32 |
|
|
33 |
|
import jalview.analysis.Finder; |
34 |
|
import jalview.api.AlignViewControllerI; |
35 |
|
import jalview.api.FeatureColourI; |
36 |
|
import jalview.api.FinderI; |
37 |
|
import jalview.datamodel.Alignment; |
38 |
|
import jalview.datamodel.SearchResults; |
39 |
|
import jalview.datamodel.SearchResultsI; |
40 |
|
import jalview.datamodel.Sequence; |
41 |
|
import jalview.datamodel.SequenceFeature; |
42 |
|
import jalview.datamodel.SequenceGroup; |
43 |
|
import jalview.datamodel.SequenceI; |
44 |
|
import jalview.gui.AlignFrame; |
45 |
|
import jalview.gui.JvOptionPane; |
46 |
|
import jalview.io.DataSourceType; |
47 |
|
import jalview.io.FileLoader; |
48 |
|
import jalview.schemes.FeatureColour; |
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (101) |
Complexity: 3 |
Complexity Density: 0.03 |
|
50 |
|
public class AlignViewControllerTest |
51 |
|
{ |
52 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
53 |
1 |
@BeforeClass(alwaysRun = true)... |
54 |
|
public void setUpJvOptionPane() |
55 |
|
{ |
56 |
1 |
JvOptionPane.setInteractiveMode(false); |
57 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
58 |
|
} |
59 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (79) |
Complexity: 1 |
Complexity Density: 0.01 |
1PASS
|
|
60 |
1 |
@Test(groups = "Functional")... |
61 |
|
public void testFindColumnsWithFeature() |
62 |
|
{ |
63 |
1 |
SequenceI seq1 = new Sequence("seq1", "-a-MMMaaaaaaaaaaaaaaaa"); |
64 |
1 |
SequenceI seq2 = new Sequence("seq2", "aa--aMM-MMMMMaaaaaaaaaa"); |
65 |
1 |
SequenceI seq3 = new Sequence("seq3", "abcab-caD-aaMMMMMaaaaa"); |
66 |
1 |
SequenceI seq4 = new Sequence("seq4", "abc--abcaaaaaaaaaaaaaa"); |
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
1 |
seq1.addSequenceFeature( |
72 |
|
new SequenceFeature("Metal", "desc", 2, 4, 0f, null)); |
73 |
1 |
seq1.addSequenceFeature( |
74 |
|
new SequenceFeature("Helix", "desc", 1, 15, 0f, null)); |
75 |
1 |
seq2.addSequenceFeature( |
76 |
|
new SequenceFeature("Metal", "desc", 4, 10, 10f, null)); |
77 |
1 |
seq3.addSequenceFeature( |
78 |
|
new SequenceFeature("Metal", "desc", 11, 15, 10f, null)); |
79 |
|
|
80 |
1 |
seq3.addSequenceFeature( |
81 |
|
new SequenceFeature("disulfide bond", "desc", 8, 12, 0f, null)); |
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
1 |
SequenceGroup sg = new SequenceGroup(); |
87 |
1 |
sg.setStartRes(0); |
88 |
1 |
sg.setEndRes(4); |
89 |
1 |
sg.addSequence(seq1, false); |
90 |
1 |
sg.addSequence(seq2, false); |
91 |
1 |
sg.addSequence(seq3, false); |
92 |
1 |
sg.addSequence(seq4, false); |
93 |
|
|
94 |
|
|
95 |
|
|
96 |
|
|
97 |
1 |
AlignFrame af = new AlignFrame( |
98 |
|
new Alignment(new SequenceI[] |
99 |
|
{ seq1, seq2, seq3, seq4 }), 100, 100); |
100 |
1 |
af.getFeatureRenderer().findAllFeatures(true); |
101 |
|
|
102 |
1 |
AlignViewController avc = new AlignViewController(af, af.getViewport(), |
103 |
|
af.alignPanel); |
104 |
|
|
105 |
1 |
BitSet bs = new BitSet(); |
106 |
1 |
int seqCount = avc.findColumnsWithFeature("Metal", sg, bs); |
107 |
1 |
assertEquals(1, seqCount); |
108 |
1 |
assertEquals(2, bs.cardinality()); |
109 |
1 |
assertTrue(bs.get(3)); |
110 |
1 |
assertTrue(bs.get(4)); |
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
|
115 |
1 |
sg.setEndRes(6); |
116 |
1 |
bs.clear(); |
117 |
1 |
seqCount = avc.findColumnsWithFeature("Metal", sg, bs); |
118 |
1 |
assertEquals(2, seqCount); |
119 |
1 |
assertEquals(4, bs.cardinality()); |
120 |
1 |
assertTrue(bs.get(3)); |
121 |
1 |
assertTrue(bs.get(4)); |
122 |
1 |
assertTrue(bs.get(5)); |
123 |
1 |
assertTrue(bs.get(6)); |
124 |
|
|
125 |
|
|
126 |
|
|
127 |
|
|
128 |
1 |
sg.setStartRes(13); |
129 |
1 |
sg.setEndRes(13); |
130 |
1 |
bs.clear(); |
131 |
1 |
seqCount = avc.findColumnsWithFeature("Metal", sg, bs); |
132 |
1 |
assertEquals(1, seqCount); |
133 |
1 |
assertEquals(1, bs.cardinality()); |
134 |
1 |
assertTrue(bs.get(13)); |
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
|
139 |
1 |
sg.setStartRes(17); |
140 |
1 |
sg.setEndRes(19); |
141 |
1 |
bs.clear(); |
142 |
1 |
seqCount = avc.findColumnsWithFeature("Metal", sg, bs); |
143 |
1 |
assertEquals(0, seqCount); |
144 |
1 |
assertEquals(0, bs.cardinality()); |
145 |
|
|
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
|
150 |
|
|
151 |
1 |
FeatureColourI fc = new FeatureColour(null, Color.red, Color.blue, null, |
152 |
|
0f, 10f); |
153 |
1 |
fc.setAboveThreshold(true); |
154 |
1 |
fc.setThreshold(5f); |
155 |
1 |
af.getFeatureRenderer().setColour("Metal", fc); |
156 |
1 |
sg.setStartRes(0); |
157 |
1 |
sg.setEndRes(6); |
158 |
1 |
bs.clear(); |
159 |
1 |
seqCount = avc.findColumnsWithFeature("Metal", sg, bs); |
160 |
1 |
assertEquals(1, seqCount); |
161 |
1 |
assertEquals(2, bs.cardinality()); |
162 |
1 |
assertTrue(bs.get(5)); |
163 |
1 |
assertTrue(bs.get(6)); |
164 |
|
|
165 |
|
|
166 |
|
|
167 |
|
|
168 |
1 |
sg.setStartRes(10); |
169 |
1 |
sg.setEndRes(12); |
170 |
1 |
bs.clear(); |
171 |
1 |
seqCount = avc.findColumnsWithFeature("disulfide bond", sg, bs); |
172 |
1 |
assertEquals(0, seqCount); |
173 |
1 |
assertEquals(0, bs.cardinality()); |
174 |
|
|
175 |
|
|
176 |
|
|
177 |
|
|
178 |
1 |
sg.setStartRes(5); |
179 |
1 |
sg.setEndRes(17); |
180 |
1 |
bs.clear(); |
181 |
1 |
seqCount = avc.findColumnsWithFeature("disulfide bond", sg, bs); |
182 |
1 |
assertEquals(1, seqCount); |
183 |
1 |
assertEquals(2, bs.cardinality()); |
184 |
1 |
assertTrue(bs.get(8)); |
185 |
1 |
assertTrue(bs.get(13)); |
186 |
|
|
187 |
|
|
188 |
|
|
189 |
|
|
190 |
1 |
sg.setStartRes(0); |
191 |
1 |
sg.setEndRes(19); |
192 |
1 |
bs.clear(); |
193 |
1 |
seqCount = avc.findColumnsWithFeature("Pfam", sg, bs); |
194 |
1 |
assertEquals(0, seqCount); |
195 |
1 |
assertEquals(0, bs.cardinality()); |
196 |
|
} |
197 |
|
|
198 |
|
|
199 |
|
|
200 |
|
|
201 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
202 |
1 |
@Test(groups = "Functional")... |
203 |
|
public void testSelectColumnsWithHighlight() |
204 |
|
{ |
205 |
1 |
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( |
206 |
|
"seq1 aMMMaaaaaaaaaaaaaaaa\n" + "seq2 aaaMMMMMMMaaaaaaaaaa\n" |
207 |
|
+ "seq3 aaaaaaaaaaMMMMMaaaaa\n" |
208 |
|
+ "seq4 aaaaaaaaaaaaaaaaaaaa\n", |
209 |
|
DataSourceType.PASTE); |
210 |
|
|
211 |
1 |
SearchResultsI sr = new SearchResults(); |
212 |
1 |
SequenceI[] sqs = af.getViewport().getAlignment().getSequencesArray(); |
213 |
1 |
SequenceI seq1 = sqs[0]; |
214 |
1 |
SequenceI seq2 = sqs[1]; |
215 |
1 |
SequenceI seq3 = sqs[2]; |
216 |
1 |
SequenceI seq4 = sqs[3]; |
217 |
|
|
218 |
|
|
219 |
|
|
220 |
|
|
221 |
1 |
sr.addResult(seq1, 2, 4); |
222 |
1 |
sr.addResult(seq2, 4, 10); |
223 |
1 |
sr.addResult(seq3, 11, 15); |
224 |
|
|
225 |
|
|
226 |
|
|
227 |
|
|
228 |
1 |
FinderI f = new Finder(af.getViewport()); |
229 |
1 |
f.findAll("M+", true, false, false, false); |
230 |
1 |
assertEquals( |
231 |
|
"Finder found different set of results to manually created SearchResults", |
232 |
|
sr, f.getSearchResults()); |
233 |
|
|
234 |
|
|
235 |
|
|
236 |
|
|
237 |
1 |
af.getViewport().setSearchResults(sr); |
238 |
1 |
AlignViewControllerI avc = af.avc; |
239 |
|
|
240 |
1 |
avc.markHighlightedColumns(false, false, false); |
241 |
1 |
assertTrue("Didn't select highlighted columns", |
242 |
|
Arrays.deepEquals(af.getViewport().getColumnSelection() |
243 |
|
.getSelectedRanges().toArray(), new int[][] |
244 |
|
{ { 1, 14 } })); |
245 |
|
} |
246 |
|
} |