JAL-1333 more abstraction and refactoring and working demo of Jalview talking to...
[jalview.git] / test / jalview / ext / rbvi / chimera / JalviewChimeraView.java
1 package jalview.ext.rbvi.chimera;
2
3 import static org.junit.Assert.*;
4 import jalview.datamodel.PDBEntry;
5 import jalview.datamodel.SequenceI;
6 import jalview.gui.AlignFrame;
7 import jalview.gui.StructureViewer;
8 import jalview.gui.StructureViewer.Viewer;
9 import jalview.io.FormatAdapter;
10
11 import java.awt.Desktop;
12 import java.io.File;
13
14 import org.junit.After;
15 import org.junit.AfterClass;
16 import org.junit.Before;
17 import org.junit.BeforeClass;
18 import org.junit.Test;
19
20 public class JalviewChimeraView
21 {
22
23   /**
24    * @throws java.lang.Exception
25    */
26   @BeforeClass
27   public static void setUpBeforeClass() throws Exception
28   {
29     jalview.bin.Jalview.main(new String[]
30     { "-noquestionnaire -nonews -props", "test/src/jalview/ext/rbvi/chimera/testProps.jvprops" });
31   }
32
33   /**
34    * @throws java.lang.Exception
35    */
36   @AfterClass
37   public static void tearDownAfterClass() throws Exception
38   {
39     jalview.gui.Desktop.instance.closeAll_actionPerformed(null);
40
41   }
42
43
44   @Test
45   public void testSingleSeqView()
46   {
47     String inFile = "examples/1gaq.txt";
48     AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
49             inFile, FormatAdapter.FILE);
50     assertTrue("Didn't read input file " + inFile, af != null);
51     for (SequenceI sq:af.getViewport().getAlignment().getSequences())
52     {
53       SequenceI dsq=sq.getDatasetSequence();
54       while (dsq.getDatasetSequence()!=null)
55       {
56         dsq=dsq.getDatasetSequence();
57       }
58       if (dsq.getPDBId()!=null && dsq.getPDBId().size()>0) {
59         for (int q=0;q<dsq.getPDBId().size();q++) 
60         {
61           new StructureViewer(af.getViewport().getStructureSelectionManager()).viewStructures(Viewer.JMOL,
62                   af.getCurrentView().getAlignPanel(),
63                   new PDBEntry[] { (PDBEntry)dsq.getPDBId().elementAt(q) },
64                   new SequenceI[][] { new SequenceI[] { sq } });
65
66           new StructureViewer(af.getViewport().getStructureSelectionManager()).viewStructures(Viewer.CHIMERA,
67                   af.getCurrentView().getAlignPanel(),
68                   new PDBEntry[] { (PDBEntry)dsq.getPDBId().elementAt(q) },
69                   new SequenceI[][] { new SequenceI[] { sq } });
70           break;
71         }
72         break;
73       }
74    }
75     try {
76       Thread.sleep(200000);
77     } catch (InterruptedException q)
78     {
79       
80     }
81   }
82 }