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;
24 import static org.testng.Assert.assertFalse;
25 import static org.testng.Assert.assertTrue;
29 import org.testng.annotations.AfterMethod;
30 import org.testng.annotations.BeforeClass;
31 import org.testng.annotations.BeforeMethod;
32 import org.testng.annotations.DataProvider;
33 import org.testng.annotations.Test;
35 import jalview.bin.Cache;
36 import jalview.bin.Jalview;
37 import jalview.datamodel.AlignmentI;
38 import jalview.datamodel.SequenceI;
39 import jalview.gui.StructureViewer.ViewerType;
40 import jalview.io.DataSourceType;
41 import jalview.io.FileLoader;
42 import jalview.structure.StructureImportSettings.TFType;
44 public class AnnotationLabelsTest2
46 @BeforeClass(alwaysRun = true)
47 public static void setUpBeforeClass() throws Exception
49 if (Desktop.instance != null)
50 Desktop.instance.closeAll_actionPerformed(null);
54 * use read-only test properties file
56 Cache.loadProperties("test/jalview/io/testProps.jvprops");
57 Jalview.main(new String[] { "--nonews", "--nosplash", });
60 @AfterMethod(alwaysRun = true)
61 public void tearDown()
63 if (Desktop.instance != null)
64 Desktop.instance.closeAll_actionPerformed(null);
68 * configure (read-only) properties for test to ensure Consensus is computed
69 * for colour Above PID testing
71 @BeforeMethod(alwaysRun = true)
74 Cache.loadProperties("test/jalview/io/testProps.jvprops");
75 Cache.applicationProperties.setProperty("SHOW_IDENTITY",
76 Boolean.TRUE.toString());
80 public static void setUpJvOptionPane()
82 JvOptionPane.setInteractiveMode(false);
83 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
88 { "Functional", "testTask1" },
89 dataProvider = "openFilesWithIdWidthChanges")
90 public void testIdWidthChanges(String alignmentFilename, boolean wrap,
91 int idWidth1min, int idWidth1max, int manualWidth,
92 String structureFilename, String paeFilename,
93 boolean secondaryStructureView, TFType temperatureFactorType,
94 ViewerType viewerType, int idWidth2min, int idWidth2max)
96 AlignFrame af = new FileLoader()
97 .LoadFileWaitTillLoaded(alignmentFilename, DataSourceType.FILE);
100 Thread.sleep(200); // to allow alignment annotations to open
101 } catch (InterruptedException e)
103 // TODO Auto-generated catch block
106 AlignViewport av = af.getCurrentView();
110 idWidth = av.getIdWidth();
111 assertTrue(idWidth > idWidth1min,
112 "idWidth (" + idWidth + ") is not greater than " + idWidth1min);
113 assertTrue(idWidth < idWidth1max,
114 "idWidth (" + idWidth + ") is not narrower than" + idWidth1max);
119 af.setWrapFormat(true, false);
120 idWidth = av.getIdWidth();
121 assertTrue(idWidth > idWidth1min, "After wrap idWidth (" + idWidth
122 + ") is not greater than " + idWidth1min);
123 assertTrue(idWidth < idWidth1max, "After wrap idWidth (" + idWidth
124 + ") is not narrower than" + idWidth1max);
127 AlignmentI al = av.getAlignment();
128 SequenceI s = al.getSequenceAt(0);
129 AlignmentPanel ap = af.alignPanel;
131 File structureFile = new File(structureFilename);
132 File paeFile = new File(paeFilename);
134 StructureViewer sv = StructureChooser.openStructureFileForSequence(null,
135 null, ap, s, false, structureFile.getAbsolutePath(),
136 temperatureFactorType, paeFile.getAbsolutePath(), true,
137 secondaryStructureView, false, viewerType);
138 // give time for annotations to open
141 Thread.sleep(200); // to allow alignment annotations to open
142 } catch (InterruptedException e)
144 // TODO Auto-generated catch block
148 // idWidth = ap.getIdPanel().getWidth();
149 idWidth = av.getIdWidth();
150 assertTrue(idWidth > idWidth2min,
151 "idWidth (" + idWidth + ") is not greater than " + idWidth2min);
152 assertTrue(idWidth < idWidth2max,
153 "idWidth (" + idWidth + ") is not narrower than" + idWidth2max);
158 { "Functional", "testTask1" },
159 dataProvider = "openFilesWithIdWidthChanges")
160 public void testIdWidthNoChanges(String alignmentFilename, boolean wrap,
161 int idWidth1min, int idWidth1max, int manualWidth,
162 String structureFilename, String paeFilename,
163 boolean secondaryStructureView, TFType temperatureFactorType,
164 ViewerType viewerType, int idWidth2min, int idWidth2max)
166 AlignFrame af = new FileLoader()
167 .LoadFileWaitTillLoaded(alignmentFilename, DataSourceType.FILE);
170 Thread.sleep(200); // to allow alignment annotations to open
171 } catch (InterruptedException e)
173 // TODO Auto-generated catch block
176 AlignViewport av = af.getCurrentView();
180 idWidth = av.getIdWidth();
181 assertTrue(idWidth > idWidth1min,
182 "idWidth (" + idWidth + ") is not greater than " + idWidth1min);
183 assertTrue(idWidth < idWidth1max,
184 "idWidth (" + idWidth + ") is not narrower than" + idWidth1max);
186 AlignmentI al = av.getAlignment();
187 SequenceI s = al.getSequenceAt(0);
188 AlignmentPanel ap = af.alignPanel;
190 // set width manually
191 av.setIdWidth(manualWidth);
192 ap.validateAnnotationDimensions(false);
193 ap.paintAlignment(true, false);
194 ap.getIdPanel().getIdCanvas().setManuallyAdjusted(true);
196 idWidth = av.getIdWidth();
197 assertEquals(idWidth, manualWidth,
198 "idWidth is not set to the manually set width " + manualWidth);
200 File structureFile = new File(structureFilename);
201 File paeFile = new File(paeFilename);
203 StructureViewer sv = StructureChooser.openStructureFileForSequence(null,
204 null, ap, s, false, structureFile.getAbsolutePath(),
205 temperatureFactorType, paeFile.getAbsolutePath(), false,
206 secondaryStructureView, false, viewerType);
208 idWidth = ap.getIdPanel().getWidth();// av.getIdWidth();
209 idWidth = av.getIdWidth();
210 assertEquals(idWidth, manualWidth,
211 "idWidth is not set to the manually set width " + manualWidth
212 + " after adding structure annotations");
213 assertFalse(idWidth > idWidth2min,
214 "idWidth (" + idWidth + ") is greater than " + idWidth2min);
217 @DataProvider(name = "openFilesWithIdWidthChanges")
218 public Object[][] openFilesWithIdWidthChanges()
221 String alignmentFilename,
225 int manualWidth, // ignored by testIdWidthChanges()
226 String structureFilename,
228 boolean secondaryStructureView,
229 TFType temperatureFactorType,
230 ViewerType viewerType,
234 return new Object[][] {
238 { "./test/files/annotation_label_width/sample.a2m", false, 50, 70,
240 "./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb",
241 "./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3_scores.json",
242 true, TFType.PLDDT, null, 115, 130 },
243 { "./test/files/annotation_label_width/sample.a2m", true, 50, 70,
245 "./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb",
246 "./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3_scores.json",
247 true, TFType.PLDDT, null, 115, 130 },