*/
package jalview.ext.jmol;
+import static org.junit.Assert.assertNotNull;
+import static org.testng.Assert.assertEquals;
import static org.testng.AssertJUnit.assertTrue;
import jalview.api.structures.JalviewStructureDisplayI;
import jalview.bin.Cache;
import jalview.bin.Jalview;
+import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SearchResultsI;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
import jalview.gui.JvOptionPane;
import jalview.gui.StructureViewer;
import jalview.gui.StructureViewer.ViewerType;
import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
+import jalview.io.FileLoader;
+
+import java.lang.reflect.InvocationTargetException;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
}
}
+ @Test(groups = { "Functional" })
+ public void testAddStrToSingleSeqViewJMol()
+ throws InvocationTargetException, InterruptedException
+ {
+ Cache.setProperty(Preferences.STRUCTURE_DISPLAY,
+ ViewerType.JMOL.name());
+ String inFile = "examples/1gaq.txt";
+ AlignFrame af = new jalview.io.FileLoader(true)
+ .LoadFileWaitTillLoaded(inFile, DataSourceType.FILE);
+ assertTrue("Didn't read input file " + inFile, af != null);
+ // show a structure for 4th Sequence
+ SequenceI sq1 = af.getViewport().getAlignment().getSequences().get(0);
+ final StructureViewer structureViewer = new StructureViewer(
+ af.getViewport().getStructureSelectionManager());
+ structureViewer.setViewerType(ViewerType.JMOL);
+ JalviewStructureDisplayI jmolViewer = structureViewer.viewStructures(
+ sq1.getDatasetSequence().getAllPDBEntries().elementAt(0),
+ new SequenceI[]
+ { sq1 }, af.getCurrentView().getAlignPanel());
+ /*
+ * Wait for viewer load thread to complete
+ */
+ try
+ {
+ while (!jmolViewer.getBinding().isFinishedInit())
+ {
+ Thread.sleep(500);
+ }
+ } catch (InterruptedException e)
+ {
+ }
+
+ assertTrue(jmolViewer.isVisible());
+
+ // add another pdb file and add it to view
+ final String _inFile = "examples/3W5V.pdb";
+ inFile = _inFile;
+ FileLoader fl = new FileLoader();
+ fl.LoadFile(af.getCurrentView(), _inFile, DataSourceType.FILE,
+ FileFormat.PDB);
+ try
+ {
+ int time = 0;
+ do
+ {
+ Thread.sleep(50); // hope we can avoid race condition
+
+ } while (++time < 30
+ && af.getViewport().getAlignment().getHeight() == 3);
+ } catch (Exception q)
+ {
+ }
+ ;
+ assertTrue("Didn't paste additional structure" + inFile,
+ af.getViewport().getAlignment().getHeight() > 3);
+ SequenceI sq2 = af.getViewport().getAlignment().getSequenceAt(3);
+ PDBEntry pdbe = sq2.getDatasetSequence().getAllPDBEntries().get(0);
+ assertTrue(pdbe.getFile().contains(inFile));
+ structureViewer.viewStructures(pdbe, new SequenceI[] { sq2 },
+ af.alignPanel);
+ /*
+ * Wait for viewer load thread to complete
+ */
+ try
+ {
+ while (structureViewer.isBusy())
+ {
+ Thread.sleep(500);
+ }
+ } catch (InterruptedException e)
+ {
+ }
+ assertEquals(jmolViewer.getBinding().getPdbCount(), 2);
+ String mouseOverTest = "[GLY]293:A.CA/2.1 #2164";
+ ((JalviewJmolBinding) jmolViewer.getBinding()).mouseOverStructure(2164,
+ mouseOverTest);
+ SearchResultsI highlight = af.alignPanel.getSeqPanel()
+ .getLastSearchResults();
+ assertNotNull("Didn't find highlight from second structure mouseover",
+ highlight.getResults(sq2, sq2.getStart(), sq2.getEnd()));
+ }
}