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, int idWidth1min,
91 int idWidth1max, int manualWidth, String structureFilename,
92 String paeFilename, boolean secondaryStructureView,
93 TFType temperatureFactorType, ViewerType viewerType,
94 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, "idWidth (" + idWidth
114 + ") is not less wide than" + idWidth1max);
116 AlignmentI al = av.getAlignment();
117 SequenceI s = al.getSequenceAt(0);
118 AlignmentPanel ap = af.alignPanel;
120 File structureFile = new File(structureFilename);
121 File paeFile = new File(paeFilename);
123 StructureViewer sv = StructureChooser.openStructureFileForSequence(null,
124 null, ap, s, false, structureFile.getAbsolutePath(),
125 temperatureFactorType, paeFile.getAbsolutePath(), true,
126 secondaryStructureView, false, viewerType);
127 // give time for annotations to open
130 Thread.sleep(200); // to allow alignment annotations to open
131 } catch (InterruptedException e)
133 // TODO Auto-generated catch block
137 idWidth = av.getIdWidth();
138 assertTrue(idWidth > idWidth2min,
139 "idWidth (" + idWidth + ") is not greater than " + idWidth2min);
140 assertTrue(idWidth < idWidth2max, "idWidth (" + idWidth
141 + ") is not less wide than" + idWidth2max);
146 { "Functional", "testTask1" },
147 dataProvider = "openFilesWithIdWidthChanges")
148 public void testIdWidthNoChanges(String alignmentFilename,
149 int idWidth1min, int idWidth1max, int manualWidth,
150 String structureFilename, String paeFilename,
151 boolean secondaryStructureView, TFType temperatureFactorType,
152 ViewerType viewerType, int idWidth2min, int idWidth2max)
154 AlignFrame af = new FileLoader()
155 .LoadFileWaitTillLoaded(alignmentFilename, DataSourceType.FILE);
158 Thread.sleep(200); // to allow alignment annotations to open
159 } catch (InterruptedException e)
161 // TODO Auto-generated catch block
164 AlignViewport av = af.getCurrentView();
168 idWidth = av.getIdWidth();
169 assertTrue(idWidth > idWidth1min,
170 "idWidth (" + idWidth + ") is not greater than " + idWidth1min);
171 assertTrue(idWidth < idWidth1max, "idWidth (" + idWidth
172 + ") is not less wide than" + idWidth1max);
174 AlignmentI al = av.getAlignment();
175 SequenceI s = al.getSequenceAt(0);
176 AlignmentPanel ap = af.alignPanel;
178 // set width manually
179 av.setIdWidth(manualWidth);
180 ap.validateAnnotationDimensions(false);
181 ap.paintAlignment(true, false);
182 ap.getIdPanel().getIdCanvas().setManuallyAdjusted(true);
184 idWidth = av.getIdWidth();
185 assertEquals(idWidth, manualWidth,
186 "idWidth is not set to the manually set width " + manualWidth);
188 File structureFile = new File(structureFilename);
189 File paeFile = new File(paeFilename);
191 StructureViewer sv = StructureChooser.openStructureFileForSequence(null,
192 null, ap, s, false, structureFile.getAbsolutePath(),
193 temperatureFactorType, paeFile.getAbsolutePath(), false,
194 secondaryStructureView, false, viewerType);
196 idWidth = ap.getIdPanel().getWidth();// av.getIdWidth();
197 idWidth = av.getIdWidth();
198 assertEquals(idWidth, manualWidth,
199 "idWidth is not set to the manually set width " + manualWidth
200 + " after adding structure annotations");
201 assertFalse(idWidth > idWidth2min,
202 "idWidth (" + idWidth + ") is greater than " + idWidth2min);
205 @DataProvider(name = "openFilesWithIdWidthChanges")
206 public Object[][] openFilesWithIdWidthChanges()
209 String alignmentFilename,
212 int manualWidth, // ignored by testIdWidthChanges()
213 String structureFilename,
215 boolean secondaryStructureView,
216 TFType temperatureFactorType,
217 ViewerType viewerType,
221 return new Object[][] {
227 "./test/files/annotation_label_width/sample.a2m", 50, 70, 100,
228 "./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb",
229 "./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3_scores.json",
230 true, TFType.PLDDT, null, 115, 130