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.
21 package jalview.ext.rbvi.chimera;
23 import static org.testng.AssertJUnit.assertEquals;
24 import static org.testng.AssertJUnit.assertTrue;
26 import jalview.api.structures.JalviewStructureDisplayI;
27 import jalview.bin.Cache;
28 import jalview.datamodel.SequenceI;
29 import jalview.gui.AlignFrame;
30 import jalview.gui.Preferences;
31 import jalview.gui.StructureViewer;
32 import jalview.gui.StructureViewer.ViewerType;
33 import jalview.io.FormatAdapter;
35 import org.testng.annotations.AfterClass;
36 import org.testng.annotations.BeforeClass;
37 import org.testng.annotations.Test;
39 @Test(singleThreaded = true)
40 public class JalviewChimeraView
44 * @throws java.lang.Exception
46 @BeforeClass(alwaysRun = true)
47 public static void setUpBeforeClass() throws Exception
49 jalview.bin.Jalview.main(new String[] {
50 "-noquestionnaire -nonews -props",
51 "test/jalview/ext/rbvi/chimera/testProps.jvprops" });
55 * @throws java.lang.Exception
57 @AfterClass(alwaysRun = true)
58 public static void tearDownAfterClass() throws Exception
60 jalview.gui.Desktop.instance.closeAll_actionPerformed(null);
63 @Test(groups = { "Functional" })
64 public void testSingleSeqViewChimera()
66 Cache.setProperty(Preferences.STRUCTURE_DISPLAY,
67 ViewerType.CHIMERA.name());
68 String inFile = "examples/1gaq.txt";
69 AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
70 inFile, FormatAdapter.FILE);
71 assertTrue("Didn't read input file " + inFile, af != null);
72 for (SequenceI sq : af.getViewport().getAlignment().getSequences())
74 System.out.println("** sq=" + sq.getName());
75 SequenceI dsq = sq.getDatasetSequence();
76 while (dsq.getDatasetSequence() != null)
78 dsq = dsq.getDatasetSequence();
80 if (dsq.getAllPDBEntries() != null
81 && dsq.getAllPDBEntries().size() > 0)
83 for (int q = 0; q < dsq.getAllPDBEntries().size(); q++)
85 final StructureViewer structureViewer = new StructureViewer(af
86 .getViewport().getStructureSelectionManager());
87 structureViewer.setViewerType(ViewerType.CHIMERA);
88 JalviewStructureDisplayI chimeraViewer = structureViewer
89 .viewStructures(dsq.getAllPDBEntries().elementAt(q),
90 new SequenceI[] { sq }, af.getCurrentView()
93 * Wait for viewer load thread to complete
95 while (!chimeraViewer.getBinding().isFinishedInit())
100 } catch (InterruptedException e)
104 assertEquals(1, chimeraViewer.getBinding().getPdbCount());
105 chimeraViewer.closeViewer(true);
106 // todo: break here means only once through this loop?