1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.gui; |
22 |
|
|
23 |
|
import static jalview.util.UrlConstants.DB_ACCESSION; |
24 |
|
import static jalview.util.UrlConstants.SEQUENCE_ID; |
25 |
|
import static org.testng.AssertJUnit.assertEquals; |
26 |
|
import static org.testng.AssertJUnit.assertFalse; |
27 |
|
import static org.testng.AssertJUnit.assertTrue; |
28 |
|
|
29 |
|
import jalview.bin.Cache; |
30 |
|
import jalview.datamodel.AlignmentAnnotation; |
31 |
|
import jalview.datamodel.AlignmentI; |
32 |
|
import jalview.datamodel.Annotation; |
33 |
|
import jalview.datamodel.ColumnSelection; |
34 |
|
import jalview.datamodel.DBRefEntry; |
35 |
|
import jalview.datamodel.DBRefSource; |
36 |
|
import jalview.datamodel.HiddenColumns; |
37 |
|
import jalview.datamodel.Sequence; |
38 |
|
import jalview.datamodel.SequenceFeature; |
39 |
|
import jalview.datamodel.SequenceGroup; |
40 |
|
import jalview.datamodel.SequenceI; |
41 |
|
import jalview.io.DataSourceType; |
42 |
|
import jalview.io.FileFormat; |
43 |
|
import jalview.io.FormatAdapter; |
44 |
|
import jalview.urls.api.UrlProviderFactoryI; |
45 |
|
import jalview.urls.desktop.DesktopUrlProviderFactory; |
46 |
|
import jalview.util.MessageManager; |
47 |
|
import jalview.util.UrlConstants; |
48 |
|
|
49 |
|
import java.awt.Component; |
50 |
|
import java.io.IOException; |
51 |
|
import java.util.ArrayList; |
52 |
|
import java.util.Collections; |
53 |
|
import java.util.Iterator; |
54 |
|
import java.util.List; |
55 |
|
|
56 |
|
import javax.swing.JMenu; |
57 |
|
import javax.swing.JMenuItem; |
58 |
|
import javax.swing.JPopupMenu; |
59 |
|
import javax.swing.JSeparator; |
60 |
|
|
61 |
|
import org.testng.annotations.BeforeClass; |
62 |
|
import org.testng.annotations.BeforeMethod; |
63 |
|
import org.testng.annotations.Test; |
64 |
|
|
|
|
| 83.7% |
Uncovered Elements: 53 (325) |
Complexity: 22 |
Complexity Density: 0.07 |
|
65 |
|
public class PopupMenuTest |
66 |
|
{ |
67 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
68 |
1 |
@BeforeClass(alwaysRun = true)... |
69 |
|
public void setUpJvOptionPane() |
70 |
|
{ |
71 |
1 |
JvOptionPane.setInteractiveMode(false); |
72 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
73 |
|
} |
74 |
|
|
75 |
|
|
76 |
|
final static String TEST_DATA = ">FER_CAPAA Ferredoxin\n" |
77 |
|
+ "TIETHKEAELVG-\n" |
78 |
|
+ ">FER_CAPAN Ferredoxin, chloroplast precursor\n" |
79 |
|
+ "TIETHKEAELVG-\n" |
80 |
|
+ ">FER1_SOLLC Ferredoxin-1, chloroplast precursor\n" |
81 |
|
+ "TIETHKEEELTA-\n" + ">Q93XJ9_SOLTU Ferredoxin I precursor\n" |
82 |
|
+ "TIETHKEEELTA-\n"; |
83 |
|
|
84 |
|
AlignmentI alignment; |
85 |
|
|
86 |
|
AlignmentPanel parentPanel; |
87 |
|
|
88 |
|
PopupMenu testee = null; |
89 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 1 |
Complexity Density: 0.07 |
|
90 |
11 |
@BeforeMethod(alwaysRun = true)... |
91 |
|
public void setUp() throws IOException |
92 |
|
{ |
93 |
11 |
Cache.loadProperties("test/jalview/io/testProps.jvprops"); |
94 |
11 |
String inMenuString = ("EMBL-EBI Search | http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$" |
95 |
|
+ SEQUENCE_ID |
96 |
|
+ "$" |
97 |
|
+ "|" |
98 |
|
+ "UNIPROT | http://www.uniprot.org/uniprot/$" + DB_ACCESSION + "$") |
99 |
|
+ "|" |
100 |
|
+ ("INTERPRO | http://www.ebi.ac.uk/interpro/entry/$" |
101 |
|
+ DB_ACCESSION + "$") |
102 |
|
+ "|" |
103 |
|
+ |
104 |
|
|
105 |
|
("Gene3D | http://gene3d.biochem.ucl.ac.uk/Gene3D/search?sterm=$" |
106 |
|
+ DB_ACCESSION + "$&mode=protein"); |
107 |
|
|
108 |
11 |
UrlProviderFactoryI factory = new DesktopUrlProviderFactory( |
109 |
|
UrlConstants.DEFAULT_LABEL, inMenuString, ""); |
110 |
11 |
Preferences.sequenceUrlLinks = factory.createUrlProvider(); |
111 |
|
|
112 |
11 |
alignment = new FormatAdapter().readFile(TEST_DATA, |
113 |
|
DataSourceType.PASTE, FileFormat.Fasta); |
114 |
11 |
AlignFrame af = new AlignFrame(alignment, 700, 500); |
115 |
11 |
parentPanel = new AlignmentPanel(af, af.getViewport()); |
116 |
11 |
testee = new PopupMenu(parentPanel, null, null); |
117 |
11 |
int i = 0; |
118 |
11 |
for (SequenceI seq : alignment.getSequences()) |
119 |
|
{ |
120 |
44 |
final AlignmentAnnotation annotation = new AlignmentAnnotation( |
121 |
|
"label" + i, "desc" + i, i); |
122 |
44 |
annotation.setCalcId("calcId" + i); |
123 |
44 |
seq.addAlignmentAnnotation(annotation); |
124 |
44 |
annotation.setSequenceRef(seq); |
125 |
|
} |
126 |
|
} |
127 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
128 |
1 |
@Test(groups = { "Functional" })... |
129 |
|
public void testConfigureReferenceAnnotationsMenu_noSequenceSelected() |
130 |
|
{ |
131 |
1 |
JMenuItem menu = new JMenuItem(); |
132 |
1 |
List<SequenceI> seqs = new ArrayList<>(); |
133 |
1 |
testee.configureReferenceAnnotationsMenu(menu, seqs); |
134 |
1 |
assertFalse(menu.isEnabled()); |
135 |
|
|
136 |
1 |
menu.setEnabled(true); |
137 |
1 |
testee.configureReferenceAnnotationsMenu(menu, null); |
138 |
1 |
assertFalse(menu.isEnabled()); |
139 |
|
} |
140 |
|
|
141 |
|
|
142 |
|
|
143 |
|
|
144 |
|
|
145 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
146 |
1 |
@Test(groups = { "Functional" })... |
147 |
|
public void testConfigureReferenceAnnotationsMenu_noReferenceAnnotations() |
148 |
|
{ |
149 |
1 |
JMenuItem menu = new JMenuItem(); |
150 |
|
|
151 |
|
|
152 |
|
|
153 |
|
|
154 |
|
|
155 |
|
|
156 |
1 |
List<SequenceI> seqs = parentPanel.getAlignment().getSequences(); |
157 |
|
|
158 |
1 |
testee.configureReferenceAnnotationsMenu(menu, seqs); |
159 |
1 |
assertFalse(menu.isEnabled()); |
160 |
|
} |
161 |
|
|
162 |
|
|
163 |
|
|
164 |
|
|
165 |
|
|
166 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
167 |
1 |
@Test(groups = { "Functional" })... |
168 |
|
public void testConfigureReferenceAnnotationsMenu_alreadyAdded() |
169 |
|
{ |
170 |
1 |
JMenuItem menu = new JMenuItem(); |
171 |
1 |
List<SequenceI> seqs = parentPanel.getAlignment().getSequences(); |
172 |
|
|
173 |
|
|
174 |
|
|
175 |
1 |
attachReferenceAnnotations(seqs, true, true); |
176 |
|
|
177 |
1 |
testee.configureReferenceAnnotationsMenu(menu, seqs); |
178 |
1 |
assertFalse(menu.isEnabled()); |
179 |
|
} |
180 |
|
|
181 |
|
|
182 |
|
|
183 |
|
|
184 |
|
|
185 |
|
|
186 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
187 |
1 |
@Test(groups = { "Functional" })... |
188 |
|
public void testConfigureReferenceAnnotationsMenu() |
189 |
|
{ |
190 |
1 |
JMenuItem menu = new JMenuItem(); |
191 |
1 |
List<SequenceI> seqs = parentPanel.getAlignment().getSequences(); |
192 |
|
|
193 |
|
|
194 |
1 |
attachReferenceAnnotations(seqs, false, false); |
195 |
|
|
196 |
1 |
testee.configureReferenceAnnotationsMenu(menu, seqs); |
197 |
1 |
assertTrue(menu.isEnabled()); |
198 |
1 |
String s = MessageManager.getString("label.add_annotations_for"); |
199 |
|
|
200 |
|
|
201 |
|
|
202 |
1 |
String expected = "<html><style> div.ttip {width:350px;white-space:pre-wrap;padding:2px;overflow-wrap:break-word;}</style>" |
203 |
|
+ "<div class=\"ttip\">" + s |
204 |
|
+ "<br/>Jmol/secondary structure<br/>PDB/Temp </div></html>"; |
205 |
1 |
assertEquals(expected, menu.getToolTipText()); |
206 |
|
} |
207 |
|
|
208 |
|
|
209 |
|
|
210 |
|
|
211 |
|
|
212 |
|
|
213 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
214 |
1 |
@Test(groups = { "Functional" })... |
215 |
|
public void testConfigureReferenceAnnotationsMenu_notOnAlignment() |
216 |
|
{ |
217 |
1 |
JMenuItem menu = new JMenuItem(); |
218 |
1 |
List<SequenceI> seqs = parentPanel.getAlignment().getSequences(); |
219 |
|
|
220 |
|
|
221 |
1 |
attachReferenceAnnotations(seqs, true, false); |
222 |
|
|
223 |
1 |
testee.configureReferenceAnnotationsMenu(menu, seqs); |
224 |
1 |
assertTrue(menu.isEnabled()); |
225 |
1 |
String s = MessageManager.getString("label.add_annotations_for"); |
226 |
|
|
227 |
|
|
228 |
|
|
229 |
1 |
String expected = "<html><style> div.ttip {width:350px;white-space:pre-wrap;padding:2px;overflow-wrap:break-word;}</style>" |
230 |
|
+ "<div class=\"ttip\">Add annotations for<br/>Jmol/secondary structure<br/>PDB/Temp </div></html>"; |
231 |
1 |
assertEquals(expected, menu.getToolTipText()); |
232 |
|
} |
233 |
|
|
234 |
|
|
235 |
|
|
236 |
|
|
237 |
|
|
238 |
|
@param |
239 |
|
@param |
240 |
|
@param |
241 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (33) |
Complexity: 7 |
Complexity Density: 0.33 |
|
242 |
3 |
private void attachReferenceAnnotations(List<SequenceI> seqs,... |
243 |
|
boolean addToSequence, boolean addToAlignment) |
244 |
|
{ |
245 |
|
|
246 |
3 |
AlignmentAnnotation annotation = new AlignmentAnnotation( |
247 |
|
"secondary structure", "", 0); |
248 |
3 |
annotation.setCalcId("PDB"); |
249 |
3 |
seqs.get(0).getDatasetSequence().addAlignmentAnnotation(annotation); |
250 |
3 |
if (addToSequence) |
251 |
|
{ |
252 |
2 |
seqs.get(0).addAlignmentAnnotation(annotation); |
253 |
|
} |
254 |
3 |
if (addToAlignment) |
255 |
|
{ |
256 |
1 |
this.alignment.addAnnotation(annotation); |
257 |
|
} |
258 |
|
|
259 |
|
|
260 |
3 |
annotation = new AlignmentAnnotation("Temp", "", 0); |
261 |
3 |
annotation.setCalcId("PDB"); |
262 |
3 |
seqs.get(1).getDatasetSequence().addAlignmentAnnotation(annotation); |
263 |
3 |
if (addToSequence) |
264 |
|
{ |
265 |
2 |
seqs.get(1).addAlignmentAnnotation(annotation); |
266 |
|
} |
267 |
3 |
if (addToAlignment) |
268 |
|
{ |
269 |
1 |
this.alignment.addAnnotation(annotation); |
270 |
|
} |
271 |
|
|
272 |
|
|
273 |
3 |
annotation = new AlignmentAnnotation("secondary structure", "", 0); |
274 |
3 |
annotation.setCalcId("Jmol"); |
275 |
3 |
seqs.get(0).getDatasetSequence().addAlignmentAnnotation(annotation); |
276 |
3 |
if (addToSequence) |
277 |
|
{ |
278 |
2 |
seqs.get(0).addAlignmentAnnotation(annotation); |
279 |
|
} |
280 |
3 |
if (addToAlignment) |
281 |
|
{ |
282 |
1 |
this.alignment.addAnnotation(annotation); |
283 |
|
} |
284 |
|
} |
285 |
|
|
286 |
|
|
287 |
|
|
288 |
|
|
289 |
|
|
290 |
|
|
291 |
|
|
292 |
|
|
293 |
|
|
294 |
|
|
295 |
|
|
296 |
|
|
297 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
1PASS
|
|
298 |
1 |
@Test(groups = { "Functional" })... |
299 |
|
public void testConfigureReferenceAnnotationsMenu_twoViews() |
300 |
|
{ |
301 |
|
} |
302 |
|
|
303 |
|
|
304 |
|
|
305 |
|
|
306 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (45) |
Complexity: 1 |
Complexity Density: 0.02 |
1PASS
|
|
307 |
1 |
@Test(groups = { "Functional" })... |
308 |
|
public void testBuildAnnotationTypesMenus() |
309 |
|
{ |
310 |
1 |
JMenu showMenu = new JMenu(); |
311 |
1 |
JMenu hideMenu = new JMenu(); |
312 |
1 |
List<SequenceI> seqs = parentPanel.getAlignment().getSequences(); |
313 |
|
|
314 |
|
|
315 |
|
|
316 |
|
|
317 |
1 |
AlignmentAnnotation annotation = new AlignmentAnnotation( |
318 |
|
"secondary structure", "", new Annotation[] {}); |
319 |
1 |
annotation.setCalcId("PDB"); |
320 |
1 |
annotation.visible = true; |
321 |
1 |
seqs.get(0).addAlignmentAnnotation(annotation); |
322 |
1 |
parentPanel.getAlignment().addAnnotation(annotation); |
323 |
|
|
324 |
|
|
325 |
1 |
annotation = new AlignmentAnnotation("secondary structure", "", |
326 |
|
new Annotation[] {}); |
327 |
1 |
annotation.setCalcId("JMOL"); |
328 |
1 |
annotation.visible = false; |
329 |
1 |
seqs.get(0).addAlignmentAnnotation(annotation); |
330 |
1 |
parentPanel.getAlignment().addAnnotation(annotation); |
331 |
|
|
332 |
|
|
333 |
1 |
annotation = new AlignmentAnnotation("SSP", "", new Annotation[] {}); |
334 |
1 |
annotation.setCalcId("JPred"); |
335 |
1 |
annotation.visible = false; |
336 |
1 |
seqs.get(0).addAlignmentAnnotation(annotation); |
337 |
1 |
parentPanel.getAlignment().addAnnotation(annotation); |
338 |
|
|
339 |
|
|
340 |
1 |
annotation = new AlignmentAnnotation("Temp", "", new Annotation[] {}); |
341 |
1 |
annotation.setCalcId("PDB"); |
342 |
1 |
annotation.visible = true; |
343 |
1 |
seqs.get(1).addAlignmentAnnotation(annotation); |
344 |
1 |
parentPanel.getAlignment().addAnnotation(annotation); |
345 |
|
|
346 |
|
|
347 |
|
|
348 |
|
|
349 |
|
|
350 |
1 |
testee.buildAnnotationTypesMenus(showMenu, hideMenu, seqs); |
351 |
|
|
352 |
1 |
assertTrue(showMenu.isEnabled()); |
353 |
1 |
assertTrue(hideMenu.isEnabled()); |
354 |
|
|
355 |
1 |
Component[] showOptions = showMenu.getMenuComponents(); |
356 |
1 |
Component[] hideOptions = hideMenu.getMenuComponents(); |
357 |
|
|
358 |
1 |
assertEquals(4, showOptions.length); |
359 |
1 |
assertEquals(4, hideOptions.length); |
360 |
1 |
String all = MessageManager.getString("label.all"); |
361 |
1 |
assertEquals(all, ((JMenuItem) showOptions[0]).getText()); |
362 |
1 |
assertTrue(showOptions[1] instanceof JPopupMenu.Separator); |
363 |
1 |
assertEquals(JSeparator.HORIZONTAL, |
364 |
|
((JSeparator) showOptions[1]).getOrientation()); |
365 |
1 |
assertEquals("secondary structure", |
366 |
|
((JMenuItem) showOptions[2]).getText()); |
367 |
1 |
assertEquals("JMOL", ((JMenuItem) showOptions[2]).getToolTipText()); |
368 |
1 |
assertEquals("SSP", ((JMenuItem) showOptions[3]).getText()); |
369 |
1 |
assertEquals("JPred", ((JMenuItem) showOptions[3]).getToolTipText()); |
370 |
|
|
371 |
1 |
assertEquals(all, ((JMenuItem) hideOptions[0]).getText()); |
372 |
1 |
assertTrue(hideOptions[1] instanceof JPopupMenu.Separator); |
373 |
1 |
assertEquals(JSeparator.HORIZONTAL, |
374 |
|
((JSeparator) hideOptions[1]).getOrientation()); |
375 |
1 |
assertEquals("secondary structure", |
376 |
|
((JMenuItem) hideOptions[2]).getText()); |
377 |
1 |
assertEquals("PDB", ((JMenuItem) hideOptions[2]).getToolTipText()); |
378 |
1 |
assertEquals("Temp", ((JMenuItem) hideOptions[3]).getText()); |
379 |
1 |
assertEquals("PDB", ((JMenuItem) hideOptions[3]).getToolTipText()); |
380 |
|
} |
381 |
|
|
382 |
|
|
383 |
|
|
384 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (31) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
385 |
1 |
@Test(groups = { "Functional" })... |
386 |
|
public void testBuildAnnotationTypesMenus_showDisabled() |
387 |
|
{ |
388 |
1 |
JMenu showMenu = new JMenu(); |
389 |
1 |
JMenu hideMenu = new JMenu(); |
390 |
1 |
List<SequenceI> seqs = parentPanel.getAlignment().getSequences(); |
391 |
|
|
392 |
|
|
393 |
|
|
394 |
|
|
395 |
1 |
AlignmentAnnotation annotation = new AlignmentAnnotation( |
396 |
|
"secondary structure", "", new Annotation[] {}); |
397 |
1 |
annotation.setCalcId("PDB"); |
398 |
1 |
annotation.visible = true; |
399 |
1 |
seqs.get(0).addAlignmentAnnotation(annotation); |
400 |
1 |
parentPanel.getAlignment().addAnnotation(annotation); |
401 |
|
|
402 |
|
|
403 |
1 |
annotation = new AlignmentAnnotation("Temp", "", new Annotation[] {}); |
404 |
1 |
annotation.setCalcId("PDB"); |
405 |
1 |
annotation.visible = true; |
406 |
1 |
seqs.get(1).addAlignmentAnnotation(annotation); |
407 |
1 |
parentPanel.getAlignment().addAnnotation(annotation); |
408 |
|
|
409 |
|
|
410 |
|
|
411 |
|
|
412 |
|
|
413 |
1 |
testee.buildAnnotationTypesMenus(showMenu, hideMenu, seqs); |
414 |
|
|
415 |
1 |
assertFalse(showMenu.isEnabled()); |
416 |
1 |
assertTrue(hideMenu.isEnabled()); |
417 |
|
|
418 |
1 |
Component[] showOptions = showMenu.getMenuComponents(); |
419 |
1 |
Component[] hideOptions = hideMenu.getMenuComponents(); |
420 |
|
|
421 |
1 |
assertEquals(2, showOptions.length); |
422 |
1 |
assertEquals(4, hideOptions.length); |
423 |
1 |
String all = MessageManager.getString("label.all"); |
424 |
1 |
assertEquals(all, ((JMenuItem) showOptions[0]).getText()); |
425 |
1 |
assertTrue(showOptions[1] instanceof JPopupMenu.Separator); |
426 |
1 |
assertEquals(JSeparator.HORIZONTAL, |
427 |
|
((JSeparator) showOptions[1]).getOrientation()); |
428 |
|
|
429 |
1 |
assertEquals(all, ((JMenuItem) hideOptions[0]).getText()); |
430 |
1 |
assertTrue(hideOptions[1] instanceof JPopupMenu.Separator); |
431 |
1 |
assertEquals(JSeparator.HORIZONTAL, |
432 |
|
((JSeparator) hideOptions[1]).getOrientation()); |
433 |
1 |
assertEquals("secondary structure", |
434 |
|
((JMenuItem) hideOptions[2]).getText()); |
435 |
1 |
assertEquals("PDB", ((JMenuItem) hideOptions[2]).getToolTipText()); |
436 |
1 |
assertEquals("Temp", ((JMenuItem) hideOptions[3]).getText()); |
437 |
1 |
assertEquals("PDB", ((JMenuItem) hideOptions[3]).getToolTipText()); |
438 |
|
} |
439 |
|
|
440 |
|
|
441 |
|
|
442 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (31) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
443 |
1 |
@Test(groups = { "Functional" })... |
444 |
|
public void testBuildAnnotationTypesMenus_hideDisabled() |
445 |
|
{ |
446 |
1 |
JMenu showMenu = new JMenu(); |
447 |
1 |
JMenu hideMenu = new JMenu(); |
448 |
1 |
List<SequenceI> seqs = parentPanel.getAlignment().getSequences(); |
449 |
|
|
450 |
|
|
451 |
|
|
452 |
|
|
453 |
1 |
AlignmentAnnotation annotation = new AlignmentAnnotation( |
454 |
|
"secondary structure", "", new Annotation[] {}); |
455 |
1 |
annotation.setCalcId("PDB"); |
456 |
1 |
annotation.visible = false; |
457 |
1 |
seqs.get(0).addAlignmentAnnotation(annotation); |
458 |
1 |
parentPanel.getAlignment().addAnnotation(annotation); |
459 |
|
|
460 |
|
|
461 |
1 |
annotation = new AlignmentAnnotation("Temp", "", new Annotation[] {}); |
462 |
1 |
annotation.setCalcId("PDB2"); |
463 |
1 |
annotation.visible = false; |
464 |
1 |
seqs.get(1).addAlignmentAnnotation(annotation); |
465 |
1 |
parentPanel.getAlignment().addAnnotation(annotation); |
466 |
|
|
467 |
|
|
468 |
|
|
469 |
|
|
470 |
|
|
471 |
1 |
testee.buildAnnotationTypesMenus(showMenu, hideMenu, seqs); |
472 |
|
|
473 |
1 |
assertTrue(showMenu.isEnabled()); |
474 |
1 |
assertFalse(hideMenu.isEnabled()); |
475 |
|
|
476 |
1 |
Component[] showOptions = showMenu.getMenuComponents(); |
477 |
1 |
Component[] hideOptions = hideMenu.getMenuComponents(); |
478 |
|
|
479 |
1 |
assertEquals(4, showOptions.length); |
480 |
1 |
assertEquals(2, hideOptions.length); |
481 |
1 |
String all = MessageManager.getString("label.all"); |
482 |
1 |
assertEquals(all, ((JMenuItem) showOptions[0]).getText()); |
483 |
1 |
assertTrue(showOptions[1] instanceof JPopupMenu.Separator); |
484 |
1 |
assertEquals(JSeparator.HORIZONTAL, |
485 |
|
((JSeparator) showOptions[1]).getOrientation()); |
486 |
1 |
assertEquals("secondary structure", |
487 |
|
((JMenuItem) showOptions[2]).getText()); |
488 |
1 |
assertEquals("PDB", ((JMenuItem) showOptions[2]).getToolTipText()); |
489 |
1 |
assertEquals("Temp", ((JMenuItem) showOptions[3]).getText()); |
490 |
1 |
assertEquals("PDB2", ((JMenuItem) showOptions[3]).getToolTipText()); |
491 |
|
|
492 |
1 |
assertEquals(all, ((JMenuItem) hideOptions[0]).getText()); |
493 |
1 |
assertTrue(hideOptions[1] instanceof JPopupMenu.Separator); |
494 |
1 |
assertEquals(JSeparator.HORIZONTAL, |
495 |
|
((JSeparator) hideOptions[1]).getOrientation()); |
496 |
|
} |
497 |
|
|
498 |
|
|
499 |
|
|
500 |
|
|
|
|
| 0% |
Uncovered Elements: 52 (52) |
Complexity: 3 |
Complexity Density: 0.06 |
3FAIL
|
|
501 |
0 |
@Test(groups = { "Functional" })... |
502 |
|
public void testAddFeatureLinks() |
503 |
|
{ |
504 |
|
|
505 |
0 |
List<SequenceI> seqs = parentPanel.getAlignment().getSequences(); |
506 |
|
|
507 |
|
|
508 |
0 |
List<String> links = new ArrayList<>(); |
509 |
0 |
List<DBRefEntry> refs = new ArrayList<>(); |
510 |
|
|
511 |
|
|
512 |
0 |
links.add("EMBL-EBI Search | http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$" |
513 |
|
+ SEQUENCE_ID + "$"); |
514 |
0 |
links.add("UNIPROT | http://www.uniprot.org/uniprot/$" + DB_ACCESSION |
515 |
|
+ "$"); |
516 |
0 |
links.add("INTERPRO | http://www.ebi.ac.uk/interpro/entry/$" |
517 |
|
+ DB_ACCESSION + "$"); |
518 |
|
|
519 |
0 |
links.add("Gene3D | http://gene3d.biochem.ucl.ac.uk/Gene3D/search?sterm=$" |
520 |
|
+ DB_ACCESSION + "$&mode=protein"); |
521 |
|
|
522 |
|
|
523 |
0 |
refs.add(new DBRefEntry(DBRefSource.UNIPROT, "1", "P83527")); |
524 |
0 |
refs.add(new DBRefEntry("INTERPRO", "1", "IPR001041")); |
525 |
0 |
refs.add(new DBRefEntry("INTERPRO", "1", "IPR006058")); |
526 |
0 |
refs.add(new DBRefEntry("INTERPRO", "1", "IPR012675")); |
527 |
|
|
528 |
|
|
529 |
0 |
refs.add(new DBRefEntry(DBRefSource.UNIPROT, "1", "Q9ZTS2")); |
530 |
0 |
refs.add(new DBRefEntry("GENE3D", "1", "3.10.20.30")); |
531 |
|
|
532 |
|
|
533 |
|
|
534 |
0 |
SequenceI seq = seqs.get(0); |
535 |
0 |
seq.addDBRef(refs.get(0)); |
536 |
|
|
537 |
0 |
seq.addDBRef(refs.get(1)); |
538 |
0 |
seq.addDBRef(refs.get(2)); |
539 |
0 |
seq.addDBRef(refs.get(3)); |
540 |
|
|
541 |
0 |
seqs.get(1).addDBRef(refs.get(4)); |
542 |
0 |
seqs.get(1).addDBRef(refs.get(5)); |
543 |
|
|
544 |
|
|
545 |
0 |
List<SequenceFeature> noFeatures = Collections.<SequenceFeature> emptyList(); |
546 |
0 |
testee = new PopupMenu(parentPanel, seq, noFeatures); |
547 |
0 |
Component[] seqItems = testee.sequenceMenu.getMenuComponents(); |
548 |
0 |
JMenu linkMenu = (JMenu) seqItems[6]; |
549 |
0 |
Component[] linkItems = linkMenu.getMenuComponents(); |
550 |
|
|
551 |
|
|
552 |
0 |
assertEquals(5, linkItems.length); |
553 |
|
|
554 |
|
|
555 |
0 |
assertEquals("EMBL-EBI Search", ((JMenuItem) linkItems[0]).getText()); |
556 |
|
|
557 |
|
|
558 |
0 |
for (int i = 1; i < 4; i++) |
559 |
|
{ |
560 |
0 |
String msg = seq.getName() + " link[" + i + "]"; |
561 |
0 |
assertEquals(msg, refs.get(i - 1).getSource(), |
562 |
|
((JMenuItem) linkItems[i]) |
563 |
|
.getText().split("\\|")[0]); |
564 |
0 |
assertEquals(msg, refs.get(i - 1).getAccessionId(), |
565 |
|
((JMenuItem) linkItems[i]) |
566 |
|
.getText().split("\\|")[1]); |
567 |
|
} |
568 |
|
|
569 |
|
|
570 |
0 |
seq = seqs.get(1); |
571 |
0 |
testee = new PopupMenu(parentPanel, seq, noFeatures); |
572 |
0 |
seqItems = testee.sequenceMenu.getMenuComponents(); |
573 |
0 |
linkMenu = (JMenu) seqItems[6]; |
574 |
0 |
linkItems = linkMenu.getMenuComponents(); |
575 |
|
|
576 |
|
|
577 |
0 |
assertEquals(3, linkItems.length); |
578 |
|
|
579 |
|
|
580 |
0 |
assertEquals("EMBL-EBI Search", ((JMenuItem) linkItems[0]).getText()); |
581 |
|
|
582 |
|
|
583 |
0 |
for (int i = 1; i < 3; i++) |
584 |
|
{ |
585 |
0 |
String msg = seq.getName() + " link[" + i + "]"; |
586 |
0 |
assertEquals(msg, refs.get(i + 3).getSource(), |
587 |
|
((JMenuItem) linkItems[i]) |
588 |
|
.getText().split("\\|")[0].toUpperCase()); |
589 |
0 |
assertEquals(msg, refs.get(i + 3).getAccessionId(), |
590 |
|
((JMenuItem) linkItems[i]).getText().split("\\|")[1]); |
591 |
|
} |
592 |
|
|
593 |
|
|
594 |
0 |
List<String> nomatchlinks = new ArrayList<>(); |
595 |
0 |
nomatchlinks.add("NOMATCH | http://www.uniprot.org/uniprot/$" |
596 |
|
+ DB_ACCESSION + "$"); |
597 |
|
|
598 |
0 |
testee = new PopupMenu(parentPanel, seq, noFeatures); |
599 |
0 |
seqItems = testee.sequenceMenu.getMenuComponents(); |
600 |
0 |
linkMenu = (JMenu) seqItems[6]; |
601 |
0 |
assertFalse(linkMenu.isEnabled()); |
602 |
|
|
603 |
|
} |
604 |
|
|
605 |
|
|
606 |
|
|
607 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (71) |
Complexity: 1 |
Complexity Density: 0.01 |
1PASS
|
|
608 |
1 |
@Test(groups = { "Functional" })... |
609 |
|
public void testHideInsertions() |
610 |
|
{ |
611 |
|
|
612 |
1 |
List<SequenceI> seqs = parentPanel.getAlignment().getSequences(); |
613 |
|
|
614 |
|
|
615 |
|
|
616 |
1 |
Sequence seqGap1 = new Sequence("GappySeq", |
617 |
|
"AAAA----AA-AAAAAAA---AAA-----------AAAAAAAAAA--"); |
618 |
1 |
seqGap1.createDatasetSequence(); |
619 |
1 |
seqs.add(seqGap1); |
620 |
1 |
Sequence seqGap2 = new Sequence("LessGappySeq", |
621 |
|
"AAAAAA-AAAAA---AAA--AAAAA--AAAAAAA-AAAAAA"); |
622 |
1 |
seqGap2.createDatasetSequence(); |
623 |
1 |
seqs.add(seqGap2); |
624 |
1 |
Sequence seqGap3 = new Sequence("AnotherGapSeq", |
625 |
|
"AAAAAA-AAAAAA--AAAAAA-AAAAAAAAAAA---AAAAAAAA"); |
626 |
1 |
seqGap3.createDatasetSequence(); |
627 |
1 |
seqs.add(seqGap3); |
628 |
1 |
Sequence seqGap4 = new Sequence("NoGaps", |
629 |
|
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); |
630 |
1 |
seqGap4.createDatasetSequence(); |
631 |
1 |
seqs.add(seqGap4); |
632 |
|
|
633 |
1 |
ColumnSelection sel = new ColumnSelection(); |
634 |
1 |
parentPanel.av.getAlignment().getHiddenColumns() |
635 |
|
.revealAllHiddenColumns(sel); |
636 |
|
|
637 |
|
|
638 |
1 |
testee = new PopupMenu(parentPanel, seqs.get(7), null); |
639 |
1 |
testee.hideInsertions_actionPerformed(null); |
640 |
|
|
641 |
1 |
HiddenColumns hidden = parentPanel.av.getAlignment().getHiddenColumns(); |
642 |
1 |
Iterator<int[]> it = hidden.iterator(); |
643 |
1 |
assertFalse(it.hasNext()); |
644 |
|
|
645 |
|
|
646 |
1 |
testee = new PopupMenu(parentPanel, seqs.get(4), null); |
647 |
1 |
testee.hideInsertions_actionPerformed(null); |
648 |
1 |
hidden = parentPanel.av.getAlignment().getHiddenColumns(); |
649 |
1 |
it = hidden.iterator(); |
650 |
|
|
651 |
1 |
assertTrue(it.hasNext()); |
652 |
1 |
int[] region = it.next(); |
653 |
1 |
assertEquals(region[0], 4); |
654 |
1 |
assertEquals(region[1], 7); |
655 |
|
|
656 |
1 |
assertTrue(it.hasNext()); |
657 |
1 |
region = it.next(); |
658 |
1 |
assertEquals(region[0], 10); |
659 |
1 |
assertEquals(region[1], 10); |
660 |
|
|
661 |
1 |
assertTrue(it.hasNext()); |
662 |
1 |
region = it.next(); |
663 |
1 |
assertEquals(region[0], 18); |
664 |
1 |
assertEquals(region[1], 20); |
665 |
|
|
666 |
1 |
assertTrue(it.hasNext()); |
667 |
1 |
region = it.next(); |
668 |
1 |
assertEquals(region[0], 24); |
669 |
1 |
assertEquals(region[1], 34); |
670 |
|
|
671 |
1 |
assertTrue(it.hasNext()); |
672 |
1 |
region = it.next(); |
673 |
1 |
assertEquals(region[0], 45); |
674 |
1 |
assertEquals(region[1], 46); |
675 |
|
|
676 |
1 |
assertFalse(it.hasNext()); |
677 |
|
|
678 |
1 |
sel = new ColumnSelection(); |
679 |
1 |
hidden.revealAllHiddenColumns(sel); |
680 |
|
|
681 |
|
|
682 |
1 |
SequenceGroup sg = new SequenceGroup(); |
683 |
1 |
sg.setStartRes(8); |
684 |
1 |
sg.setEndRes(42); |
685 |
1 |
sg.addSequence(seqGap2, false); |
686 |
1 |
sg.addSequence(seqGap3, false); |
687 |
1 |
parentPanel.av.setSelectionGroup(sg); |
688 |
|
|
689 |
|
|
690 |
|
|
691 |
|
|
692 |
1 |
hidden.hideColumns(1, 10); |
693 |
1 |
hidden.hideColumns(31, 40); |
694 |
|
|
695 |
|
|
696 |
1 |
testee = new PopupMenu(parentPanel, seqs.get(5), null); |
697 |
1 |
testee.hideInsertions_actionPerformed(null); |
698 |
1 |
hidden = parentPanel.av.getAlignment().getHiddenColumns(); |
699 |
1 |
it = hidden.iterator(); |
700 |
|
|
701 |
1 |
assertTrue(it.hasNext()); |
702 |
1 |
region = it.next(); |
703 |
1 |
assertEquals(region[0], 1); |
704 |
1 |
assertEquals(region[1], 7); |
705 |
|
|
706 |
1 |
assertTrue(it.hasNext()); |
707 |
1 |
region = it.next(); |
708 |
1 |
assertEquals(region[0], 13); |
709 |
1 |
assertEquals(region[1], 14); |
710 |
|
|
711 |
1 |
assertTrue(it.hasNext()); |
712 |
1 |
region = it.next(); |
713 |
1 |
assertEquals(region[0], 34); |
714 |
1 |
assertEquals(region[1], 34); |
715 |
|
} |
716 |
|
|
717 |
|
} |