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