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 java.util.Date;
24 import java.util.List;
26 import org.testng.Assert;
27 import org.testng.annotations.AfterClass;
28 import org.testng.annotations.AfterMethod;
29 import org.testng.annotations.BeforeClass;
30 import org.testng.annotations.DataProvider;
31 import org.testng.annotations.Test;
33 import jalview.api.AlignViewportI;
34 import jalview.datamodel.AlignmentAnnotation;
35 import jalview.datamodel.AlignmentI;
36 import jalview.datamodel.SequenceI;
37 import jalview.gui.AlignFrame;
38 import jalview.gui.AlignmentPanel;
39 import jalview.gui.Desktop;
40 import jalview.gui.JvOptionPane;
41 import jalview.gui.StructureViewerBase;
44 public class CommandsTest2
46 @BeforeClass(alwaysRun = true)
47 public static void setUpBeforeClass() throws Exception
49 Cache.loadProperties("test/jalview/bin/commandsTest.jvprops");
50 Date oneHourFromNow = new Date(
51 System.currentTimeMillis() + 3600 * 1000);
52 Cache.setDateProperty("JALVIEW_NEWS_RSS_LASTMODIFIED", oneHourFromNow);
53 if (Desktop.instance != null)
54 Desktop.instance.closeAll_actionPerformed(null);
58 @AfterClass(alwaysRun = true)
59 public static void resetProps()
61 Cache.loadProperties("test/jalview/testProps.jvprops");
64 @BeforeClass(alwaysRun = true)
65 public void setUpJvOptionPane()
67 JvOptionPane.setInteractiveMode(false);
68 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
71 @AfterMethod(alwaysRun = true)
72 public void tearDown()
74 Desktop.closeDesktop();
79 { "Functional", "testTask1" },
80 dataProvider = "structureOpeningArgsParams",
81 singleThreaded = true)
82 public void structureOpeningArgsTest(String cmdLine, int seqNum,
83 int annNum, int viewerNum)
85 String[] args = cmdLine.split("\\s+");
87 CommandsTest.callJalviewMain(args);
88 while (Desktop.instance != null
89 && Desktop.instance.operationsAreInProgress())
93 // sleep for slow build server to open annotations and viewer windows
94 Thread.sleep(viewerNum * 50);
95 } catch (InterruptedException e)
102 AlignFrame[] afs = Desktop.getDesktopAlignFrames();
103 Assert.assertNotNull(afs);
104 Assert.assertTrue(afs.length > 0);
106 AlignFrame af = afs[0];
107 Assert.assertNotNull(af);
109 AlignmentPanel ap = af.alignPanel;
110 Assert.assertNotNull(ap);
112 AlignmentI al = ap.getAlignment();
113 Assert.assertNotNull(al);
115 List<SequenceI> seqs = al.getSequences();
116 Assert.assertNotNull(seqs);
118 Assert.assertEquals(seqs.size(), seqNum, "Wrong number of sequences");
120 AlignViewportI av = ap.getAlignViewport();
121 Assert.assertNotNull(av);
123 AlignmentAnnotation[] aas = al.getAlignmentAnnotation();
126 for (AlignmentAnnotation aa : aas)
132 Assert.assertEquals(visibleAnn, annNum,
133 "Wrong number of visible annotations");
137 List<StructureViewerBase> openViewers = Desktop.instance
138 .getStructureViewers(ap, null);
139 Assert.assertNotNull(openViewers);
141 for (StructureViewerBase svb : openViewers)
146 Assert.assertEquals(count, viewerNum,
147 "Wrong number of structure viewers opened");
151 @DataProvider(name = "structureOpeningArgsParams")
152 public Object[][] structureOpeningArgsParams()
158 int structureViewerNum,
160 return new Object[][] {
164 { "--gui --nonews --nosplash --debug "
165 + "--append=examples/uniref50.fa "
166 + "--colour=gecos-flower "
167 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
168 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
169 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
171 { "--gui --nonews --nosplash --debug "
172 + "--append=examples/uniref50.fa "
173 + "--colour=gecos-flower "
174 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
175 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
176 + "--props=test/jalview/bin/commandsTest2.jvprops2 ",
178 { "--gui --nonews --nosplash --debug "
179 + "--append=examples/uniref50.fa "
180 + "--colour=gecos-flower "
181 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
182 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
183 + "--noshowssannotations "
184 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
186 { "--gui --nonews --nosplash --debug "
187 + "--append=examples/uniref50.fa "
188 + "--colour=gecos-flower "
189 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
190 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
191 + "--noshowannotations "
192 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
194 { "--gui --nonews --nosplash --debug "
195 + "--append=examples/uniref50.fa "
196 + "--colour=gecos-flower "
197 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
198 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
199 + "--noshowannotations " + "--noshowssannotations "
200 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
202 { "--gui --nonews --nosplash --debug "
203 + "--append=examples/uniref50.fa "
204 + "--colour=gecos-flower "
205 + "--structure=[seqid=FER1_SPIOL]examples/AlphaFold/AF-P00221-F1-model_v4.cif "
206 + "--paematrix=examples/AlphaFold/AF-P00221-F1-predicted_aligned_error_v4.json "
207 + "--noshowannotations " + "--noshowssannotations "
208 + "--props=test/jalview/bin/commandsTest2.jvprops1 ",
210 { "--gui --nonews --nosplash --debug --nowebservicediscovery --props=test/jalview/bin/commandsTest.jvprops --argfile=test/jalview/bin/commandsTest2.argfile1 ",
212 { "--gui --nonews --nosplash --debug --nowebservicediscovery --props=test/jalview/bin/commandsTest.jvprops --argfile=test/jalview/bin/commandsTest2.argfile2 ",
214 { "--gui --nonews --nosplash --debug --nowebservicediscovery --props=test/jalview/bin/commandsTest.jvprops --open=./examples/test_fab41.result/sample.a2m "
216 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb "
217 + "--structureviewer=none "
218 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_2_model_4.pdb "
219 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_3_model_2.pdb",
221 { "--gui --nonews --nosplash --debug --nowebservicediscovery --props=test/jalview/bin/commandsTest.jvprops --open=./examples/test_fab41.result/sample.a2m "
223 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb "
224 + "--noallstructures " + "--structureviewer=none "
225 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_2_model_4.pdb "
226 + "--structure=./examples/test_fab41.result/test_fab41_unrelaxed_rank_3_model_2.pdb",