1 package jalview.ext.rbvi.chimera;
3 import static org.testng.AssertJUnit.assertTrue;
5 import jalview.api.structures.JalviewStructureDisplayI;
6 import jalview.datamodel.SequenceI;
7 import jalview.gui.AlignFrame;
8 import jalview.gui.StructureViewer;
9 import jalview.gui.StructureViewer.ViewerType;
10 import jalview.io.FormatAdapter;
12 import org.testng.annotations.AfterClass;
13 import org.testng.annotations.BeforeClass;
14 import org.testng.annotations.Test;
16 public class JalviewChimeraView
20 * @throws java.lang.Exception
22 @BeforeClass(alwaysRun = true)
23 public static void setUpBeforeClass() throws Exception
25 jalview.bin.Jalview.main(new String[]
26 { "-noquestionnaire -nonews -props", "test/src/jalview/ext/rbvi/chimera/testProps.jvprops" });
30 * @throws java.lang.Exception
33 public static void tearDownAfterClass() throws Exception
37 jalview.gui.Desktop.instance.closeAll_actionPerformed(null);
40 // ignore NullPointerException thrown by JMol
45 @Test(groups ={ "Functional" })
46 public void testSingleSeqViewJMol()
48 String inFile = "examples/1gaq.txt";
49 AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
50 inFile, FormatAdapter.FILE);
51 assertTrue("Didn't read input file " + inFile, af != null);
52 for (SequenceI sq : af.getViewport().getAlignment().getSequences())
54 SequenceI dsq = sq.getDatasetSequence();
55 while (dsq.getDatasetSequence() != null)
57 dsq = dsq.getDatasetSequence();
59 if (dsq.getPDBId() != null && dsq.getPDBId().size() > 0)
61 for (int q = 0; q < dsq.getPDBId().size(); q++)
63 final StructureViewer structureViewer = new StructureViewer(af
64 .getViewport().getStructureSelectionManager());
65 structureViewer.setViewerType(ViewerType.JMOL);
66 JalviewStructureDisplayI jmolViewer = structureViewer
67 .viewStructures(dsq.getPDBId().elementAt(q),
69 { sq }, af.getCurrentView().getAlignPanel());
71 * Wait for viewer thread to start
76 } catch (InterruptedException e)
80 jmolViewer.closeViewer(true);
81 // todo: break here means only once through this loop?
89 @Test(groups ={ "Functional" })
90 public void testSingleSeqViewChimera()
92 String inFile = "examples/1gaq.txt";
93 AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
94 inFile, FormatAdapter.FILE);
95 assertTrue("Didn't read input file " + inFile, af != null);
96 for (SequenceI sq : af.getViewport().getAlignment().getSequences())
98 SequenceI dsq = sq.getDatasetSequence();
99 while (dsq.getDatasetSequence() != null)
101 dsq = dsq.getDatasetSequence();
103 if (dsq.getPDBId() != null && dsq.getPDBId().size() > 0)
105 for (int q = 0; q < dsq.getPDBId().size(); q++)
107 final StructureViewer structureViewer = new StructureViewer(af
108 .getViewport().getStructureSelectionManager());
109 structureViewer.setViewerType(ViewerType.CHIMERA);
110 JalviewStructureDisplayI chimeraViewer = structureViewer
111 .viewStructures(dsq.getPDBId().elementAt(q),
113 { sq }, af.getCurrentView().getAlignPanel());
115 * Wait for viewer thread to start
120 } catch (InterruptedException e)
123 chimeraViewer.closeViewer(true);
124 // todo: break here means only once through this loop?