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 java.awt.Container; |
24 |
|
import java.awt.event.ComponentEvent; |
25 |
|
import java.awt.event.ComponentListener; |
26 |
|
import java.io.File; |
27 |
|
import java.net.URL; |
28 |
|
import java.util.ArrayList; |
29 |
|
import java.util.List; |
30 |
|
import java.util.Map; |
31 |
|
import java.util.StringTokenizer; |
32 |
|
import java.util.Vector; |
33 |
|
|
34 |
|
import org.jmol.adapter.smarter.SmarterJmolAdapter; |
35 |
|
import org.jmol.api.JmolAppConsoleInterface; |
36 |
|
import org.jmol.api.JmolSelectionListener; |
37 |
|
import org.jmol.api.JmolStatusListener; |
38 |
|
import org.jmol.api.JmolViewer; |
39 |
|
import org.jmol.c.CBK; |
40 |
|
import org.jmol.viewer.Viewer; |
41 |
|
|
42 |
|
import jalview.api.AlignmentViewPanel; |
43 |
|
import jalview.api.FeatureRenderer; |
44 |
|
import jalview.api.SequenceRenderer; |
45 |
|
import jalview.bin.Cache; |
46 |
|
import jalview.datamodel.PDBEntry; |
47 |
|
import jalview.datamodel.SequenceI; |
48 |
|
import jalview.gui.IProgressIndicator; |
49 |
|
import jalview.gui.StructureViewer.ViewerType; |
50 |
|
import jalview.io.DataSourceType; |
51 |
|
import jalview.io.StructureFile; |
52 |
|
import jalview.structure.AtomSpec; |
53 |
|
import jalview.structure.StructureCommand; |
54 |
|
import jalview.structure.StructureCommandI; |
55 |
|
import jalview.structure.StructureSelectionManager; |
56 |
|
import jalview.structures.models.AAStructureBindingModel; |
57 |
|
import javajs.util.BS; |
58 |
|
|
|
|
| 52.9% |
Uncovered Elements: 210 (446) |
Complexity: 137 |
Complexity Density: 0.49 |
|
59 |
|
public abstract class JalviewJmolBinding extends AAStructureBindingModel |
60 |
|
implements JmolStatusListener, JmolSelectionListener, |
61 |
|
ComponentListener |
62 |
|
{ |
63 |
|
private String lastMessage; |
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
private boolean associateNewStructs = false; |
70 |
|
|
71 |
|
private Vector<String> atomsPicked = new Vector<>(); |
72 |
|
|
73 |
|
private String lastCommand; |
74 |
|
|
75 |
|
private boolean loadedInline; |
76 |
|
|
77 |
|
private StringBuffer resetLastRes = new StringBuffer(); |
78 |
|
|
79 |
|
public Viewer jmolViewer; |
80 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
81 |
7 |
public JalviewJmolBinding(StructureSelectionManager ssm,... |
82 |
|
PDBEntry[] pdbentry, SequenceI[][] sequenceIs, |
83 |
|
DataSourceType protocol) |
84 |
|
{ |
85 |
7 |
super(ssm, pdbentry, sequenceIs, protocol); |
86 |
7 |
setStructureCommands(new JmolCommands()); |
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
} |
95 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
96 |
0 |
public JalviewJmolBinding(StructureSelectionManager ssm,... |
97 |
|
SequenceI[][] seqs, Viewer theViewer) |
98 |
|
{ |
99 |
0 |
super(ssm, seqs); |
100 |
|
|
101 |
0 |
jmolViewer = theViewer; |
102 |
0 |
jmolViewer.setJmolStatusListener(this); |
103 |
0 |
jmolViewer.addSelectionListener(this); |
104 |
0 |
setStructureCommands(new JmolCommands()); |
105 |
|
} |
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
@return |
112 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
113 |
7 |
public String getViewerTitle()... |
114 |
|
{ |
115 |
7 |
return getViewerTitle("Jmol", true); |
116 |
|
} |
117 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
118 |
83 |
private String jmolScript(String script)... |
119 |
|
{ |
120 |
83 |
Cache.log.debug(">>Jmol>> " + script); |
121 |
83 |
String s = jmolViewer.evalStringQuiet(script); |
122 |
83 |
Cache.log.debug("<<Jmol<< " + s); |
123 |
|
|
124 |
83 |
return s; |
125 |
|
} |
126 |
|
|
|
|
| 84.6% |
Uncovered Elements: 2 (13) |
Complexity: 4 |
Complexity Density: 0.44 |
|
127 |
28 |
@Override... |
128 |
|
public List<String> executeCommand(StructureCommandI command, |
129 |
|
boolean getReply) |
130 |
|
{ |
131 |
28 |
if (command == null) |
132 |
|
{ |
133 |
0 |
return null; |
134 |
|
} |
135 |
28 |
String cmd = command.getCommand(); |
136 |
28 |
jmolHistory(false); |
137 |
28 |
if (lastCommand == null || !lastCommand.equals(cmd)) |
138 |
|
{ |
139 |
24 |
jmolScript(cmd + "\n"); |
140 |
|
} |
141 |
28 |
jmolHistory(true); |
142 |
28 |
lastCommand = cmd; |
143 |
28 |
return null; |
144 |
|
} |
145 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
146 |
0 |
public void createImage(String file, String type, int quality)... |
147 |
|
{ |
148 |
0 |
System.out.println("JMOL CREATE IMAGE"); |
149 |
|
} |
150 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
151 |
4 |
@Override... |
152 |
|
public String createImage(String fileName, String type, |
153 |
|
Object textOrBytes, int quality) |
154 |
|
{ |
155 |
4 |
System.out.println("JMOL CREATE IMAGE"); |
156 |
4 |
return null; |
157 |
|
} |
158 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
159 |
0 |
@Override... |
160 |
|
public String eval(String strEval) |
161 |
|
{ |
162 |
|
|
163 |
|
|
164 |
0 |
return null; |
165 |
|
} |
166 |
|
|
167 |
|
|
168 |
|
|
169 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
170 |
0 |
@Override... |
171 |
|
public float[][] functionXY(String functionName, int x, int y) |
172 |
|
{ |
173 |
0 |
return null; |
174 |
|
} |
175 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
176 |
0 |
@Override... |
177 |
|
public float[][][] functionXYZ(String functionName, int nx, int ny, |
178 |
|
int nz) |
179 |
|
{ |
180 |
|
|
181 |
0 |
return null; |
182 |
|
} |
183 |
|
|
184 |
|
|
185 |
|
|
186 |
|
|
187 |
|
|
188 |
|
|
189 |
|
private int _modelFileNameMap[]; |
190 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (23) |
Complexity: 7 |
Complexity Density: 0.54 |
|
191 |
74 |
@Override... |
192 |
|
public synchronized String[] getStructureFiles() |
193 |
|
{ |
194 |
74 |
if (jmolViewer == null) |
195 |
|
{ |
196 |
2 |
return new String[0]; |
197 |
|
} |
198 |
|
|
199 |
72 |
if (modelFileNames == null) |
200 |
|
{ |
201 |
35 |
int modelCount = jmolViewer.ms.mc; |
202 |
35 |
String filePath = null; |
203 |
35 |
List<String> mset = new ArrayList<>(); |
204 |
71 |
for (int i = 0; i < modelCount; ++i) |
205 |
|
{ |
206 |
|
|
207 |
|
|
208 |
|
|
209 |
|
|
210 |
36 |
filePath = jmolViewer.ms.getModelFileName(i); |
211 |
36 |
if (filePath != null && !mset.contains(filePath)) |
212 |
|
{ |
213 |
7 |
mset.add(filePath); |
214 |
|
} |
215 |
|
} |
216 |
35 |
if (!mset.isEmpty()) |
217 |
|
{ |
218 |
6 |
modelFileNames = mset.toArray(new String[mset.size()]); |
219 |
|
} |
220 |
|
} |
221 |
|
|
222 |
72 |
return modelFileNames; |
223 |
|
} |
224 |
|
|
225 |
|
|
226 |
|
|
227 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
228 |
0 |
@Override... |
229 |
|
public Map<String, Object> getRegistryInfo() |
230 |
|
{ |
231 |
|
|
232 |
0 |
return null; |
233 |
|
} |
234 |
|
|
235 |
|
|
236 |
|
|
237 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
238 |
0 |
public void handlePopupMenu(int x, int y)... |
239 |
|
{ |
240 |
|
|
241 |
|
|
242 |
|
} |
243 |
|
|
244 |
|
|
245 |
|
|
246 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
247 |
0 |
@Override... |
248 |
|
public void highlightAtoms(List<AtomSpec> atoms) |
249 |
|
{ |
250 |
0 |
if (atoms != null) |
251 |
|
{ |
252 |
0 |
if (resetLastRes.length() > 0) |
253 |
|
{ |
254 |
0 |
jmolScript(resetLastRes.toString()); |
255 |
0 |
resetLastRes.setLength(0); |
256 |
|
} |
257 |
0 |
for (AtomSpec atom : atoms) |
258 |
|
{ |
259 |
0 |
highlightAtom(atom.getAtomIndex(), atom.getPdbResNum(), |
260 |
|
atom.getChain(), atom.getPdbFile()); |
261 |
|
} |
262 |
|
} |
263 |
|
} |
264 |
|
|
265 |
|
|
|
|
| 0% |
Uncovered Elements: 19 (19) |
Complexity: 3 |
Complexity Density: 0.2 |
|
266 |
0 |
public void highlightAtom(int atomIndex, int pdbResNum, String chain,... |
267 |
|
String pdbfile) |
268 |
|
{ |
269 |
0 |
String modelId = getModelIdForFile(pdbfile); |
270 |
0 |
if (modelId.isEmpty()) |
271 |
|
{ |
272 |
0 |
return; |
273 |
|
} |
274 |
|
|
275 |
0 |
jmolHistory(false); |
276 |
|
|
277 |
0 |
StringBuilder selection = new StringBuilder(32); |
278 |
0 |
StringBuilder cmd = new StringBuilder(64); |
279 |
0 |
selection.append("select ").append(String.valueOf(pdbResNum)); |
280 |
0 |
selection.append(":"); |
281 |
0 |
if (!chain.equals(" ")) |
282 |
|
{ |
283 |
0 |
selection.append(chain); |
284 |
|
} |
285 |
0 |
selection.append(" /").append(modelId); |
286 |
|
|
287 |
0 |
cmd.append(selection).append(";wireframe 100;").append(selection) |
288 |
|
.append(" and not hetero;").append("spacefill 200;select none"); |
289 |
|
|
290 |
0 |
resetLastRes.append(selection).append(";wireframe 0;").append(selection) |
291 |
|
.append(" and not hetero; spacefill 0;"); |
292 |
|
|
293 |
0 |
jmolScript(cmd.toString()); |
294 |
0 |
jmolHistory(true); |
295 |
|
} |
296 |
|
|
297 |
|
private boolean debug = true; |
298 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 3 |
Complexity Density: 3 |
|
299 |
56 |
private void jmolHistory(boolean enable)... |
300 |
|
{ |
301 |
56 |
jmolScript("History " + ((debug || enable) ? "on" : "off")); |
302 |
|
} |
303 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
304 |
0 |
public void loadInline(String string)... |
305 |
|
{ |
306 |
0 |
loadedInline = true; |
307 |
|
|
308 |
|
|
309 |
|
|
310 |
|
|
311 |
|
|
312 |
|
|
313 |
|
|
314 |
|
|
315 |
0 |
jmolViewer.openStringInline(string); |
316 |
|
} |
317 |
|
|
|
|
| 50.8% |
Uncovered Elements: 32 (65) |
Complexity: 16 |
Complexity Density: 0.39 |
|
318 |
1 |
protected void mouseOverStructure(int atomIndex, final String strInfo)... |
319 |
|
{ |
320 |
1 |
int pdbResNum; |
321 |
1 |
int alocsep = strInfo.indexOf("^"); |
322 |
1 |
int mdlSep = strInfo.indexOf("/"); |
323 |
1 |
int chainSeparator = strInfo.indexOf(":"), chainSeparator1 = -1; |
324 |
|
|
325 |
1 |
if (chainSeparator == -1) |
326 |
|
{ |
327 |
0 |
chainSeparator = strInfo.indexOf("."); |
328 |
0 |
if (mdlSep > -1 && mdlSep < chainSeparator) |
329 |
|
{ |
330 |
0 |
chainSeparator1 = chainSeparator; |
331 |
0 |
chainSeparator = mdlSep; |
332 |
|
} |
333 |
|
} |
334 |
|
|
335 |
1 |
if (alocsep != -1) |
336 |
|
{ |
337 |
0 |
pdbResNum = Integer.parseInt( |
338 |
|
strInfo.substring(strInfo.indexOf("]") + 1, alocsep)); |
339 |
|
|
340 |
|
} |
341 |
|
else |
342 |
|
{ |
343 |
1 |
pdbResNum = Integer.parseInt( |
344 |
|
strInfo.substring(strInfo.indexOf("]") + 1, chainSeparator)); |
345 |
|
} |
346 |
1 |
String chainId; |
347 |
|
|
348 |
1 |
if (strInfo.indexOf(":") > -1) |
349 |
|
{ |
350 |
1 |
chainId = strInfo.substring(strInfo.indexOf(":") + 1, |
351 |
|
strInfo.indexOf(".")); |
352 |
|
} |
353 |
|
else |
354 |
|
{ |
355 |
0 |
chainId = " "; |
356 |
|
} |
357 |
|
|
358 |
1 |
String pdbfilename = modelFileNames[0]; |
359 |
1 |
if (mdlSep > -1) |
360 |
|
{ |
361 |
1 |
if (chainSeparator1 == -1) |
362 |
|
{ |
363 |
1 |
chainSeparator1 = strInfo.indexOf(".", mdlSep); |
364 |
|
} |
365 |
1 |
String mdlId = (chainSeparator1 > -1) |
366 |
|
? strInfo.substring(mdlSep + 1, chainSeparator1) |
367 |
|
: strInfo.substring(mdlSep + 1); |
368 |
1 |
try |
369 |
|
{ |
370 |
|
|
371 |
1 |
int mnumber = Integer.valueOf(mdlId).intValue() - 1; |
372 |
1 |
if (_modelFileNameMap != null) |
373 |
|
{ |
374 |
0 |
int _mp = _modelFileNameMap.length - 1; |
375 |
|
|
376 |
0 |
while (mnumber < _modelFileNameMap[_mp]) |
377 |
|
{ |
378 |
0 |
_mp--; |
379 |
|
} |
380 |
0 |
pdbfilename = modelFileNames[_mp]; |
381 |
|
} |
382 |
|
else |
383 |
|
{ |
384 |
1 |
if (mnumber >= 0 && mnumber < modelFileNames.length) |
385 |
|
{ |
386 |
1 |
pdbfilename = modelFileNames[mnumber]; |
387 |
|
} |
388 |
|
|
389 |
1 |
if (pdbfilename == null) |
390 |
|
{ |
391 |
0 |
pdbfilename = new File(jmolViewer.ms.getModelFileName(mnumber)) |
392 |
|
.getAbsolutePath(); |
393 |
|
} |
394 |
|
} |
395 |
|
} catch (Exception e) |
396 |
|
{ |
397 |
|
} |
398 |
|
} |
399 |
|
|
400 |
|
|
401 |
|
|
402 |
|
|
403 |
|
|
404 |
1 |
String label = getSsm().mouseOverStructure(pdbResNum, chainId, |
405 |
|
pdbfilename); |
406 |
1 |
if (label != null) |
407 |
|
{ |
408 |
|
|
409 |
0 |
label = label.replace(',', '|'); |
410 |
0 |
StringTokenizer toks = new StringTokenizer(strInfo, " "); |
411 |
0 |
StringBuilder sb = new StringBuilder(); |
412 |
0 |
sb.append("select ").append(String.valueOf(pdbResNum)).append(":") |
413 |
|
.append(chainId).append("/1"); |
414 |
0 |
sb.append(";set hoverLabel \"").append(toks.nextToken()).append(" ") |
415 |
|
.append(toks.nextToken()); |
416 |
0 |
sb.append("|").append(label).append("\""); |
417 |
0 |
executeCommand(new StructureCommand(sb.toString()), false); |
418 |
|
} |
419 |
|
} |
420 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
421 |
0 |
public void notifyAtomHovered(int atomIndex, String strInfo, String data)... |
422 |
|
{ |
423 |
0 |
if (strInfo.equals(lastMessage)) |
424 |
|
{ |
425 |
0 |
return; |
426 |
|
} |
427 |
0 |
lastMessage = strInfo; |
428 |
0 |
if (data != null) |
429 |
|
{ |
430 |
0 |
System.err.println("Ignoring additional hover info: " + data |
431 |
|
+ " (other info: '" + strInfo + "' pos " + atomIndex + ")"); |
432 |
|
} |
433 |
0 |
mouseOverStructure(atomIndex, strInfo); |
434 |
|
} |
435 |
|
|
436 |
|
|
437 |
|
|
438 |
|
|
439 |
|
|
440 |
|
|
441 |
|
|
|
|
| 0% |
Uncovered Elements: 30 (30) |
Complexity: 6 |
Complexity Density: 0.3 |
|
442 |
0 |
public void notifyAtomPicked(int atomIndex, String strInfo,... |
443 |
|
String strData) |
444 |
|
{ |
445 |
|
|
446 |
|
|
447 |
|
|
448 |
|
|
449 |
0 |
if (strData != null) |
450 |
|
{ |
451 |
0 |
System.err.println("Ignoring additional pick data string " + strData); |
452 |
|
} |
453 |
0 |
int chainSeparator = strInfo.indexOf(":"); |
454 |
0 |
int p = 0; |
455 |
0 |
if (chainSeparator == -1) |
456 |
|
{ |
457 |
0 |
chainSeparator = strInfo.indexOf("."); |
458 |
|
} |
459 |
|
|
460 |
0 |
String picked = strInfo.substring(strInfo.indexOf("]") + 1, |
461 |
|
chainSeparator); |
462 |
0 |
String mdlString = ""; |
463 |
0 |
if ((p = strInfo.indexOf(":")) > -1) |
464 |
|
{ |
465 |
0 |
picked += strInfo.substring(p, strInfo.indexOf(".")); |
466 |
|
} |
467 |
|
|
468 |
0 |
if ((p = strInfo.indexOf("/")) > -1) |
469 |
|
{ |
470 |
0 |
mdlString += strInfo.substring(p, strInfo.indexOf(" #")); |
471 |
|
} |
472 |
0 |
picked = "((" + picked + ".CA" + mdlString + ")|(" + picked + ".P" |
473 |
|
+ mdlString + "))"; |
474 |
0 |
jmolHistory(false); |
475 |
|
|
476 |
0 |
if (!atomsPicked.contains(picked)) |
477 |
|
{ |
478 |
0 |
jmolScript("select " + picked + ";label %n %r:%c"); |
479 |
0 |
atomsPicked.addElement(picked); |
480 |
|
} |
481 |
|
else |
482 |
|
{ |
483 |
0 |
jmolViewer.evalString("select " + picked + ";label off"); |
484 |
0 |
atomsPicked.removeElement(picked); |
485 |
|
} |
486 |
0 |
jmolHistory(true); |
487 |
|
|
488 |
|
|
489 |
|
|
490 |
|
|
491 |
|
|
492 |
|
|
493 |
|
|
494 |
|
|
495 |
|
} |
496 |
|
|
|
|
| 55.9% |
Uncovered Elements: 15 (34) |
Complexity: 14 |
Complexity Density: 0.44 |
|
497 |
45 |
@Override... |
498 |
|
public void notifyCallback(CBK type, Object[] data) |
499 |
|
{ |
500 |
45 |
try |
501 |
|
{ |
502 |
45 |
switch (type) |
503 |
|
{ |
504 |
16 |
case LOADSTRUCT: |
505 |
16 |
notifyFileLoaded((String) data[1], (String) data[2], |
506 |
|
(String) data[3], (String) data[4], |
507 |
|
((Integer) data[5]).intValue()); |
508 |
|
|
509 |
16 |
break; |
510 |
0 |
case PICK: |
511 |
0 |
notifyAtomPicked(((Integer) data[2]).intValue(), (String) data[1], |
512 |
|
(String) data[0]); |
513 |
|
|
514 |
|
|
515 |
0 |
case HOVER: |
516 |
0 |
notifyAtomHovered(((Integer) data[2]).intValue(), (String) data[1], |
517 |
|
(String) data[0]); |
518 |
0 |
break; |
519 |
4 |
case SCRIPT: |
520 |
4 |
notifyScriptTermination((String) data[2], |
521 |
|
((Integer) data[3]).intValue()); |
522 |
4 |
break; |
523 |
6 |
case ECHO: |
524 |
6 |
sendConsoleEcho((String) data[1]); |
525 |
6 |
break; |
526 |
0 |
case MESSAGE: |
527 |
0 |
sendConsoleMessage( |
528 |
0 |
(data == null) ? ((String) null) : (String) data[1]); |
529 |
0 |
break; |
530 |
2 |
case ERROR: |
531 |
|
|
532 |
2 |
break; |
533 |
14 |
case SYNC: |
534 |
0 |
case RESIZE: |
535 |
14 |
refreshGUI(); |
536 |
14 |
break; |
537 |
3 |
case MEASURE: |
538 |
|
|
539 |
0 |
case CLICK: |
540 |
0 |
default: |
541 |
3 |
System.err.println( |
542 |
|
"Unhandled callback " + type + " " + data[1].toString()); |
543 |
3 |
break; |
544 |
|
} |
545 |
|
} catch (Exception e) |
546 |
|
{ |
547 |
0 |
System.err.println("Squashed Jmol callback handler error:"); |
548 |
0 |
e.printStackTrace(); |
549 |
|
} |
550 |
|
} |
551 |
|
|
|
|
| 75% |
Uncovered Elements: 3 (12) |
Complexity: 9 |
Complexity Density: 0.75 |
|
552 |
62 |
@Override... |
553 |
|
public boolean notifyEnabled(CBK callbackPick) |
554 |
|
{ |
555 |
62 |
switch (callbackPick) |
556 |
|
{ |
557 |
6 |
case ECHO: |
558 |
16 |
case LOADSTRUCT: |
559 |
3 |
case MEASURE: |
560 |
0 |
case MESSAGE: |
561 |
0 |
case PICK: |
562 |
4 |
case SCRIPT: |
563 |
0 |
case HOVER: |
564 |
2 |
case ERROR: |
565 |
31 |
return true; |
566 |
31 |
default: |
567 |
31 |
return false; |
568 |
|
} |
569 |
|
} |
570 |
|
|
571 |
|
|
572 |
|
|
573 |
|
|
574 |
|
private long loadNotifiesHandled = 0; |
575 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
576 |
18 |
public long getLoadNotifiesHandled()... |
577 |
|
{ |
578 |
18 |
return loadNotifiesHandled; |
579 |
|
} |
580 |
|
|
|
|
| 73% |
Uncovered Elements: 30 (111) |
Complexity: 26 |
Complexity Density: 0.38 |
|
581 |
16 |
public void notifyFileLoaded(String fullPathName, String fileName2,... |
582 |
|
String modelName, String errorMsg, int modelParts) |
583 |
|
{ |
584 |
16 |
if (errorMsg != null) |
585 |
|
{ |
586 |
5 |
fileLoadingError = errorMsg; |
587 |
5 |
refreshGUI(); |
588 |
5 |
return; |
589 |
|
} |
590 |
|
|
591 |
|
|
592 |
|
|
593 |
|
|
594 |
|
|
595 |
|
|
596 |
11 |
fileLoadingError = null; |
597 |
11 |
String[] oldmodels = modelFileNames; |
598 |
11 |
modelFileNames = null; |
599 |
11 |
boolean notifyLoaded = false; |
600 |
11 |
String[] modelfilenames = getStructureFiles(); |
601 |
11 |
if (modelfilenames == null) |
602 |
|
{ |
603 |
|
|
604 |
5 |
return; |
605 |
|
} |
606 |
|
|
607 |
6 |
if (oldmodels != null && oldmodels.length > 0) |
608 |
|
{ |
609 |
1 |
int oldm = 0; |
610 |
2 |
for (int i = 0; i < oldmodels.length; i++) |
611 |
|
{ |
612 |
1 |
for (int n = 0; n < modelfilenames.length; n++) |
613 |
|
{ |
614 |
1 |
if (modelfilenames[n] == oldmodels[i]) |
615 |
|
{ |
616 |
1 |
oldmodels[i] = null; |
617 |
1 |
break; |
618 |
|
} |
619 |
|
} |
620 |
1 |
if (oldmodels[i] != null) |
621 |
|
{ |
622 |
0 |
oldm++; |
623 |
|
} |
624 |
|
} |
625 |
1 |
if (oldm > 0) |
626 |
|
{ |
627 |
0 |
String[] oldmfn = new String[oldm]; |
628 |
0 |
oldm = 0; |
629 |
0 |
for (int i = 0; i < oldmodels.length; i++) |
630 |
|
{ |
631 |
0 |
if (oldmodels[i] != null) |
632 |
|
{ |
633 |
0 |
oldmfn[oldm++] = oldmodels[i]; |
634 |
|
} |
635 |
|
} |
636 |
|
|
637 |
|
|
638 |
0 |
getSsm().removeStructureViewerListener(this, oldmfn); |
639 |
|
} |
640 |
|
} |
641 |
6 |
refreshPdbEntries(); |
642 |
13 |
for (int modelnum = 0; modelnum < modelfilenames.length; modelnum++) |
643 |
|
{ |
644 |
7 |
String fileName = modelfilenames[modelnum]; |
645 |
7 |
boolean foundEntry = false; |
646 |
7 |
StructureFile pdb = null; |
647 |
7 |
String pdbfile = null; |
648 |
|
|
649 |
7 |
if (loadedInline) |
650 |
|
{ |
651 |
|
|
652 |
|
|
653 |
|
|
654 |
0 |
pdbfile = jmolViewer.getData( |
655 |
|
"" + (1 + _modelFileNameMap[modelnum]) + ".0", "PDB"); |
656 |
|
} |
657 |
|
|
658 |
|
|
659 |
16 |
for (int pe = 0; pe < getPdbCount(); pe++) |
660 |
|
{ |
661 |
9 |
boolean matches = false; |
662 |
9 |
addSequence(pe, getSequence()[pe]); |
663 |
9 |
if (fileName == null) |
664 |
|
{ |
665 |
0 |
if (false) |
666 |
|
|
667 |
|
{ |
668 |
0 |
pdb = getSsm().setMapping(getSequence()[pe], getChains()[pe], |
669 |
|
pdbfile, DataSourceType.PASTE, getIProgressIndicator()); |
670 |
0 |
getPdbEntry(modelnum).setFile("INLINE" + pdb.getId()); |
671 |
0 |
matches = true; |
672 |
0 |
foundEntry = true; |
673 |
|
} |
674 |
|
} |
675 |
|
else |
676 |
|
{ |
677 |
9 |
File fl = new File(getPdbEntry(pe).getFile()); |
678 |
9 |
matches = fl.equals(new File(fileName)); |
679 |
9 |
if (matches) |
680 |
|
{ |
681 |
7 |
foundEntry = true; |
682 |
|
|
683 |
|
|
684 |
|
|
685 |
|
|
686 |
|
|
687 |
7 |
DataSourceType protocol = DataSourceType.URL; |
688 |
7 |
try |
689 |
|
{ |
690 |
7 |
if (fl.exists()) |
691 |
|
{ |
692 |
7 |
protocol = DataSourceType.FILE; |
693 |
|
} |
694 |
|
} catch (Exception e) |
695 |
|
{ |
696 |
|
} catch (Error e) |
697 |
|
{ |
698 |
|
} |
699 |
|
|
700 |
7 |
pdb = getSsm().setMapping(getSequence()[pe], getChains()[pe], |
701 |
|
fileName, protocol, getIProgressIndicator()); |
702 |
|
|
703 |
|
|
704 |
|
} |
705 |
|
} |
706 |
9 |
if (matches) |
707 |
|
{ |
708 |
7 |
stashFoundChains(pdb, fileName); |
709 |
7 |
notifyLoaded = true; |
710 |
|
} |
711 |
|
} |
712 |
|
|
713 |
7 |
if (!foundEntry && associateNewStructs) |
714 |
|
{ |
715 |
|
|
716 |
|
|
717 |
|
|
718 |
0 |
String pdbcontent = jmolViewer.getData("/" + (modelnum + 1) + ".1", |
719 |
|
"PDB"); |
720 |
|
|
721 |
|
|
722 |
|
|
723 |
|
|
724 |
0 |
notifyLoaded = true; |
725 |
|
|
726 |
|
} |
727 |
|
} |
728 |
|
|
729 |
|
|
730 |
|
|
731 |
|
|
732 |
|
|
733 |
|
|
734 |
|
|
735 |
6 |
if (!isLoadingFromArchive()) |
736 |
|
{ |
737 |
3 |
jmolScript( |
738 |
|
"model *; select backbone;restrict;cartoon;wireframe off;spacefill off"); |
739 |
|
} |
740 |
|
|
741 |
|
|
742 |
6 |
getSsm().addStructureViewerListener(this); |
743 |
6 |
if (notifyLoaded) |
744 |
|
{ |
745 |
6 |
FeatureRenderer fr = getFeatureRenderer(null); |
746 |
6 |
if (fr != null) |
747 |
|
{ |
748 |
0 |
fr.featuresAdded(); |
749 |
|
} |
750 |
6 |
refreshGUI(); |
751 |
6 |
loadNotifiesHandled++; |
752 |
|
} |
753 |
6 |
setLoadingFromArchive(false); |
754 |
|
} |
755 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
756 |
7 |
protected IProgressIndicator getIProgressIndicator()... |
757 |
|
{ |
758 |
7 |
return null; |
759 |
|
} |
760 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
761 |
0 |
public void notifyNewPickingModeMeasurement(int iatom, String strMeasure)... |
762 |
|
{ |
763 |
0 |
notifyAtomPicked(iatom, strMeasure, null); |
764 |
|
} |
765 |
|
|
766 |
|
public abstract void notifyScriptTermination(String strStatus, |
767 |
|
int msWalltime); |
768 |
|
|
769 |
|
|
770 |
|
|
771 |
|
|
772 |
|
@param |
773 |
|
|
774 |
|
public abstract void sendConsoleEcho(String strEcho); |
775 |
|
|
776 |
|
|
777 |
|
|
778 |
|
|
779 |
|
|
780 |
|
|
781 |
|
|
782 |
|
|
783 |
|
|
784 |
|
|
785 |
|
@param |
786 |
|
|
787 |
|
|
788 |
|
|
789 |
|
public abstract void sendConsoleMessage(String strStatus); |
790 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
791 |
0 |
@Override... |
792 |
|
public void setCallbackFunction(String callbackType, |
793 |
|
String callbackFunction) |
794 |
|
{ |
795 |
0 |
System.err.println("Ignoring set-callback request to associate " |
796 |
|
+ callbackType + " with function " + callbackFunction); |
797 |
|
|
798 |
|
} |
799 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
800 |
0 |
public void showHelp()... |
801 |
|
{ |
802 |
0 |
showUrl("http://wiki.jmol.org" |
803 |
|
|
804 |
|
, "jmolHelp"); |
805 |
|
} |
806 |
|
|
807 |
|
|
808 |
|
|
809 |
|
|
810 |
|
@param |
811 |
|
|
812 |
|
public abstract void showUrl(String url, String target); |
813 |
|
|
814 |
|
|
815 |
|
|
816 |
|
|
817 |
|
@param |
818 |
|
|
819 |
|
public abstract void showConsole(boolean show); |
820 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
821 |
79 |
public static Viewer getJmolData(JmolParser jmolParser)... |
822 |
|
{ |
823 |
79 |
return (Viewer) JmolViewer.allocateViewer(null, null, null, null, null, |
824 |
|
"-x -o -n", jmolParser); |
825 |
|
} |
826 |
|
|
827 |
|
|
828 |
|
|
829 |
|
|
830 |
|
|
831 |
|
@param |
832 |
|
@param |
833 |
|
|
834 |
|
|
835 |
|
@param |
836 |
|
@param |
837 |
|
@param |
838 |
|
@param |
839 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
840 |
0 |
public void allocateViewer(Container renderPanel, boolean jmolfileio,... |
841 |
|
String htmlName, URL documentBase, URL codeBase, |
842 |
|
String commandOptions) |
843 |
|
{ |
844 |
0 |
allocateViewer(renderPanel, jmolfileio, htmlName, documentBase, |
845 |
|
codeBase, commandOptions, null, null); |
846 |
|
} |
847 |
|
|
848 |
|
|
849 |
|
|
850 |
|
@param |
851 |
|
@param |
852 |
|
|
853 |
|
|
854 |
|
@param |
855 |
|
@param |
856 |
|
@param |
857 |
|
@param |
858 |
|
@param |
859 |
|
|
860 |
|
@param |
861 |
|
|
862 |
|
|
|
|
| 64.7% |
Uncovered Elements: 6 (17) |
Complexity: 5 |
Complexity Density: 0.45 |
|
863 |
7 |
public void allocateViewer(Container renderPanel, boolean jmolfileio,... |
864 |
|
String htmlName, URL documentBase, URL codeBase, |
865 |
|
String commandOptions, final Container consolePanel, |
866 |
|
String buttonsToShow) |
867 |
|
{ |
868 |
|
|
869 |
7 |
System.err.println("Allocating Jmol Viewer: " + commandOptions); |
870 |
|
|
871 |
7 |
if (commandOptions == null) |
872 |
|
{ |
873 |
0 |
commandOptions = ""; |
874 |
|
} |
875 |
7 |
jmolViewer = (Viewer) JmolViewer.allocateViewer(renderPanel, |
876 |
7 |
(jmolfileio ? new SmarterJmolAdapter() : null), |
877 |
|
htmlName + ((Object) this).toString(), documentBase, codeBase, |
878 |
|
commandOptions, this); |
879 |
|
|
880 |
7 |
jmolViewer.setJmolStatusListener(this); |
881 |
|
|
882 |
7 |
try |
883 |
|
{ |
884 |
7 |
console = createJmolConsole(consolePanel, buttonsToShow); |
885 |
|
} catch (Throwable e) |
886 |
|
{ |
887 |
0 |
System.err.println("Could not create Jmol application console. " |
888 |
|
+ e.getMessage()); |
889 |
0 |
e.printStackTrace(); |
890 |
|
} |
891 |
7 |
if (consolePanel != null) |
892 |
|
{ |
893 |
7 |
consolePanel.addComponentListener(this); |
894 |
|
|
895 |
|
} |
896 |
|
|
897 |
|
} |
898 |
|
|
899 |
|
protected abstract JmolAppConsoleInterface createJmolConsole( |
900 |
|
Container consolePanel, String buttonsToShow); |
901 |
|
|
902 |
|
|
903 |
|
|
904 |
|
|
905 |
|
protected org.jmol.api.JmolAppConsoleInterface console = null; |
906 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
907 |
0 |
@Override... |
908 |
|
public int[] resizeInnerPanel(String data) |
909 |
|
{ |
910 |
|
|
911 |
0 |
return null; |
912 |
|
} |
913 |
|
|
914 |
|
|
915 |
|
|
916 |
|
|
|
|
| 85.7% |
Uncovered Elements: 1 (7) |
Complexity: 4 |
Complexity Density: 0.8 |
|
917 |
7 |
protected void closeConsole()... |
918 |
|
{ |
919 |
7 |
if (console != null) |
920 |
|
{ |
921 |
7 |
try |
922 |
|
{ |
923 |
7 |
console.setVisible(false); |
924 |
|
} catch (Error e) |
925 |
|
{ |
926 |
|
} catch (Exception x) |
927 |
|
{ |
928 |
|
} |
929 |
7 |
; |
930 |
7 |
console = null; |
931 |
|
} |
932 |
|
} |
933 |
|
|
934 |
|
|
935 |
|
|
936 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
937 |
0 |
@Override... |
938 |
|
public void componentMoved(ComponentEvent e) |
939 |
|
{ |
940 |
|
} |
941 |
|
|
942 |
|
|
943 |
|
|
944 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
945 |
0 |
@Override... |
946 |
|
public void componentResized(ComponentEvent e) |
947 |
|
{ |
948 |
|
} |
949 |
|
|
950 |
|
|
951 |
|
|
952 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
953 |
0 |
@Override... |
954 |
|
public void componentShown(ComponentEvent e) |
955 |
|
{ |
956 |
0 |
showConsole(true); |
957 |
|
} |
958 |
|
|
959 |
|
|
960 |
|
|
961 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
962 |
0 |
@Override... |
963 |
|
public void componentHidden(ComponentEvent e) |
964 |
|
{ |
965 |
0 |
showConsole(false); |
966 |
|
} |
967 |
|
|
|
|
| 66.7% |
Uncovered Elements: 4 (12) |
Complexity: 4 |
Complexity Density: 0.67 |
|
968 |
14 |
@Override... |
969 |
|
protected String getModelIdForFile(String pdbFile) |
970 |
|
{ |
971 |
14 |
if (modelFileNames == null) |
972 |
|
{ |
973 |
0 |
return ""; |
974 |
|
} |
975 |
17 |
for (int i = 0; i < modelFileNames.length; i++) |
976 |
|
{ |
977 |
17 |
if (modelFileNames[i].equalsIgnoreCase(pdbFile)) |
978 |
|
{ |
979 |
14 |
return String.valueOf(i + 1); |
980 |
|
} |
981 |
|
} |
982 |
0 |
return ""; |
983 |
|
} |
984 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
985 |
2 |
@Override... |
986 |
|
protected ViewerType getViewerType() |
987 |
|
{ |
988 |
2 |
return ViewerType.JMOL; |
989 |
|
} |
990 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
991 |
0 |
@Override... |
992 |
|
protected String getModelId(int pdbfnum, String file) |
993 |
|
{ |
994 |
0 |
return String.valueOf(pdbfnum + 1); |
995 |
|
} |
996 |
|
|
997 |
|
|
998 |
|
|
999 |
|
|
1000 |
|
@return |
1001 |
|
@see |
1002 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1003 |
2 |
@Override... |
1004 |
|
public String getSessionFileExtension() |
1005 |
|
{ |
1006 |
2 |
return ".spt"; |
1007 |
|
} |
1008 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
1009 |
0 |
@Override... |
1010 |
|
public void selectionChanged(BS arg0) |
1011 |
|
{ |
1012 |
|
|
1013 |
|
|
1014 |
|
} |
1015 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1016 |
0 |
@Override... |
1017 |
|
public SequenceRenderer getSequenceRenderer(AlignmentViewPanel avp) |
1018 |
|
{ |
1019 |
0 |
return new jalview.gui.SequenceRenderer(avp.getAlignViewport()); |
1020 |
|
} |
1021 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1022 |
0 |
@Override... |
1023 |
|
public String getHelpURL() |
1024 |
|
{ |
1025 |
0 |
return "http://wiki.jmol.org"; |
1026 |
|
} |
1027 |
|
} |