2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import static org.testng.Assert.assertEquals;
25 import jalview.bin.Cache;
26 import jalview.datamodel.AlignmentAnnotation;
27 import jalview.datamodel.AlignmentI;
28 import jalview.datamodel.SequenceI;
29 import jalview.io.DataSourceType;
30 import jalview.io.FileLoader;
32 import java.util.Vector;
34 import org.testng.annotations.BeforeClass;
35 import org.testng.annotations.Test;
38 * Tests for methods of base class of annotation column or colour chooser
40 public class AnnotationRowFilterTest
44 private AnnotationRowFilter testee;
46 @BeforeClass(alwaysRun = true)
49 Cache.loadProperties("test/jalview/io/testProps.jvprops");
50 Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS",
51 Boolean.TRUE.toString());
52 Cache.applicationProperties.setProperty(Preferences.SHOW_AUTOCALC_ABOVE,
53 Boolean.TRUE.toString());
54 af = new FileLoader().LoadFileWaitTillLoaded("examples/uniref50.fa",
56 testee = new AnnotationRowFilter(af.viewport, af.alignPanel)
59 public void valueChanged(boolean updateAllAnnotation)
64 public void updateView()
76 * Test the method that builds the drop-down list of annotations to choose
77 * from for colour by annotation or select columns by annotation
79 @Test(groups = "Functional")
80 public void testGetAnnotationItems()
82 AlignmentI al = af.getViewport().getAlignment();
83 SequenceI seq1 = al.findSequenceMatch("FER_CAPAA")[0];
84 SequenceI seq2 = al.findSequenceMatch("FER_BRANA")[0];
86 AlignmentAnnotation ann1 = new AlignmentAnnotation("ann1Label", "ann1",
88 al.addAnnotation(ann1);
89 AlignmentAnnotation ann2 = new AlignmentAnnotation("Significance",
91 al.addAnnotation(ann2);
93 * a second Significance alignment annotation
95 AlignmentAnnotation ann2a = new AlignmentAnnotation("Significance",
97 al.addAnnotation(ann2a);
99 AlignmentAnnotation ann3 = new AlignmentAnnotation("Jronn", "Jronn",
101 ann3.setSequenceRef(seq1);
102 al.addAnnotation(ann3);
103 AlignmentAnnotation ann4 = new AlignmentAnnotation("Jronn", "Jronn",
105 ann4.setSequenceRef(seq2);
106 al.addAnnotation(ann4);
107 AlignmentAnnotation ann5 = new AlignmentAnnotation("Jnet", "Jnet",
109 ann5.setSequenceRef(seq2);
110 al.addAnnotation(ann5);
112 * a second Jnet annotation for FER_BRANA
114 AlignmentAnnotation ann6 = new AlignmentAnnotation("Jnet", "Jnet",
116 ann6.setSequenceRef(seq2);
117 al.addAnnotation(ann6);
120 * drop-down items with 'Per-sequence only' not checked
122 Vector<String> items = testee.getAnnotationItems(false);
123 assertEquals(items.toString(),
124 "[Conservation, Quality, Consensus, Occupancy, ann1Label, Significance, Significance_1, Jronn_FER_CAPAA, Jronn_FER_BRANA, Jnet_FER_BRANA, Jnet_FER_BRANA_2]");
125 assertEquals(testee.getAnnotationMenuLabel(ann1), "ann1Label");
126 assertEquals(testee.getAnnotationMenuLabel(ann2), "Significance");
127 assertEquals(testee.getAnnotationMenuLabel(ann2a), "Significance_1");
128 assertEquals(testee.getAnnotationMenuLabel(ann3), "Jronn_FER_CAPAA");
129 assertEquals(testee.getAnnotationMenuLabel(ann4), "Jronn_FER_BRANA");
130 assertEquals(testee.getAnnotationMenuLabel(ann5), "Jnet_FER_BRANA");
131 assertEquals(testee.getAnnotationMenuLabel(ann6), "Jnet_FER_BRANA_2");
134 * drop-down items with 'Per-sequence only' checked
136 items = testee.getAnnotationItems(true);
137 assertEquals(items.toString(), "[Jronn, Jnet]");
138 // the first annotation of the type is associated with the menu item
139 assertEquals(testee.getAnnotationMenuLabel(ann3), "Jronn");
140 assertEquals(testee.getAnnotationMenuLabel(ann5), "Jnet");