1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.gui; |
22 |
|
|
23 |
|
import jalview.api.FeatureRenderer; |
24 |
|
import jalview.bin.Cache; |
25 |
|
import jalview.datamodel.AlignmentI; |
26 |
|
import jalview.datamodel.PDBEntry; |
27 |
|
import jalview.datamodel.SequenceI; |
28 |
|
import jalview.ext.rbvi.chimera.ChimeraCommands; |
29 |
|
import jalview.ext.rbvi.chimera.JalviewChimeraBinding; |
30 |
|
import jalview.gui.StructureViewer.ViewerType; |
31 |
|
import jalview.io.DataSourceType; |
32 |
|
import jalview.io.StructureFile; |
33 |
|
import jalview.structures.models.AAStructureBindingModel; |
34 |
|
import jalview.util.BrowserLauncher; |
35 |
|
import jalview.util.ImageMaker.TYPE; |
36 |
|
import jalview.util.MessageManager; |
37 |
|
import jalview.util.Platform; |
38 |
|
import jalview.ws.dbsources.Pdb; |
39 |
|
|
40 |
|
import java.awt.event.ActionEvent; |
41 |
|
import java.awt.event.ActionListener; |
42 |
|
import java.awt.event.MouseAdapter; |
43 |
|
import java.awt.event.MouseEvent; |
44 |
|
import java.io.File; |
45 |
|
import java.io.FileInputStream; |
46 |
|
import java.io.IOException; |
47 |
|
import java.io.InputStream; |
48 |
|
import java.util.ArrayList; |
49 |
|
import java.util.Collections; |
50 |
|
import java.util.List; |
51 |
|
import java.util.Random; |
52 |
|
|
53 |
|
import javax.swing.JCheckBoxMenuItem; |
54 |
|
import javax.swing.JInternalFrame; |
55 |
|
import javax.swing.JMenu; |
56 |
|
import javax.swing.JMenuItem; |
57 |
|
import javax.swing.event.InternalFrameAdapter; |
58 |
|
import javax.swing.event.InternalFrameEvent; |
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
@author |
64 |
|
|
65 |
|
|
|
|
| 0% |
Uncovered Elements: 344 (344) |
Complexity: 86 |
Complexity Density: 0.37 |
|
66 |
|
public class ChimeraViewFrame extends StructureViewerBase |
67 |
|
{ |
68 |
|
private JalviewChimeraBinding jmb; |
69 |
|
|
70 |
|
private IProgressIndicator progressBar = null; |
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
private String chimeraSessionFile = null; |
78 |
|
|
79 |
|
private Random random = new Random(); |
80 |
|
|
81 |
|
private int myWidth = 500; |
82 |
|
|
83 |
|
private int myHeight = 150; |
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
|
88 |
0 |
@Override... |
89 |
|
protected void initMenus() |
90 |
|
{ |
91 |
0 |
super.initMenus(); |
92 |
|
|
93 |
0 |
viewerActionMenu.setText(MessageManager.getString("label.chimera")); |
94 |
|
|
95 |
0 |
viewerColour |
96 |
|
.setText(MessageManager.getString("label.colour_with_chimera")); |
97 |
0 |
viewerColour.setToolTipText(MessageManager |
98 |
|
.getString("label.let_chimera_manage_structure_colours")); |
99 |
|
|
100 |
0 |
helpItem.setText(MessageManager.getString("label.chimera_help")); |
101 |
0 |
savemenu.setVisible(false); |
102 |
0 |
viewMenu.add(fitToWindow); |
103 |
|
|
104 |
0 |
JMenuItem writeFeatures = new JMenuItem( |
105 |
|
MessageManager.getString("label.create_chimera_attributes")); |
106 |
0 |
writeFeatures.setToolTipText(MessageManager |
107 |
|
.getString("label.create_chimera_attributes_tip")); |
108 |
0 |
writeFeatures.addActionListener(new ActionListener() |
109 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
110 |
0 |
@Override... |
111 |
|
public void actionPerformed(ActionEvent e) |
112 |
|
{ |
113 |
0 |
sendFeaturesToChimera(); |
114 |
|
} |
115 |
|
}); |
116 |
0 |
viewerActionMenu.add(writeFeatures); |
117 |
|
|
118 |
0 |
final JMenu fetchAttributes = new JMenu( |
119 |
|
MessageManager.getString("label.fetch_chimera_attributes")); |
120 |
0 |
fetchAttributes.setToolTipText( |
121 |
|
MessageManager.getString("label.fetch_chimera_attributes_tip")); |
122 |
0 |
fetchAttributes.addMouseListener(new MouseAdapter() |
123 |
|
{ |
124 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
125 |
0 |
@Override... |
126 |
|
public void mouseEntered(MouseEvent e) |
127 |
|
{ |
128 |
0 |
buildAttributesMenu(fetchAttributes); |
129 |
|
} |
130 |
|
}); |
131 |
0 |
viewerActionMenu.add(fetchAttributes); |
132 |
|
} |
133 |
|
|
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
@param |
139 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 3 |
Complexity Density: 0.27 |
|
140 |
0 |
protected void buildAttributesMenu(JMenu attributesMenu)... |
141 |
|
{ |
142 |
0 |
List<String> atts = jmb.sendChimeraCommand("list resattr", true); |
143 |
0 |
if (atts == null) |
144 |
|
{ |
145 |
0 |
return; |
146 |
|
} |
147 |
0 |
attributesMenu.removeAll(); |
148 |
0 |
Collections.sort(atts); |
149 |
0 |
for (String att : atts) |
150 |
|
{ |
151 |
0 |
final String attName = att.split(" ")[1]; |
152 |
|
|
153 |
|
|
154 |
|
|
155 |
|
|
156 |
|
|
157 |
0 |
if (!attName.startsWith(ChimeraCommands.NAMESPACE_PREFIX)) |
158 |
|
{ |
159 |
0 |
JMenuItem menuItem = new JMenuItem(attName); |
160 |
0 |
menuItem.addActionListener(new ActionListener() |
161 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
162 |
0 |
@Override... |
163 |
|
public void actionPerformed(ActionEvent e) |
164 |
|
{ |
165 |
0 |
getChimeraAttributes(attName); |
166 |
|
} |
167 |
|
}); |
168 |
0 |
attributesMenu.add(menuItem); |
169 |
|
} |
170 |
|
} |
171 |
|
} |
172 |
|
|
173 |
|
|
174 |
|
|
175 |
|
|
176 |
|
|
177 |
|
@param |
178 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
179 |
0 |
protected void getChimeraAttributes(String attName)... |
180 |
|
{ |
181 |
0 |
jmb.copyStructureAttributesToFeatures(attName, getAlignmentPanel()); |
182 |
|
} |
183 |
|
|
184 |
|
|
185 |
|
|
186 |
|
|
187 |
|
|
188 |
|
|
189 |
|
|
190 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
191 |
0 |
protected void sendFeaturesToChimera()... |
192 |
|
{ |
193 |
0 |
int count = jmb.sendFeaturesToViewer(getAlignmentPanel()); |
194 |
0 |
statusBar.setText( |
195 |
|
MessageManager.formatMessage("label.attributes_set", count)); |
196 |
|
} |
197 |
|
|
198 |
|
|
199 |
|
|
200 |
|
|
201 |
|
@param |
202 |
|
@param |
203 |
|
@param |
204 |
|
@param |
205 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
206 |
0 |
public ChimeraViewFrame(PDBEntry pdbentry, SequenceI[] seq,... |
207 |
|
String[] chains, final AlignmentPanel ap) |
208 |
|
{ |
209 |
0 |
this(); |
210 |
|
|
211 |
0 |
openNewChimera(ap, new PDBEntry[] { pdbentry }, |
212 |
|
new SequenceI[][] |
213 |
|
{ seq }); |
214 |
|
} |
215 |
|
|
216 |
|
|
217 |
|
|
218 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
219 |
0 |
protected void createProgressBar()... |
220 |
|
{ |
221 |
0 |
if (progressBar == null) |
222 |
|
{ |
223 |
0 |
progressBar = new ProgressBar(statusPanel, statusBar); |
224 |
|
} |
225 |
|
} |
226 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 2 |
Complexity Density: 0.15 |
|
227 |
0 |
private void openNewChimera(AlignmentPanel ap, PDBEntry[] pdbentrys,... |
228 |
|
SequenceI[][] seqs) |
229 |
|
{ |
230 |
0 |
createProgressBar(); |
231 |
0 |
jmb = new JalviewChimeraBindingModel(this, |
232 |
|
ap.getStructureSelectionManager(), pdbentrys, seqs, null); |
233 |
0 |
addAlignmentPanel(ap); |
234 |
0 |
useAlignmentPanelForColourbyseq(ap); |
235 |
|
|
236 |
0 |
if (pdbentrys.length > 1) |
237 |
|
{ |
238 |
0 |
useAlignmentPanelForSuperposition(ap); |
239 |
|
} |
240 |
0 |
jmb.setColourBySequence(true); |
241 |
0 |
setSize(myWidth, myHeight); |
242 |
0 |
initMenus(); |
243 |
|
|
244 |
0 |
addingStructures = false; |
245 |
0 |
worker = new Thread(this); |
246 |
0 |
worker.start(); |
247 |
|
|
248 |
0 |
this.addInternalFrameListener(new InternalFrameAdapter() |
249 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
250 |
0 |
@Override... |
251 |
|
public void internalFrameClosing( |
252 |
|
InternalFrameEvent internalFrameEvent) |
253 |
|
{ |
254 |
0 |
closeViewer(false); |
255 |
|
} |
256 |
|
}); |
257 |
|
|
258 |
|
} |
259 |
|
|
260 |
|
|
261 |
|
|
262 |
|
|
263 |
|
|
264 |
|
@param |
265 |
|
@param |
266 |
|
@param |
267 |
|
@param |
268 |
|
@param |
269 |
|
@param |
270 |
|
@param |
271 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 3 |
Complexity Density: 0.25 |
|
272 |
0 |
public ChimeraViewFrame(String chimeraSessionFile,... |
273 |
|
AlignmentPanel alignPanel, PDBEntry[] pdbArray, |
274 |
|
SequenceI[][] seqsArray, boolean colourByChimera, |
275 |
|
boolean colourBySequence, String newViewId) |
276 |
|
{ |
277 |
0 |
this(); |
278 |
0 |
setViewId(newViewId); |
279 |
0 |
this.chimeraSessionFile = chimeraSessionFile; |
280 |
0 |
openNewChimera(alignPanel, pdbArray, seqsArray); |
281 |
0 |
if (colourByChimera) |
282 |
|
{ |
283 |
0 |
jmb.setColourBySequence(false); |
284 |
0 |
seqColour.setSelected(false); |
285 |
0 |
viewerColour.setSelected(true); |
286 |
|
} |
287 |
0 |
else if (colourBySequence) |
288 |
|
{ |
289 |
0 |
jmb.setColourBySequence(true); |
290 |
0 |
seqColour.setSelected(true); |
291 |
0 |
viewerColour.setSelected(false); |
292 |
|
} |
293 |
|
} |
294 |
|
|
295 |
|
|
296 |
|
|
297 |
|
|
298 |
|
|
299 |
|
@param |
300 |
|
@param |
301 |
|
@param |
302 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
303 |
0 |
public ChimeraViewFrame(PDBEntry[] pe, boolean alignAdded,... |
304 |
|
SequenceI[][] seqs, |
305 |
|
AlignmentPanel ap) |
306 |
|
{ |
307 |
0 |
this(); |
308 |
0 |
setAlignAddedStructures(alignAdded); |
309 |
0 |
openNewChimera(ap, pe, seqs); |
310 |
|
} |
311 |
|
|
312 |
|
|
313 |
|
|
314 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
315 |
0 |
public ChimeraViewFrame()... |
316 |
|
{ |
317 |
0 |
super(); |
318 |
|
|
319 |
|
|
320 |
|
|
321 |
|
|
322 |
|
|
323 |
0 |
setDefaultCloseOperation(JInternalFrame.DO_NOTHING_ON_CLOSE); |
324 |
|
} |
325 |
|
|
326 |
|
|
327 |
|
|
328 |
|
|
329 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 4 |
Complexity Density: 0.36 |
|
330 |
0 |
void initChimera()... |
331 |
|
{ |
332 |
0 |
jmb.setFinishedInit(false); |
333 |
0 |
Desktop.addInternalFrame(this, |
334 |
|
jmb.getViewerTitle(getViewerName(), true), getBounds().width, |
335 |
|
getBounds().height); |
336 |
|
|
337 |
0 |
if (!jmb.launchChimera()) |
338 |
|
{ |
339 |
0 |
JvOptionPane.showMessageDialog(Desktop.desktop, |
340 |
|
MessageManager.getString("label.chimera_failed"), |
341 |
|
MessageManager.getString("label.error_loading_file"), |
342 |
|
JvOptionPane.ERROR_MESSAGE); |
343 |
0 |
this.dispose(); |
344 |
0 |
return; |
345 |
|
} |
346 |
|
|
347 |
0 |
if (this.chimeraSessionFile != null) |
348 |
|
{ |
349 |
0 |
boolean opened = jmb.openSession(chimeraSessionFile); |
350 |
0 |
if (!opened) |
351 |
|
{ |
352 |
0 |
System.err.println("An error occurred opening Chimera session file " |
353 |
|
+ chimeraSessionFile); |
354 |
|
} |
355 |
|
} |
356 |
|
|
357 |
0 |
jmb.startChimeraListener(); |
358 |
|
} |
359 |
|
|
360 |
|
|
361 |
|
|
362 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 4 |
Complexity Density: 0.57 |
|
363 |
0 |
@Override... |
364 |
|
void showSelectedChains() |
365 |
|
{ |
366 |
0 |
List<String> toshow = new ArrayList<>(); |
367 |
0 |
for (int i = 0; i < chainMenu.getItemCount(); i++) |
368 |
|
{ |
369 |
0 |
if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem) |
370 |
|
{ |
371 |
0 |
JCheckBoxMenuItem item = (JCheckBoxMenuItem) chainMenu.getItem(i); |
372 |
0 |
if (item.isSelected()) |
373 |
|
{ |
374 |
0 |
toshow.add(item.getText()); |
375 |
|
} |
376 |
|
} |
377 |
|
} |
378 |
0 |
jmb.showChains(toshow); |
379 |
|
} |
380 |
|
|
381 |
|
|
382 |
|
|
383 |
|
|
384 |
|
|
385 |
|
|
386 |
|
@param |
387 |
|
|
388 |
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 6 |
Complexity Density: 0.4 |
|
389 |
0 |
@Override... |
390 |
|
public void closeViewer(boolean closeChimera) |
391 |
|
{ |
392 |
0 |
if (jmb != null && jmb.isChimeraRunning()) |
393 |
|
{ |
394 |
0 |
if (!closeChimera) |
395 |
|
{ |
396 |
0 |
String prompt = MessageManager |
397 |
|
.formatMessage("label.confirm_close_chimera", new Object[] |
398 |
|
{ jmb.getViewerTitle(getViewerName(), false) }); |
399 |
0 |
prompt = JvSwingUtils.wrapTooltip(true, prompt); |
400 |
0 |
int confirm = JvOptionPane.showConfirmDialog(this, prompt, |
401 |
|
MessageManager.getString("label.close_viewer"), |
402 |
|
JvOptionPane.YES_NO_CANCEL_OPTION); |
403 |
|
|
404 |
|
|
405 |
|
|
406 |
0 |
if (confirm == JvOptionPane.CANCEL_OPTION |
407 |
|
|| confirm == JvOptionPane.CLOSED_OPTION) |
408 |
|
{ |
409 |
0 |
return; |
410 |
|
} |
411 |
0 |
closeChimera = confirm == JvOptionPane.YES_OPTION; |
412 |
|
} |
413 |
0 |
jmb.closeViewer(closeChimera); |
414 |
|
} |
415 |
0 |
setAlignmentPanel(null); |
416 |
0 |
_aps.clear(); |
417 |
0 |
_alignwith.clear(); |
418 |
0 |
_colourwith.clear(); |
419 |
|
|
420 |
|
|
421 |
0 |
jmb = null; |
422 |
0 |
dispose(); |
423 |
|
} |
424 |
|
|
425 |
|
|
426 |
|
|
427 |
|
|
428 |
|
|
|
|
| 0% |
Uncovered Elements: 99 (99) |
Complexity: 22 |
Complexity Density: 0.31 |
|
429 |
0 |
@Override... |
430 |
|
public void run() |
431 |
|
{ |
432 |
0 |
_started = true; |
433 |
|
|
434 |
0 |
StringBuilder errormsgs = new StringBuilder(128); |
435 |
0 |
StringBuilder files = new StringBuilder(128); |
436 |
0 |
List<PDBEntry> filePDB = new ArrayList<>(); |
437 |
0 |
List<Integer> filePDBpos = new ArrayList<>(); |
438 |
0 |
PDBEntry thePdbEntry = null; |
439 |
0 |
StructureFile pdb = null; |
440 |
0 |
try |
441 |
|
{ |
442 |
0 |
String[] curfiles = jmb.getStructureFiles(); |
443 |
|
|
444 |
|
|
445 |
0 |
for (int pi = 0; pi < jmb.getPdbCount(); pi++) |
446 |
|
{ |
447 |
0 |
String file = null; |
448 |
0 |
thePdbEntry = jmb.getPdbEntry(pi); |
449 |
0 |
if (thePdbEntry.getFile() == null) |
450 |
|
{ |
451 |
|
|
452 |
|
|
453 |
|
|
454 |
0 |
file = fetchPdbFile(thePdbEntry); |
455 |
0 |
if (file == null) |
456 |
|
{ |
457 |
0 |
errormsgs.append("'" + thePdbEntry.getId() + "' "); |
458 |
|
} |
459 |
|
} |
460 |
|
else |
461 |
|
{ |
462 |
|
|
463 |
|
|
464 |
|
|
465 |
0 |
file = new File(thePdbEntry.getFile()).getAbsoluteFile() |
466 |
|
.getPath(); |
467 |
0 |
if (curfiles != null && curfiles.length > 0) |
468 |
|
{ |
469 |
0 |
addingStructures = true; |
470 |
0 |
for (int c = 0; c < curfiles.length; c++) |
471 |
|
{ |
472 |
0 |
if (curfiles[c].equals(file)) |
473 |
|
{ |
474 |
0 |
file = null; |
475 |
0 |
break; |
476 |
|
} |
477 |
|
} |
478 |
|
} |
479 |
|
} |
480 |
0 |
if (file != null) |
481 |
|
{ |
482 |
0 |
filePDB.add(thePdbEntry); |
483 |
0 |
filePDBpos.add(Integer.valueOf(pi)); |
484 |
0 |
files.append(" \"" + Platform.escapeString(file) + "\""); |
485 |
|
} |
486 |
|
} |
487 |
|
} catch (OutOfMemoryError oomerror) |
488 |
|
{ |
489 |
0 |
new OOMWarning("Retrieving PDB files: " + thePdbEntry.getId(), |
490 |
|
oomerror); |
491 |
|
} catch (Exception ex) |
492 |
|
{ |
493 |
0 |
ex.printStackTrace(); |
494 |
0 |
errormsgs.append( |
495 |
|
"When retrieving pdbfiles for '" + thePdbEntry.getId() + "'"); |
496 |
|
} |
497 |
0 |
if (errormsgs.length() > 0) |
498 |
|
{ |
499 |
|
|
500 |
0 |
JvOptionPane.showInternalMessageDialog(Desktop.desktop, |
501 |
|
MessageManager.formatMessage( |
502 |
|
"label.pdb_entries_couldnt_be_retrieved", new Object[] |
503 |
|
{ errormsgs.toString() }), |
504 |
|
MessageManager.getString("label.couldnt_load_file"), |
505 |
|
JvOptionPane.ERROR_MESSAGE); |
506 |
|
} |
507 |
|
|
508 |
0 |
if (files.length() > 0) |
509 |
|
{ |
510 |
0 |
jmb.setFinishedInit(false); |
511 |
0 |
if (!addingStructures) |
512 |
|
{ |
513 |
0 |
try |
514 |
|
{ |
515 |
0 |
initChimera(); |
516 |
|
} catch (Exception ex) |
517 |
|
{ |
518 |
0 |
Cache.log.error("Couldn't open Chimera viewer!", ex); |
519 |
|
} |
520 |
|
} |
521 |
0 |
int num = -1; |
522 |
0 |
for (PDBEntry pe : filePDB) |
523 |
|
{ |
524 |
0 |
num++; |
525 |
0 |
if (pe.getFile() != null) |
526 |
|
{ |
527 |
0 |
try |
528 |
|
{ |
529 |
0 |
int pos = filePDBpos.get(num).intValue(); |
530 |
0 |
long startTime = startProgressBar(getViewerName() + " " |
531 |
|
+ MessageManager.getString("status.opening_file_for") |
532 |
|
+ " " + pe.getId()); |
533 |
0 |
jmb.openFile(pe); |
534 |
0 |
jmb.addSequence(pos, jmb.getSequence()[pos]); |
535 |
0 |
File fl = new File(pe.getFile()); |
536 |
0 |
DataSourceType protocol = DataSourceType.URL; |
537 |
0 |
try |
538 |
|
{ |
539 |
0 |
if (fl.exists()) |
540 |
|
{ |
541 |
0 |
protocol = DataSourceType.FILE; |
542 |
|
} |
543 |
|
} catch (Throwable e) |
544 |
|
{ |
545 |
|
} finally |
546 |
|
{ |
547 |
0 |
stopProgressBar("", startTime); |
548 |
|
} |
549 |
|
|
550 |
|
|
551 |
0 |
pdb = jmb.getSsm().setMapping(jmb.getSequence()[pos], |
552 |
|
jmb.getChains()[pos], pe.getFile(), protocol, |
553 |
|
progressBar); |
554 |
0 |
stashFoundChains(pdb, pe.getFile()); |
555 |
|
|
556 |
|
} catch (OutOfMemoryError oomerror) |
557 |
|
{ |
558 |
0 |
new OOMWarning( |
559 |
|
"When trying to open and map structures from Chimera!", |
560 |
|
oomerror); |
561 |
|
} catch (Exception ex) |
562 |
|
{ |
563 |
0 |
Cache.log.error( |
564 |
|
"Couldn't open " + pe.getFile() + " in Chimera viewer!", |
565 |
|
ex); |
566 |
|
} finally |
567 |
|
{ |
568 |
0 |
Cache.log.debug("File locations are " + files); |
569 |
|
} |
570 |
|
} |
571 |
|
} |
572 |
|
|
573 |
0 |
jmb.refreshGUI(); |
574 |
0 |
jmb.setFinishedInit(true); |
575 |
0 |
jmb.setLoadingFromArchive(false); |
576 |
|
|
577 |
|
|
578 |
|
|
579 |
|
|
580 |
|
|
581 |
0 |
FeatureRenderer fr = getBinding().getFeatureRenderer(null); |
582 |
0 |
if (fr != null) |
583 |
|
{ |
584 |
0 |
fr.featuresAdded(); |
585 |
|
} |
586 |
|
|
587 |
|
|
588 |
0 |
for (AlignmentPanel ap : _colourwith) |
589 |
|
{ |
590 |
0 |
jmb.updateColours(ap); |
591 |
|
} |
592 |
|
|
593 |
0 |
if (alignAddedStructures) |
594 |
|
{ |
595 |
0 |
new Thread(new Runnable() |
596 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
597 |
0 |
@Override... |
598 |
|
public void run() |
599 |
|
{ |
600 |
0 |
alignStructs_withAllAlignPanels(); |
601 |
|
} |
602 |
|
}).start(); |
603 |
|
} |
604 |
0 |
addingStructures = false; |
605 |
|
} |
606 |
0 |
_started = false; |
607 |
0 |
worker = null; |
608 |
|
} |
609 |
|
|
610 |
|
|
611 |
|
|
612 |
|
|
613 |
|
|
614 |
|
@param |
615 |
|
@return |
616 |
|
@throws |
617 |
|
|
618 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
619 |
0 |
private void stashFoundChains(StructureFile pdb, String file)... |
620 |
|
{ |
621 |
0 |
for (int i = 0; i < pdb.getChains().size(); i++) |
622 |
|
{ |
623 |
0 |
String chid = new String( |
624 |
|
pdb.getId() + ":" + pdb.getChains().elementAt(i).id); |
625 |
0 |
jmb.getChainNames().add(chid); |
626 |
0 |
jmb.getChainFile().put(chid, file); |
627 |
|
} |
628 |
|
} |
629 |
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 4 |
Complexity Density: 0.25 |
|
630 |
0 |
private String fetchPdbFile(PDBEntry processingEntry) throws Exception... |
631 |
|
{ |
632 |
0 |
String filePath = null; |
633 |
0 |
Pdb pdbclient = new Pdb(); |
634 |
0 |
AlignmentI pdbseq = null; |
635 |
0 |
String pdbid = processingEntry.getId(); |
636 |
0 |
long handle = System.currentTimeMillis() |
637 |
|
+ Thread.currentThread().hashCode(); |
638 |
|
|
639 |
|
|
640 |
|
|
641 |
|
|
642 |
0 |
String msg = MessageManager.formatMessage("status.fetching_pdb", |
643 |
|
new Object[] |
644 |
|
{ pdbid }); |
645 |
0 |
getAlignmentPanel().alignFrame.setProgressBar(msg, handle); |
646 |
|
|
647 |
|
|
648 |
|
|
649 |
0 |
try |
650 |
|
{ |
651 |
0 |
pdbseq = pdbclient.getSequenceRecords(pdbid); |
652 |
|
} catch (OutOfMemoryError oomerror) |
653 |
|
{ |
654 |
0 |
new OOMWarning("Retrieving PDB id " + pdbid, oomerror); |
655 |
|
} finally |
656 |
|
{ |
657 |
0 |
msg = pdbid + " " + MessageManager.getString("label.state_completed"); |
658 |
0 |
getAlignmentPanel().alignFrame.setProgressBar(msg, handle); |
659 |
|
|
660 |
|
} |
661 |
|
|
662 |
|
|
663 |
|
|
664 |
|
|
665 |
0 |
if (pdbseq != null && pdbseq.getHeight() > 0) |
666 |
|
{ |
667 |
|
|
668 |
0 |
filePath = new File(pdbseq.getSequenceAt(0).getAllPDBEntries() |
669 |
|
.elementAt(0).getFile()).getAbsolutePath(); |
670 |
0 |
processingEntry.setFile(filePath); |
671 |
|
} |
672 |
0 |
return filePath; |
673 |
|
} |
674 |
|
|
675 |
|
|
676 |
|
|
677 |
|
|
678 |
|
|
679 |
|
@param |
680 |
|
@param |
681 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
682 |
0 |
public long startProgressBar(String msg)... |
683 |
|
{ |
684 |
|
|
685 |
|
|
686 |
0 |
long tm = random.nextLong(); |
687 |
0 |
if (progressBar != null) |
688 |
|
{ |
689 |
0 |
progressBar.setProgressBar(msg, tm); |
690 |
|
} |
691 |
0 |
return tm; |
692 |
|
} |
693 |
|
|
694 |
|
|
695 |
|
|
696 |
|
|
697 |
|
|
698 |
|
@param |
699 |
|
@param |
700 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
701 |
0 |
public void stopProgressBar(String msg, long handle)... |
702 |
|
{ |
703 |
0 |
if (progressBar != null) |
704 |
|
{ |
705 |
0 |
progressBar.setProgressBar(msg, handle); |
706 |
|
} |
707 |
|
} |
708 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
709 |
0 |
@Override... |
710 |
|
public void makePDBImage(TYPE imageType) |
711 |
|
{ |
712 |
0 |
throw new UnsupportedOperationException( |
713 |
|
"Image export for Chimera is not implemented"); |
714 |
|
} |
715 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 2 |
Complexity Density: 1 |
|
716 |
0 |
@Override... |
717 |
|
public void showHelp_actionPerformed(ActionEvent actionEvent) |
718 |
|
{ |
719 |
0 |
try |
720 |
|
{ |
721 |
0 |
BrowserLauncher |
722 |
|
.openURL("https://www.cgl.ucsf.edu/chimera/docs/UsersGuide"); |
723 |
|
} catch (IOException ex) |
724 |
|
{ |
725 |
|
} |
726 |
|
} |
727 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
728 |
0 |
@Override... |
729 |
|
public AAStructureBindingModel getBinding() |
730 |
|
{ |
731 |
0 |
return jmb; |
732 |
|
} |
733 |
|
|
734 |
|
|
735 |
|
|
736 |
|
|
737 |
|
|
738 |
|
|
739 |
|
@param |
740 |
|
@see |
741 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 4 |
Complexity Density: 0.36 |
|
742 |
0 |
protected String saveSession(String filepath)... |
743 |
|
{ |
744 |
0 |
String pathUsed = filepath; |
745 |
0 |
try |
746 |
|
{ |
747 |
0 |
if (pathUsed == null) |
748 |
|
{ |
749 |
0 |
File tempFile = File.createTempFile("chimera", ".py"); |
750 |
0 |
tempFile.deleteOnExit(); |
751 |
0 |
pathUsed = tempFile.getPath(); |
752 |
|
} |
753 |
0 |
boolean result = jmb.saveSession(pathUsed); |
754 |
0 |
if (result) |
755 |
|
{ |
756 |
0 |
this.chimeraSessionFile = pathUsed; |
757 |
0 |
return pathUsed; |
758 |
|
} |
759 |
|
} catch (IOException e) |
760 |
|
{ |
761 |
|
} |
762 |
0 |
return null; |
763 |
|
} |
764 |
|
|
765 |
|
|
766 |
|
|
767 |
|
|
768 |
|
|
769 |
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 5 |
Complexity Density: 0.36 |
|
770 |
0 |
@Override... |
771 |
|
public String getStateInfo() |
772 |
|
{ |
773 |
0 |
String sessionFile = saveSession(null); |
774 |
0 |
if (sessionFile == null) |
775 |
|
{ |
776 |
0 |
return ""; |
777 |
|
} |
778 |
0 |
InputStream is = null; |
779 |
0 |
try |
780 |
|
{ |
781 |
0 |
File f = new File(sessionFile); |
782 |
0 |
byte[] bytes = new byte[(int) f.length()]; |
783 |
0 |
is = new FileInputStream(sessionFile); |
784 |
0 |
is.read(bytes); |
785 |
0 |
return new String(bytes); |
786 |
|
} catch (IOException e) |
787 |
|
{ |
788 |
0 |
return ""; |
789 |
|
} finally |
790 |
|
{ |
791 |
0 |
if (is != null) |
792 |
|
{ |
793 |
0 |
try |
794 |
|
{ |
795 |
0 |
is.close(); |
796 |
|
} catch (IOException e) |
797 |
|
{ |
798 |
|
|
799 |
|
} |
800 |
|
} |
801 |
|
} |
802 |
|
} |
803 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
804 |
0 |
@Override... |
805 |
|
protected void fitToWindow_actionPerformed() |
806 |
|
{ |
807 |
0 |
jmb.focusView(); |
808 |
|
} |
809 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
810 |
0 |
@Override... |
811 |
|
public ViewerType getViewerType() |
812 |
|
{ |
813 |
0 |
return ViewerType.CHIMERA; |
814 |
|
} |
815 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
816 |
0 |
@Override... |
817 |
|
protected String getViewerName() |
818 |
|
{ |
819 |
0 |
return "Chimera"; |
820 |
|
} |
821 |
|
|
822 |
|
|
823 |
|
|
824 |
|
|
825 |
|
@return |
826 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
827 |
0 |
@Override... |
828 |
|
protected String alignStructs_withAllAlignPanels() |
829 |
|
{ |
830 |
0 |
String reply = super.alignStructs_withAllAlignPanels(); |
831 |
0 |
if (reply != null) |
832 |
|
{ |
833 |
0 |
statusBar.setText("Superposition failed: " + reply); |
834 |
|
} |
835 |
0 |
return reply; |
836 |
|
} |
837 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
838 |
0 |
@Override... |
839 |
|
protected IProgressIndicator getIProgressIndicator() |
840 |
|
{ |
841 |
0 |
return progressBar; |
842 |
|
} |
843 |
|
} |