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