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.bin.Jalview;
27 import jalview.datamodel.Sequence;
28 import jalview.datamodel.SequenceI;
29 import jalview.io.DataSourceType;
30 import jalview.io.FileLoader;
31 import jalview.viewmodel.ViewportRanges;
33 import org.testng.annotations.BeforeMethod;
34 import org.testng.annotations.Test;
36 public class AlignmentPanelTest
38 SequenceI seq1 = new Sequence(
40 "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
42 SequenceI seq2 = new Sequence(
44 "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
46 SequenceI seq3 = new Sequence(
48 "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
50 SequenceI seq4 = new Sequence(
52 "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
54 SequenceI seq5 = new Sequence(
56 "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
58 SequenceI seq6 = new Sequence(
60 "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
62 SequenceI seq7 = new Sequence(
64 "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
66 SequenceI seq8 = new Sequence(
68 "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
70 SequenceI seq9 = new Sequence(
72 "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
74 SequenceI seq10 = new Sequence(
76 "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
78 SequenceI seq11 = new Sequence(
80 "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
82 SequenceI seq12 = new Sequence(
84 "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
86 SequenceI seq13 = new Sequence(
88 "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
90 SequenceI seq14 = new Sequence(
92 "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
94 SequenceI seq15 = new Sequence(
96 "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
98 SequenceI seq16 = new Sequence(
100 "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
102 SequenceI seq17 = new Sequence(
104 "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
106 SequenceI seq18 = new Sequence(
108 "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
110 SequenceI seq19 = new Sequence(
112 "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
114 SequenceI seq20 = new Sequence(
116 "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
118 SequenceI seq21 = new Sequence(
120 "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
122 SequenceI seq22 = new Sequence(
124 "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
126 SequenceI seq23 = new Sequence(
128 "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
132 @BeforeMethod(alwaysRun = true)
135 Jalview.main(new String[] { "-nonews", "-props",
136 "test/jalview/testProps.jvprops" });
138 Cache.applicationProperties.setProperty("SHOW_IDENTITY",
139 Boolean.TRUE.toString());
140 af = new FileLoader().LoadFileWaitTillLoaded("examples/uniref50.fa",
141 DataSourceType.FILE);
144 * wait for Consensus thread to complete
148 while (af.getViewport().getConsensusSeq() == null)
153 } catch (InterruptedException e)
162 * Test side effect that end residue is set correctly by setScrollValues, with
163 * or without hidden columns
165 @Test(groups = "Functional")
166 public void TestSetScrollValues()
168 ViewportRanges ranges = af.getViewport().getRanges();
169 af.alignPanel.setScrollValues(0, 0);
171 int oldres = ranges.getEndRes();
172 af.alignPanel.setScrollValues(-1, 5);
174 // setting -ve x value does not change residue
175 assertEquals(ranges.getEndRes(), oldres);
177 af.alignPanel.setScrollValues(0, 5);
179 // setting 0 as x value does not change residue
180 assertEquals(ranges.getEndRes(), oldres);
182 af.alignPanel.setScrollValues(5, 5);
183 // setting x value to 5 extends endRes by 5 residues
184 assertEquals(ranges.getEndRes(), oldres + 5);
186 // scroll to position after hidden columns sets endres to oldres (width) +
189 af.getViewport().hideColumns(30, 50);
190 af.alignPanel.setScrollValues(scrollpos, 5);
191 assertEquals(ranges.getEndRes(), oldres + scrollpos);
193 // scroll to position within hidden columns, still sets endres to oldres +
195 // not sure if this is actually correct behaviour but this is what Jalview
198 af.getViewport().showAllHiddenColumns();
199 af.getViewport().hideColumns(30, 50);
200 af.alignPanel.setScrollValues(scrollpos, 5);
201 assertEquals(ranges.getEndRes(), oldres + scrollpos);
203 // scroll to position within <width> distance of the end of the alignment
204 // endRes should be set to width of alignment - 1
206 af.getViewport().showAllHiddenColumns();
207 af.alignPanel.setScrollValues(scrollpos, 5);
208 assertEquals(ranges.getEndRes(), af.getViewport()
209 .getAlignment().getWidth() - 1);
211 // now hide some columns, and scroll to position within <width>
212 // distance of the end of the alignment
213 // endRes should be set to width of alignment - 1 - the number of hidden
215 af.getViewport().hideColumns(30, 50);
216 af.alignPanel.setScrollValues(scrollpos, 5);
217 assertEquals(ranges.getEndRes(), af.getViewport()
218 .getAlignment().getWidth() - 1 - 21); // 21 is the number of hidden