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