1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.ext.jmol; |
22 |
|
|
23 |
|
import static org.junit.Assert.assertNotNull; |
24 |
|
import static org.testng.Assert.assertEquals; |
25 |
|
import static org.testng.AssertJUnit.assertTrue; |
26 |
|
|
27 |
|
import jalview.api.structures.JalviewStructureDisplayI; |
28 |
|
import jalview.bin.Cache; |
29 |
|
import jalview.bin.Jalview; |
30 |
|
import jalview.datamodel.PDBEntry; |
31 |
|
import jalview.datamodel.SearchResultsI; |
32 |
|
import jalview.datamodel.SequenceI; |
33 |
|
import jalview.gui.AlignFrame; |
34 |
|
import jalview.gui.JvOptionPane; |
35 |
|
import jalview.gui.Preferences; |
36 |
|
import jalview.gui.StructureViewer; |
37 |
|
import jalview.gui.StructureViewer.ViewerType; |
38 |
|
import jalview.io.DataSourceType; |
39 |
|
import jalview.io.FileFormat; |
40 |
|
import jalview.io.FileLoader; |
41 |
|
|
42 |
|
import java.lang.reflect.InvocationTargetException; |
43 |
|
|
44 |
|
import org.testng.annotations.AfterClass; |
45 |
|
import org.testng.annotations.BeforeClass; |
46 |
|
import org.testng.annotations.Test; |
47 |
|
|
48 |
|
@Test(singleThreaded = true) |
|
|
| 94.7% |
Uncovered Elements: 4 (76) |
Complexity: 18 |
Complexity Density: 0.32 |
|
49 |
|
public class JmolViewerTest |
50 |
|
{ |
51 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
52 |
1 |
@BeforeClass(alwaysRun = true)... |
53 |
|
public void setUpJvOptionPane() |
54 |
|
{ |
55 |
1 |
JvOptionPane.setInteractiveMode(false); |
56 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
57 |
|
} |
58 |
|
|
59 |
|
|
60 |
|
@throws |
61 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
62 |
1 |
@BeforeClass(alwaysRun = true)... |
63 |
|
public static void setUpBeforeClass() throws Exception |
64 |
|
{ |
65 |
1 |
Jalview.main( |
66 |
|
new String[] |
67 |
|
{ "-noquestionnaire", "-nonews", "-props", |
68 |
|
"test/jalview/ext/rbvi/chimera/testProps.jvprops" }); |
69 |
|
} |
70 |
|
|
71 |
|
|
72 |
|
@throws |
73 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
74 |
1 |
@AfterClass(alwaysRun = true)... |
75 |
|
public static void tearDownAfterClass() throws Exception |
76 |
|
{ |
77 |
1 |
jalview.gui.Desktop.instance.closeAll_actionPerformed(null); |
78 |
|
} |
79 |
|
|
|
|
| 85.2% |
Uncovered Elements: 4 (27) |
Complexity: 7 |
Complexity Density: 0.37 |
1PASS
|
|
80 |
1 |
@Test(groups = { "Functional" })... |
81 |
|
public void testSingleSeqViewJMol() |
82 |
|
{ |
83 |
1 |
Cache.setProperty(Preferences.STRUCTURE_DISPLAY, |
84 |
|
ViewerType.JMOL.name()); |
85 |
1 |
String inFile = "examples/1gaq.txt"; |
86 |
1 |
AlignFrame af = new jalview.io.FileLoader() |
87 |
|
.LoadFileWaitTillLoaded(inFile, DataSourceType.FILE); |
88 |
1 |
assertTrue("Didn't read input file " + inFile, af != null); |
89 |
1 |
for (SequenceI sq : af.getViewport().getAlignment().getSequences()) |
90 |
|
{ |
91 |
1 |
SequenceI dsq = sq.getDatasetSequence(); |
92 |
1 |
while (dsq.getDatasetSequence() != null) |
93 |
|
{ |
94 |
0 |
dsq = dsq.getDatasetSequence(); |
95 |
|
} |
96 |
1 |
if (dsq.getAllPDBEntries() != null |
97 |
|
&& dsq.getAllPDBEntries().size() > 0) |
98 |
|
{ |
99 |
1 |
for (int q = 0; q < dsq.getAllPDBEntries().size(); q++) |
100 |
|
{ |
101 |
1 |
final StructureViewer structureViewer = new StructureViewer( |
102 |
|
af.getViewport().getStructureSelectionManager()); |
103 |
1 |
structureViewer.setViewerType(ViewerType.JMOL); |
104 |
1 |
JalviewStructureDisplayI jmolViewer = structureViewer |
105 |
|
.viewStructures(dsq.getAllPDBEntries().elementAt(q), |
106 |
|
new SequenceI[] |
107 |
|
{ sq }, af.getCurrentView().getAlignPanel()); |
108 |
|
|
109 |
|
|
110 |
|
|
111 |
1 |
try |
112 |
|
{ |
113 |
2 |
while (!jmolViewer.getBinding().isFinishedInit()) |
114 |
|
{ |
115 |
1 |
Thread.sleep(500); |
116 |
|
} |
117 |
|
} catch (InterruptedException e) |
118 |
|
{ |
119 |
|
} |
120 |
|
|
121 |
1 |
jmolViewer.closeViewer(true); |
122 |
|
|
123 |
1 |
break; |
124 |
|
} |
125 |
1 |
break; |
126 |
|
} |
127 |
|
} |
128 |
|
} |
129 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (40) |
Complexity: 8 |
Complexity Density: 0.24 |
1PASS
|
|
130 |
1 |
@Test(groups = { "Functional" })... |
131 |
|
public void testAddStrToSingleSeqViewJMol() |
132 |
|
throws InvocationTargetException, InterruptedException |
133 |
|
{ |
134 |
1 |
Cache.setProperty(Preferences.STRUCTURE_DISPLAY, |
135 |
|
ViewerType.JMOL.name()); |
136 |
1 |
String inFile = "examples/1gaq.txt"; |
137 |
1 |
AlignFrame af = new jalview.io.FileLoader(true) |
138 |
|
.LoadFileWaitTillLoaded(inFile, DataSourceType.FILE); |
139 |
1 |
assertTrue("Didn't read input file " + inFile, af != null); |
140 |
|
|
141 |
1 |
SequenceI sq1 = af.getViewport().getAlignment().getSequences().get(0); |
142 |
1 |
final StructureViewer structureViewer = new StructureViewer( |
143 |
|
af.getViewport().getStructureSelectionManager()); |
144 |
1 |
structureViewer.setViewerType(ViewerType.JMOL); |
145 |
1 |
JalviewStructureDisplayI jmolViewer = structureViewer.viewStructures( |
146 |
|
sq1.getDatasetSequence().getAllPDBEntries().elementAt(0), |
147 |
|
new SequenceI[] |
148 |
|
{ sq1 }, af.getCurrentView().getAlignPanel()); |
149 |
|
|
150 |
|
|
151 |
|
|
152 |
1 |
try |
153 |
|
{ |
154 |
2 |
while (!jmolViewer.getBinding().isFinishedInit()) |
155 |
|
{ |
156 |
1 |
Thread.sleep(500); |
157 |
|
} |
158 |
|
} catch (InterruptedException e) |
159 |
|
{ |
160 |
|
} |
161 |
|
|
162 |
1 |
assertTrue(jmolViewer.isVisible()); |
163 |
|
|
164 |
|
|
165 |
1 |
final String _inFile = "examples/3W5V.pdb"; |
166 |
1 |
inFile = _inFile; |
167 |
1 |
FileLoader fl = new FileLoader(); |
168 |
1 |
fl.LoadFile(af.getCurrentView(), _inFile, DataSourceType.FILE, |
169 |
|
FileFormat.PDB); |
170 |
1 |
try |
171 |
|
{ |
172 |
1 |
int time = 0; |
173 |
1 |
do |
174 |
|
{ |
175 |
3 |
Thread.sleep(50); |
176 |
|
|
177 |
3 |
} while (++time < 30 |
178 |
|
&& af.getViewport().getAlignment().getHeight() == 3); |
179 |
|
} catch (Exception q) |
180 |
|
{ |
181 |
|
} |
182 |
1 |
; |
183 |
1 |
assertTrue("Didn't paste additional structure" + inFile, |
184 |
|
af.getViewport().getAlignment().getHeight() > 3); |
185 |
1 |
SequenceI sq2 = af.getViewport().getAlignment().getSequenceAt(3); |
186 |
1 |
PDBEntry pdbe = sq2.getDatasetSequence().getAllPDBEntries().get(0); |
187 |
1 |
assertTrue(pdbe.getFile().contains(inFile)); |
188 |
1 |
structureViewer.viewStructures(pdbe, new SequenceI[] { sq2 }, |
189 |
|
af.alignPanel); |
190 |
|
|
191 |
|
|
192 |
|
|
193 |
1 |
try |
194 |
|
{ |
195 |
3 |
while (structureViewer.isBusy()) |
196 |
|
{ |
197 |
2 |
Thread.sleep(500); |
198 |
|
} |
199 |
|
} catch (InterruptedException e) |
200 |
|
{ |
201 |
|
} |
202 |
1 |
assertEquals(jmolViewer.getBinding().getPdbCount(), 2); |
203 |
1 |
String mouseOverTest = "[GLY]293:A.CA/2.1 #2164"; |
204 |
1 |
((JalviewJmolBinding) jmolViewer.getBinding()).mouseOverStructure(2164, |
205 |
|
mouseOverTest); |
206 |
1 |
SearchResultsI highlight = af.alignPanel.getSeqPanel() |
207 |
|
.getLastSearchResults(); |
208 |
1 |
assertNotNull("Didn't find highlight from second structure mouseover", |
209 |
|
highlight.getResults(sq2, sq2.getStart(), sq2.getEnd())); |
210 |
|
} |
211 |
|
|
212 |
|
} |