JAL-1333 more abstraction and refactoring and working demo of Jalview talking to...
[jalview.git] / test / jalview / ext / rbvi / chimera / JalviewChimeraView.java
diff --git a/test/jalview/ext/rbvi/chimera/JalviewChimeraView.java b/test/jalview/ext/rbvi/chimera/JalviewChimeraView.java
new file mode 100644 (file)
index 0000000..1736af5
--- /dev/null
@@ -0,0 +1,82 @@
+package jalview.ext.rbvi.chimera;
+
+import static org.junit.Assert.*;
+import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SequenceI;
+import jalview.gui.AlignFrame;
+import jalview.gui.StructureViewer;
+import jalview.gui.StructureViewer.Viewer;
+import jalview.io.FormatAdapter;
+
+import java.awt.Desktop;
+import java.io.File;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class JalviewChimeraView
+{
+
+  /**
+   * @throws java.lang.Exception
+   */
+  @BeforeClass
+  public static void setUpBeforeClass() throws Exception
+  {
+    jalview.bin.Jalview.main(new String[]
+    { "-noquestionnaire -nonews -props", "test/src/jalview/ext/rbvi/chimera/testProps.jvprops" });
+  }
+
+  /**
+   * @throws java.lang.Exception
+   */
+  @AfterClass
+  public static void tearDownAfterClass() throws Exception
+  {
+    jalview.gui.Desktop.instance.closeAll_actionPerformed(null);
+
+  }
+
+
+  @Test
+  public void testSingleSeqView()
+  {
+    String inFile = "examples/1gaq.txt";
+    AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
+            inFile, FormatAdapter.FILE);
+    assertTrue("Didn't read input file " + inFile, af != null);
+    for (SequenceI sq:af.getViewport().getAlignment().getSequences())
+    {
+      SequenceI dsq=sq.getDatasetSequence();
+      while (dsq.getDatasetSequence()!=null)
+      {
+        dsq=dsq.getDatasetSequence();
+      }
+      if (dsq.getPDBId()!=null && dsq.getPDBId().size()>0) {
+        for (int q=0;q<dsq.getPDBId().size();q++) 
+        {
+          new StructureViewer(af.getViewport().getStructureSelectionManager()).viewStructures(Viewer.JMOL,
+                  af.getCurrentView().getAlignPanel(),
+                  new PDBEntry[] { (PDBEntry)dsq.getPDBId().elementAt(q) },
+                  new SequenceI[][] { new SequenceI[] { sq } });
+
+          new StructureViewer(af.getViewport().getStructureSelectionManager()).viewStructures(Viewer.CHIMERA,
+                  af.getCurrentView().getAlignPanel(),
+                  new PDBEntry[] { (PDBEntry)dsq.getPDBId().elementAt(q) },
+                  new SequenceI[][] { new SequenceI[] { sq } });
+          break;
+        }
+        break;
+      }
+   }
+    try {
+      Thread.sleep(200000);
+    } catch (InterruptedException q)
+    {
+      
+    }
+  }
+}