3 import static org.testng.Assert.assertEquals;
5 import jalview.bin.Cache;
6 import jalview.datamodel.AlignmentAnnotation;
7 import jalview.datamodel.AlignmentI;
8 import jalview.datamodel.SequenceI;
9 import jalview.io.DataSourceType;
10 import jalview.io.FileLoader;
12 import java.util.Vector;
14 import org.testng.annotations.BeforeClass;
15 import org.testng.annotations.Test;
18 * Tests for methods of base class of annotation column or colour chooser
20 public class AnnotationRowFilterTest
24 private AnnotationRowFilter testee;
26 @BeforeClass(alwaysRun = true)
29 Cache.loadProperties("test/jalview/io/testProps.jvprops");
30 Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
31 Boolean.TRUE.toString());
32 Cache.applicationProperties.setProperty(
33 Preferences.SHOW_AUTOCALC_ABOVE, Boolean.TRUE.toString());
34 af = new FileLoader().LoadFileWaitTillLoaded("examples/uniref50.fa",
36 testee = new AnnotationRowFilter(af.viewport, af.alignPanel)
39 public void valueChanged(boolean updateAllAnnotation)
44 public void updateView()
56 * Test the method that builds the drop-down list of annotations to choose
57 * from for colour by annotation or select columns by annotation
59 @Test(groups = "Functional")
60 public void testGetAnnotationItems()
62 AlignmentI al = af.getViewport().getAlignment();
63 SequenceI seq1 = al.findSequenceMatch("FER_CAPAA")[0];
64 SequenceI seq2 = al.findSequenceMatch("FER_BRANA")[0];
66 AlignmentAnnotation ann1 = new AlignmentAnnotation("ann1Label", "ann1",
68 al.addAnnotation(ann1);
69 AlignmentAnnotation ann2 = new AlignmentAnnotation("Significance",
71 al.addAnnotation(ann2);
73 * a second Significance alignment annotation
75 AlignmentAnnotation ann2a = new AlignmentAnnotation("Significance",
77 al.addAnnotation(ann2a);
79 AlignmentAnnotation ann3 = new AlignmentAnnotation("Jronn", "Jronn",
81 ann3.setSequenceRef(seq1);
82 al.addAnnotation(ann3);
83 AlignmentAnnotation ann4 = new AlignmentAnnotation("Jronn", "Jronn",
85 ann4.setSequenceRef(seq2);
86 al.addAnnotation(ann4);
87 AlignmentAnnotation ann5 = new AlignmentAnnotation("Jnet", "Jnet", null);
88 ann5.setSequenceRef(seq2);
89 al.addAnnotation(ann5);
91 * a second Jnet annotation for FER_BRANA
93 AlignmentAnnotation ann6 = new AlignmentAnnotation("Jnet", "Jnet", null);
94 ann6.setSequenceRef(seq2);
95 al.addAnnotation(ann6);
98 * drop-down items with 'Per-sequence only' not checked
100 Vector<String> items = testee.getAnnotationItems(false);
103 "[Conservation, Quality, Consensus, Occupancy, ann1Label, Significance, Significance_1, Jronn_FER_CAPAA, Jronn_FER_BRANA, Jnet_FER_BRANA, Jnet_FER_BRANA_2]");
104 assertEquals(testee.getAnnotationMenuLabel(ann1), "ann1Label");
105 assertEquals(testee.getAnnotationMenuLabel(ann2), "Significance");
106 assertEquals(testee.getAnnotationMenuLabel(ann2a), "Significance_1");
107 assertEquals(testee.getAnnotationMenuLabel(ann3), "Jronn_FER_CAPAA");
108 assertEquals(testee.getAnnotationMenuLabel(ann4), "Jronn_FER_BRANA");
109 assertEquals(testee.getAnnotationMenuLabel(ann5), "Jnet_FER_BRANA");
110 assertEquals(testee.getAnnotationMenuLabel(ann6), "Jnet_FER_BRANA_2");
113 * drop-down items with 'Per-sequence only' checked
115 items = testee.getAnnotationItems(true);
116 assertEquals(items.toString(), "[Jronn, Jnet]");
117 // the first annotation of the type is associated with the menu item
118 assertEquals(testee.getAnnotationMenuLabel(ann3), "Jronn");
119 assertEquals(testee.getAnnotationMenuLabel(ann5), "Jnet");