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 java.awt.Color; |
24 |
|
import java.awt.Component; |
25 |
|
import java.awt.event.ActionEvent; |
26 |
|
import java.awt.event.ActionListener; |
27 |
|
import java.awt.event.ItemEvent; |
28 |
|
import java.awt.event.ItemListener; |
29 |
|
import java.beans.PropertyVetoException; |
30 |
|
import java.io.BufferedReader; |
31 |
|
import java.io.File; |
32 |
|
import java.io.FileOutputStream; |
33 |
|
import java.io.FileReader; |
34 |
|
import java.io.IOException; |
35 |
|
import java.io.PrintWriter; |
36 |
|
import java.util.ArrayList; |
37 |
|
import java.util.List; |
38 |
|
import java.util.Map; |
39 |
|
import java.util.Random; |
40 |
|
import java.util.Vector; |
41 |
|
|
42 |
|
import javax.swing.ButtonGroup; |
43 |
|
import javax.swing.JCheckBoxMenuItem; |
44 |
|
import javax.swing.JMenu; |
45 |
|
import javax.swing.JMenuItem; |
46 |
|
import javax.swing.JRadioButtonMenuItem; |
47 |
|
import javax.swing.event.MenuEvent; |
48 |
|
import javax.swing.event.MenuListener; |
49 |
|
|
50 |
|
import jalview.api.AlignmentViewPanel; |
51 |
|
import jalview.api.structures.JalviewStructureDisplayI; |
52 |
|
import jalview.bin.Cache; |
53 |
|
import jalview.bin.Console; |
54 |
|
import jalview.datamodel.AlignmentI; |
55 |
|
import jalview.datamodel.PDBEntry; |
56 |
|
import jalview.datamodel.SequenceI; |
57 |
|
import jalview.gui.JalviewColourChooser.ColourChooserListener; |
58 |
|
import jalview.gui.StructureViewer.ViewerType; |
59 |
|
import jalview.gui.ViewSelectionMenu.ViewSetProvider; |
60 |
|
import jalview.io.DataSourceType; |
61 |
|
import jalview.io.JalviewFileChooser; |
62 |
|
import jalview.io.JalviewFileView; |
63 |
|
import jalview.jbgui.GStructureViewer; |
64 |
|
import jalview.schemes.ColourSchemeI; |
65 |
|
import jalview.schemes.ColourSchemes; |
66 |
|
import jalview.structure.StructureMapping; |
67 |
|
import jalview.structures.models.AAStructureBindingModel; |
68 |
|
import jalview.util.BrowserLauncher; |
69 |
|
import jalview.util.MessageManager; |
70 |
|
import jalview.ws.dbsources.EBIAlfaFold; |
71 |
|
import jalview.ws.dbsources.Pdb; |
72 |
|
import jalview.ws.utils.UrlDownloadClient; |
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
@author |
79 |
|
|
80 |
|
|
|
|
| 0% |
Uncovered Elements: 674 (674) |
Complexity: 192 |
Complexity Density: 0.45 |
|
81 |
|
public abstract class StructureViewerBase extends GStructureViewer |
82 |
|
implements Runnable, ViewSetProvider |
83 |
|
{ |
84 |
|
|
85 |
|
|
86 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
87 |
|
enum ViewerColour |
88 |
|
{ |
89 |
|
BySequence, ByChain, ChargeCysteine, ByViewer |
90 |
|
} |
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
|
96 |
|
|
97 |
|
private static List<JalviewStructureDisplayI> svbs = new ArrayList<>(); |
98 |
|
|
99 |
|
|
100 |
|
|
101 |
|
@return |
102 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 3 |
Complexity Density: 0.6 |
|
103 |
0 |
public static List<JalviewStructureDisplayI> getAllStructureViewerBases()... |
104 |
|
{ |
105 |
0 |
List<JalviewStructureDisplayI> goodSvbs = new ArrayList<>(); |
106 |
0 |
for (JalviewStructureDisplayI s : svbs) |
107 |
|
{ |
108 |
0 |
if (s != null && !goodSvbs.contains(s)) |
109 |
|
{ |
110 |
0 |
goodSvbs.add(s); |
111 |
|
} |
112 |
|
} |
113 |
0 |
return goodSvbs; |
114 |
|
} |
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
|
119 |
|
protected List<String> _aps = new ArrayList<>(); |
120 |
|
|
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
protected Vector<AlignmentViewPanel> _alignwith = new Vector<>(); |
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
|
130 |
|
protected Vector<AlignmentViewPanel> _colourwith = new Vector<>(); |
131 |
|
|
132 |
|
private String viewId = null; |
133 |
|
|
134 |
|
private AlignmentPanel ap; |
135 |
|
|
136 |
|
protected boolean alignAddedStructures = false; |
137 |
|
|
138 |
|
protected volatile boolean _started = false; |
139 |
|
|
140 |
|
protected volatile boolean addingStructures = false; |
141 |
|
|
142 |
|
protected Thread worker = null; |
143 |
|
|
144 |
|
protected boolean allChainsSelected = false; |
145 |
|
|
146 |
|
protected boolean allHetatmBeingSelected = false; |
147 |
|
|
148 |
|
protected JMenu viewSelectionMenu; |
149 |
|
|
150 |
|
|
151 |
|
|
152 |
|
|
153 |
|
|
154 |
|
|
155 |
|
protected volatile boolean seqColoursApplied = false; |
156 |
|
|
157 |
|
private IProgressIndicator progressBar = null; |
158 |
|
|
159 |
|
private Random random = new Random(); |
160 |
|
|
161 |
|
|
162 |
|
|
163 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
164 |
0 |
public StructureViewerBase()... |
165 |
|
{ |
166 |
0 |
super(); |
167 |
0 |
setFrameIcon(null); |
168 |
0 |
svbs.add(this); |
169 |
|
} |
170 |
|
|
171 |
|
|
172 |
|
@return |
173 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
174 |
0 |
@Override... |
175 |
|
public boolean isAlignAddedStructures() |
176 |
|
{ |
177 |
0 |
return alignAddedStructures; |
178 |
|
} |
179 |
|
|
180 |
|
|
181 |
|
|
182 |
|
@param |
183 |
|
|
184 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
185 |
0 |
@Override... |
186 |
|
public void setAlignAddedStructures(boolean alignAdded) |
187 |
|
{ |
188 |
0 |
alignAddedStructures = alignAdded; |
189 |
|
} |
190 |
|
|
191 |
|
|
192 |
|
|
193 |
|
|
194 |
|
|
195 |
|
@param |
196 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
197 |
0 |
public synchronized void setAddingStructures(boolean addingStructures)... |
198 |
|
{ |
199 |
0 |
this.addingStructures = addingStructures; |
200 |
|
} |
201 |
|
|
202 |
|
|
203 |
|
|
204 |
|
@param |
205 |
|
@return |
206 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
207 |
0 |
public boolean isLinkedWith(AlignmentPanel ap2)... |
208 |
|
{ |
209 |
0 |
return _aps.contains(ap2.av.getSequenceSetId()); |
210 |
|
} |
211 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
212 |
0 |
@Override... |
213 |
|
public boolean isUsedforaligment(AlignmentViewPanel ap2) |
214 |
|
{ |
215 |
|
|
216 |
0 |
return (_alignwith != null) && _alignwith.contains(ap2); |
217 |
|
} |
218 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
219 |
0 |
@Override... |
220 |
|
public boolean isUsedForColourBy(AlignmentViewPanel ap2) |
221 |
|
{ |
222 |
0 |
return (_colourwith != null) && _colourwith.contains(ap2); |
223 |
|
} |
224 |
|
|
225 |
|
|
226 |
|
|
227 |
|
@return |
228 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
229 |
0 |
public boolean isColouredByViewer()... |
230 |
|
{ |
231 |
0 |
return !getBinding().isColourBySequence(); |
232 |
|
} |
233 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
234 |
0 |
public String getViewId()... |
235 |
|
{ |
236 |
0 |
if (viewId == null) |
237 |
|
{ |
238 |
0 |
viewId = System.currentTimeMillis() + "." + this.hashCode(); |
239 |
|
} |
240 |
0 |
return viewId; |
241 |
|
} |
242 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
243 |
0 |
protected void setViewId(String viewId)... |
244 |
|
{ |
245 |
0 |
this.viewId = viewId; |
246 |
|
} |
247 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 5 |
Complexity Density: 0.62 |
|
248 |
0 |
protected void buildActionMenu()... |
249 |
|
{ |
250 |
0 |
if (_alignwith == null) |
251 |
|
{ |
252 |
0 |
_alignwith = new Vector<>(); |
253 |
|
} |
254 |
0 |
if (_alignwith.size() == 0 && ap != null) |
255 |
|
{ |
256 |
0 |
_alignwith.add(ap); |
257 |
|
} |
258 |
0 |
; |
259 |
|
|
260 |
|
|
261 |
|
|
262 |
|
|
263 |
0 |
for (Component c : viewerActionMenu.getMenuComponents()) |
264 |
|
{ |
265 |
0 |
if (c != alignStructs) |
266 |
|
{ |
267 |
0 |
viewerActionMenu.remove((JMenuItem) c); |
268 |
|
} |
269 |
|
} |
270 |
|
} |
271 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
272 |
0 |
@Override... |
273 |
|
public AlignmentPanel getAlignmentPanel() |
274 |
|
{ |
275 |
0 |
return ap; |
276 |
|
} |
277 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
278 |
0 |
protected void setAlignmentPanel(AlignmentPanel alp)... |
279 |
|
{ |
280 |
0 |
this.ap = alp; |
281 |
|
} |
282 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 2 |
Complexity Density: 0.22 |
|
283 |
0 |
@Override... |
284 |
|
public AlignmentPanel[] getAllAlignmentPanels() |
285 |
|
{ |
286 |
0 |
AlignmentPanel[] t, list = new AlignmentPanel[0]; |
287 |
0 |
for (String setid : _aps) |
288 |
|
{ |
289 |
0 |
AlignmentPanel[] panels = PaintRefresher.getAssociatedPanels(setid); |
290 |
0 |
if (panels != null) |
291 |
|
{ |
292 |
0 |
t = new AlignmentPanel[list.length + panels.length]; |
293 |
0 |
System.arraycopy(list, 0, t, 0, list.length); |
294 |
0 |
System.arraycopy(panels, 0, t, list.length, panels.length); |
295 |
0 |
list = t; |
296 |
|
} |
297 |
|
} |
298 |
|
|
299 |
0 |
return list; |
300 |
|
} |
301 |
|
|
302 |
|
|
303 |
|
|
304 |
|
|
305 |
|
|
306 |
|
@param |
307 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.75 |
|
308 |
0 |
public void addAlignmentPanel(AlignmentPanel nap)... |
309 |
|
{ |
310 |
0 |
if (getAlignmentPanel() == null) |
311 |
|
{ |
312 |
0 |
setAlignmentPanel(nap); |
313 |
|
} |
314 |
0 |
if (!_aps.contains(nap.av.getSequenceSetId())) |
315 |
|
{ |
316 |
0 |
_aps.add(nap.av.getSequenceSetId()); |
317 |
|
} |
318 |
|
} |
319 |
|
|
320 |
|
|
321 |
|
|
322 |
|
|
323 |
|
@param |
324 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 5 |
Complexity Density: 0.45 |
|
325 |
0 |
@Override... |
326 |
|
public void removeAlignmentPanel(AlignmentViewPanel nap) |
327 |
|
{ |
328 |
0 |
try |
329 |
|
{ |
330 |
0 |
_alignwith.remove(nap); |
331 |
0 |
_colourwith.remove(nap); |
332 |
0 |
if (getAlignmentPanel() == nap) |
333 |
|
{ |
334 |
0 |
setAlignmentPanel(null); |
335 |
0 |
for (AlignmentPanel aps : getAllAlignmentPanels()) |
336 |
|
{ |
337 |
0 |
if (aps != nap) |
338 |
|
{ |
339 |
0 |
setAlignmentPanel(aps); |
340 |
0 |
break; |
341 |
|
} |
342 |
|
} |
343 |
|
} |
344 |
|
} catch (Exception ex) |
345 |
|
{ |
346 |
|
} |
347 |
0 |
if (getAlignmentPanel() != null) |
348 |
|
{ |
349 |
0 |
buildActionMenu(); |
350 |
|
} |
351 |
|
} |
352 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
353 |
0 |
public void useAlignmentPanelForSuperposition(AlignmentPanel nap)... |
354 |
|
{ |
355 |
0 |
addAlignmentPanel(nap); |
356 |
0 |
if (!_alignwith.contains(nap)) |
357 |
|
{ |
358 |
0 |
_alignwith.add(nap); |
359 |
|
} |
360 |
|
} |
361 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
362 |
0 |
public void excludeAlignmentPanelForSuperposition(AlignmentPanel nap)... |
363 |
|
{ |
364 |
0 |
if (_alignwith.contains(nap)) |
365 |
|
{ |
366 |
0 |
_alignwith.remove(nap); |
367 |
|
} |
368 |
|
} |
369 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
370 |
0 |
public void useAlignmentPanelForColourbyseq(AlignmentPanel nap,... |
371 |
|
boolean enableColourBySeq) |
372 |
|
{ |
373 |
0 |
useAlignmentPanelForColourbyseq(nap); |
374 |
0 |
getBinding().setColourBySequence(enableColourBySeq); |
375 |
0 |
seqColour.setSelected(enableColourBySeq); |
376 |
0 |
viewerColour.setSelected(!enableColourBySeq); |
377 |
|
} |
378 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
379 |
0 |
public void useAlignmentPanelForColourbyseq(AlignmentPanel nap)... |
380 |
|
{ |
381 |
0 |
addAlignmentPanel(nap); |
382 |
0 |
if (!_colourwith.contains(nap)) |
383 |
|
{ |
384 |
0 |
_colourwith.add(nap); |
385 |
|
} |
386 |
|
} |
387 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
388 |
0 |
public void excludeAlignmentPanelForColourbyseq(AlignmentPanel nap)... |
389 |
|
{ |
390 |
0 |
if (_colourwith.contains(nap)) |
391 |
|
{ |
392 |
0 |
_colourwith.remove(nap); |
393 |
|
} |
394 |
|
} |
395 |
|
|
396 |
|
public abstract ViewerType getViewerType(); |
397 |
|
|
398 |
|
|
399 |
|
|
400 |
|
|
401 |
|
|
402 |
|
@param |
403 |
|
@param |
404 |
|
@param |
405 |
|
@param |
406 |
|
|
407 |
|
|
408 |
|
@param |
409 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 4 |
Complexity Density: 0.4 |
|
410 |
0 |
protected void addStructure(final PDBEntry pdbentry,... |
411 |
|
final SequenceI[] seqs, final String[] chains, |
412 |
|
final IProgressIndicator alignFrame) |
413 |
|
{ |
414 |
0 |
if (pdbentry.getFile() == null) |
415 |
|
{ |
416 |
0 |
if (worker != null && worker.isAlive()) |
417 |
|
{ |
418 |
|
|
419 |
|
|
420 |
0 |
new Thread(new Runnable() |
421 |
|
{ |
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 5 |
Complexity Density: 1.25 |
|
422 |
0 |
@Override... |
423 |
|
public void run() |
424 |
|
{ |
425 |
0 |
while (worker != null && worker.isAlive() && _started) |
426 |
|
{ |
427 |
0 |
try |
428 |
|
{ |
429 |
0 |
Thread.sleep(100 + ((int) Math.random() * 100)); |
430 |
|
|
431 |
|
} catch (Exception e) |
432 |
|
{ |
433 |
|
} |
434 |
|
} |
435 |
|
|
436 |
0 |
addStructure(pdbentry, seqs, chains, alignFrame); |
437 |
|
} |
438 |
|
}).start(); |
439 |
0 |
return; |
440 |
|
} |
441 |
|
} |
442 |
|
|
443 |
0 |
getBinding().addSequenceAndChain(new PDBEntry[] { pdbentry }, |
444 |
|
new SequenceI[][] |
445 |
|
{ seqs }, new String[][] { chains }); |
446 |
0 |
addingStructures = true; |
447 |
0 |
_started = false; |
448 |
0 |
worker = new Thread(this); |
449 |
0 |
worker.start(); |
450 |
0 |
return; |
451 |
|
} |
452 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
453 |
0 |
protected boolean hasPdbId(String pdbId)... |
454 |
|
{ |
455 |
0 |
return getBinding().hasPdbId(pdbId); |
456 |
|
} |
457 |
|
|
458 |
|
|
459 |
|
|
460 |
|
|
461 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
462 |
0 |
protected List<StructureViewerBase> getViewersFor(AlignmentPanel alp)... |
463 |
|
{ |
464 |
0 |
return Desktop.instance.getStructureViewers(alp, this.getClass()); |
465 |
|
} |
466 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
467 |
0 |
@Override... |
468 |
|
public void addToExistingViewer(PDBEntry pdbentry, SequenceI[] seq, |
469 |
|
String[] chains, final AlignmentViewPanel apanel, String pdbId) |
470 |
|
{ |
471 |
|
|
472 |
|
|
473 |
|
|
474 |
|
|
475 |
|
|
476 |
0 |
if (hasPdbId(pdbId)) |
477 |
|
{ |
478 |
0 |
return; |
479 |
|
} |
480 |
0 |
AlignmentPanel alignPanel = (AlignmentPanel) apanel; |
481 |
|
|
482 |
|
|
483 |
0 |
useAlignmentPanelForSuperposition(alignPanel); |
484 |
0 |
addStructure(pdbentry, seq, chains, alignPanel.alignFrame); |
485 |
|
} |
486 |
|
|
487 |
|
|
488 |
|
|
489 |
|
|
490 |
|
|
491 |
|
@param |
492 |
|
@param |
493 |
|
@param |
494 |
|
@param |
495 |
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 4 |
Complexity Density: 0.27 |
|
496 |
0 |
public void addSequenceMappingsToStructure(SequenceI[] seq,... |
497 |
|
String[] chains, final AlignmentViewPanel alpanel, |
498 |
|
String pdbFilename) |
499 |
|
{ |
500 |
0 |
AlignmentPanel apanel = (AlignmentPanel) alpanel; |
501 |
|
|
502 |
|
|
503 |
|
|
504 |
|
|
505 |
|
|
506 |
0 |
apanel.getStructureSelectionManager().setMapping(seq, chains, |
507 |
|
pdbFilename, DataSourceType.FILE, getProgressIndicator()); |
508 |
|
|
509 |
|
|
510 |
|
|
511 |
|
|
512 |
0 |
if (apanel.getSeqPanel().seqCanvas.fr != null) |
513 |
|
{ |
514 |
0 |
apanel.getSeqPanel().seqCanvas.fr.featuresAdded(); |
515 |
|
|
516 |
|
|
517 |
0 |
apanel.paintAlignment(true, false); |
518 |
|
} |
519 |
|
|
520 |
|
|
521 |
|
|
522 |
|
|
523 |
|
|
524 |
|
|
525 |
0 |
for (StructureViewerBase viewer : getViewersFor(null)) |
526 |
|
{ |
527 |
0 |
AAStructureBindingModel bindingModel = viewer.getBinding(); |
528 |
0 |
for (int pe = 0; pe < bindingModel.getPdbCount(); pe++) |
529 |
|
{ |
530 |
0 |
if (bindingModel.getPdbEntry(pe).getFile().equals(pdbFilename)) |
531 |
|
{ |
532 |
0 |
bindingModel.addSequence(pe, seq); |
533 |
0 |
viewer.addAlignmentPanel(apanel); |
534 |
|
|
535 |
|
|
536 |
|
|
537 |
|
|
538 |
0 |
viewer.useAlignmentPanelForColourbyseq(apanel); |
539 |
0 |
viewer.buildActionMenu(); |
540 |
0 |
apanel.getStructureSelectionManager() |
541 |
|
.sequenceColoursChanged(apanel); |
542 |
0 |
break; |
543 |
|
} |
544 |
|
} |
545 |
|
} |
546 |
|
} |
547 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
548 |
0 |
@Override... |
549 |
|
public boolean addAlreadyLoadedFile(SequenceI[] seq, String[] chains, |
550 |
|
final AlignmentViewPanel apanel, String pdbId) |
551 |
|
{ |
552 |
0 |
String alreadyMapped = apanel.getStructureSelectionManager() |
553 |
|
.alreadyMappedToFile(pdbId); |
554 |
|
|
555 |
0 |
if (alreadyMapped == null) |
556 |
|
{ |
557 |
0 |
return false; |
558 |
|
} |
559 |
|
|
560 |
0 |
addSequenceMappingsToStructure(seq, chains, apanel, alreadyMapped); |
561 |
0 |
return true; |
562 |
|
} |
563 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 3 |
Complexity Density: 0.3 |
|
564 |
0 |
void setChainMenuItems(List<String> chainNames)... |
565 |
|
{ |
566 |
0 |
chainMenu.removeAll(); |
567 |
0 |
if (chainNames == null || chainNames.isEmpty()) |
568 |
|
{ |
569 |
0 |
return; |
570 |
|
} |
571 |
0 |
JMenuItem menuItem = new JMenuItem( |
572 |
|
MessageManager.getString("label.all")); |
573 |
0 |
menuItem.addActionListener(new ActionListener() |
574 |
|
{ |
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
575 |
0 |
@Override... |
576 |
|
public void actionPerformed(ActionEvent evt) |
577 |
|
{ |
578 |
0 |
allChainsSelected = true; |
579 |
0 |
for (int i = 0; i < chainMenu.getItemCount(); i++) |
580 |
|
{ |
581 |
0 |
if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem) |
582 |
|
{ |
583 |
0 |
((JCheckBoxMenuItem) chainMenu.getItem(i)).setSelected(true); |
584 |
|
} |
585 |
|
} |
586 |
0 |
showSelectedChains(); |
587 |
0 |
allChainsSelected = false; |
588 |
|
} |
589 |
|
}); |
590 |
|
|
591 |
0 |
chainMenu.add(menuItem); |
592 |
|
|
593 |
0 |
for (String chain : chainNames) |
594 |
|
{ |
595 |
0 |
menuItem = new JCheckBoxMenuItem(chain, true); |
596 |
0 |
menuItem.addItemListener(new ItemListener() |
597 |
|
{ |
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
598 |
0 |
@Override... |
599 |
|
public void itemStateChanged(ItemEvent evt) |
600 |
|
{ |
601 |
0 |
if (!allChainsSelected) |
602 |
|
{ |
603 |
0 |
showSelectedChains(); |
604 |
|
} |
605 |
|
} |
606 |
|
}); |
607 |
|
|
608 |
0 |
chainMenu.add(menuItem); |
609 |
|
} |
610 |
|
} |
611 |
|
|
|
|
| 0% |
Uncovered Elements: 19 (19) |
Complexity: 3 |
Complexity Density: 0.18 |
|
612 |
0 |
void setHetatmMenuItems(Map<String, String> hetatmNames)... |
613 |
|
{ |
614 |
0 |
hetatmMenu.removeAll(); |
615 |
0 |
if (hetatmNames == null || hetatmNames.isEmpty()) |
616 |
|
{ |
617 |
0 |
hetatmMenu.setVisible(false); |
618 |
0 |
return; |
619 |
|
} |
620 |
0 |
hetatmMenu.setVisible(true); |
621 |
0 |
allHetatmBeingSelected = false; |
622 |
0 |
JMenuItem allMenuItem = new JMenuItem( |
623 |
|
MessageManager.getString("label.all")); |
624 |
0 |
JMenuItem noneMenuItem = new JMenuItem( |
625 |
|
MessageManager.getString("label.none")); |
626 |
0 |
allMenuItem.addActionListener(new ActionListener() |
627 |
|
{ |
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
628 |
0 |
@Override... |
629 |
|
public void actionPerformed(ActionEvent e) |
630 |
|
{ |
631 |
|
{ |
632 |
0 |
allHetatmBeingSelected = true; |
633 |
|
|
634 |
0 |
for (int i = 0; i < hetatmMenu.getItemCount(); i++) |
635 |
|
{ |
636 |
0 |
if (hetatmMenu.getItem(i) instanceof JCheckBoxMenuItem) |
637 |
|
{ |
638 |
0 |
((JCheckBoxMenuItem) hetatmMenu.getItem(i)).setSelected(true); |
639 |
|
} |
640 |
|
} |
641 |
0 |
allHetatmBeingSelected = false; |
642 |
0 |
showSelectedHetatms(); |
643 |
|
} |
644 |
|
} |
645 |
|
}); |
646 |
|
|
647 |
0 |
noneMenuItem.addActionListener(new ActionListener() |
648 |
|
{ |
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
649 |
0 |
@Override... |
650 |
|
public void actionPerformed(ActionEvent e) |
651 |
|
{ |
652 |
|
{ |
653 |
0 |
allHetatmBeingSelected = true; |
654 |
|
|
655 |
0 |
for (int i = 0; i < hetatmMenu.getItemCount(); i++) |
656 |
|
{ |
657 |
0 |
if (hetatmMenu.getItem(i) instanceof JCheckBoxMenuItem) |
658 |
|
{ |
659 |
0 |
((JCheckBoxMenuItem) hetatmMenu.getItem(i)) |
660 |
|
.setSelected(false); |
661 |
|
} |
662 |
|
} |
663 |
0 |
allHetatmBeingSelected = false; |
664 |
0 |
showSelectedHetatms(); |
665 |
|
} |
666 |
|
} |
667 |
|
}); |
668 |
0 |
hetatmMenu.add(noneMenuItem); |
669 |
0 |
hetatmMenu.add(allMenuItem); |
670 |
|
|
671 |
0 |
for (Map.Entry<String, String> chain : hetatmNames.entrySet()) |
672 |
|
{ |
673 |
0 |
JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(chain.getKey(), |
674 |
|
false); |
675 |
0 |
menuItem.setToolTipText(chain.getValue()); |
676 |
0 |
menuItem.addItemListener(new ItemListener() |
677 |
|
{ |
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
678 |
0 |
@Override... |
679 |
|
public void itemStateChanged(ItemEvent evt) |
680 |
|
{ |
681 |
0 |
if (!allHetatmBeingSelected) |
682 |
|
{ |
683 |
|
|
684 |
|
|
685 |
0 |
showSelectedHetatms(); |
686 |
|
} |
687 |
|
} |
688 |
|
}); |
689 |
|
|
690 |
0 |
hetatmMenu.add(menuItem); |
691 |
|
} |
692 |
|
} |
693 |
|
|
694 |
|
|
695 |
|
|
696 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
697 |
0 |
@Override... |
698 |
|
public void changeColour_actionPerformed(String colourSchemeName) |
699 |
|
{ |
700 |
0 |
AlignmentI al = getAlignmentPanel().av.getAlignment(); |
701 |
0 |
ColourSchemeI cs = ColourSchemes.getInstance().getColourScheme( |
702 |
|
colourSchemeName, getAlignmentPanel().av, al, null); |
703 |
0 |
getBinding().colourByJalviewColourScheme(cs); |
704 |
|
} |
705 |
|
|
706 |
|
|
707 |
|
|
708 |
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 1 |
Complexity Density: 0.06 |
|
709 |
0 |
protected void buildColourMenu()... |
710 |
|
{ |
711 |
0 |
colourMenu.removeAll(); |
712 |
0 |
AlignmentI al = getAlignmentPanel().av.getAlignment(); |
713 |
|
|
714 |
|
|
715 |
|
|
716 |
|
|
717 |
0 |
colourMenu.add(seqColour); |
718 |
0 |
colourMenu.add(chainColour); |
719 |
0 |
colourMenu.add(chargeColour); |
720 |
0 |
chargeColour.setEnabled(!al.isNucleotide()); |
721 |
|
|
722 |
|
|
723 |
|
|
724 |
|
|
725 |
0 |
ButtonGroup itemGroup = ColourMenuHelper.addMenuItems(colourMenu, this, |
726 |
|
al, true); |
727 |
|
|
728 |
|
|
729 |
|
|
730 |
|
|
731 |
0 |
viewerColour.setSelected(false); |
732 |
0 |
viewerColour.addActionListener(new ActionListener() |
733 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
734 |
0 |
@Override... |
735 |
|
public void actionPerformed(ActionEvent actionEvent) |
736 |
|
{ |
737 |
0 |
viewerColour_actionPerformed(); |
738 |
|
} |
739 |
|
}); |
740 |
0 |
colourMenu.add(viewerColour); |
741 |
|
|
742 |
|
|
743 |
|
|
744 |
|
|
745 |
0 |
JMenuItem backGround = new JMenuItem(); |
746 |
0 |
backGround |
747 |
|
.setText(MessageManager.getString("action.background_colour")); |
748 |
0 |
backGround.addActionListener(new ActionListener() |
749 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
750 |
0 |
@Override... |
751 |
|
public void actionPerformed(ActionEvent actionEvent) |
752 |
|
{ |
753 |
0 |
background_actionPerformed(); |
754 |
|
} |
755 |
|
}); |
756 |
0 |
colourMenu.add(backGround); |
757 |
|
|
758 |
|
|
759 |
|
|
760 |
|
|
761 |
|
|
762 |
0 |
itemGroup.add(seqColour); |
763 |
0 |
itemGroup.add(chainColour); |
764 |
0 |
itemGroup.add(chargeColour); |
765 |
0 |
itemGroup.add(viewerColour); |
766 |
|
} |
767 |
|
|
768 |
|
|
769 |
|
|
770 |
|
|
|
|
| 0% |
Uncovered Elements: 37 (37) |
Complexity: 3 |
Complexity Density: 0.09 |
|
771 |
0 |
protected void initMenus()... |
772 |
|
{ |
773 |
0 |
AAStructureBindingModel binding = getBinding(); |
774 |
|
|
775 |
0 |
seqColour = new JRadioButtonMenuItem(); |
776 |
0 |
seqColour.setText(MessageManager.getString("action.by_sequence")); |
777 |
0 |
seqColour.setName(ViewerColour.BySequence.name()); |
778 |
0 |
seqColour.setSelected(binding.isColourBySequence()); |
779 |
0 |
seqColour.addActionListener(new ActionListener() |
780 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
781 |
0 |
@Override... |
782 |
|
public void actionPerformed(ActionEvent actionEvent) |
783 |
|
{ |
784 |
0 |
seqColour_actionPerformed(); |
785 |
|
} |
786 |
|
}); |
787 |
|
|
788 |
0 |
chainColour = new JRadioButtonMenuItem(); |
789 |
0 |
chainColour.setText(MessageManager.getString("action.by_chain")); |
790 |
0 |
chainColour.setName(ViewerColour.ByChain.name()); |
791 |
0 |
chainColour.addActionListener(new ActionListener() |
792 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
793 |
0 |
@Override... |
794 |
|
public void actionPerformed(ActionEvent actionEvent) |
795 |
|
{ |
796 |
0 |
chainColour_actionPerformed(); |
797 |
|
} |
798 |
|
}); |
799 |
|
|
800 |
0 |
chargeColour = new JRadioButtonMenuItem(); |
801 |
0 |
chargeColour.setText(MessageManager.getString("label.charge_cysteine")); |
802 |
0 |
chargeColour.setName(ViewerColour.ChargeCysteine.name()); |
803 |
0 |
chargeColour.addActionListener(new ActionListener() |
804 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
805 |
0 |
@Override... |
806 |
|
public void actionPerformed(ActionEvent actionEvent) |
807 |
|
{ |
808 |
0 |
chargeColour_actionPerformed(); |
809 |
|
} |
810 |
|
}); |
811 |
|
|
812 |
0 |
viewerColour = new JRadioButtonMenuItem(); |
813 |
0 |
viewerColour |
814 |
|
.setText(MessageManager.getString("label.colour_with_viewer")); |
815 |
0 |
viewerColour.setToolTipText(MessageManager |
816 |
|
.getString("label.let_viewer_manage_structure_colours")); |
817 |
0 |
viewerColour.setName(ViewerColour.ByViewer.name()); |
818 |
0 |
viewerColour.setSelected(!binding.isColourBySequence()); |
819 |
|
|
820 |
0 |
if (_colourwith == null) |
821 |
|
{ |
822 |
0 |
_colourwith = new Vector<>(); |
823 |
|
} |
824 |
0 |
if (_alignwith == null) |
825 |
|
{ |
826 |
0 |
_alignwith = new Vector<>(); |
827 |
|
} |
828 |
|
|
829 |
0 |
ViewSelectionMenu seqColourBy = new ViewSelectionMenu( |
830 |
|
MessageManager.getString("label.colour_by"), this, _colourwith, |
831 |
|
new ItemListener() |
832 |
|
{ |
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
833 |
0 |
@Override... |
834 |
|
public void itemStateChanged(ItemEvent e) |
835 |
|
{ |
836 |
0 |
if (!seqColour.isSelected()) |
837 |
|
{ |
838 |
0 |
seqColour.doClick(); |
839 |
|
} |
840 |
|
else |
841 |
|
{ |
842 |
|
|
843 |
0 |
seqColour_actionPerformed(); |
844 |
|
} |
845 |
|
} |
846 |
|
}); |
847 |
0 |
viewMenu.add(seqColourBy); |
848 |
|
|
849 |
0 |
final ItemListener handler = new ItemListener() |
850 |
|
{ |
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
851 |
0 |
@Override... |
852 |
|
public void itemStateChanged(ItemEvent e) |
853 |
|
{ |
854 |
0 |
if (_alignwith.isEmpty()) |
855 |
|
{ |
856 |
0 |
alignStructs.setEnabled(false); |
857 |
0 |
alignStructs.setToolTipText(null); |
858 |
|
} |
859 |
|
else |
860 |
|
{ |
861 |
0 |
alignStructs.setEnabled(true); |
862 |
0 |
alignStructs.setToolTipText(MessageManager.formatMessage( |
863 |
|
"label.align_structures_using_linked_alignment_views", |
864 |
|
_alignwith.size())); |
865 |
|
} |
866 |
|
} |
867 |
|
}; |
868 |
0 |
viewSelectionMenu = new ViewSelectionMenu( |
869 |
|
MessageManager.getString("label.superpose_with"), this, |
870 |
|
_alignwith, handler); |
871 |
0 |
handler.itemStateChanged(null); |
872 |
0 |
viewerActionMenu.add(viewSelectionMenu, 0); |
873 |
0 |
viewerActionMenu.addMenuListener(new MenuListener() |
874 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
875 |
0 |
@Override... |
876 |
|
public void menuSelected(MenuEvent e) |
877 |
|
{ |
878 |
0 |
handler.itemStateChanged(null); |
879 |
|
} |
880 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
881 |
0 |
@Override... |
882 |
|
public void menuDeselected(MenuEvent e) |
883 |
|
{ |
884 |
|
} |
885 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
886 |
0 |
@Override... |
887 |
|
public void menuCanceled(MenuEvent e) |
888 |
|
{ |
889 |
|
} |
890 |
|
}); |
891 |
|
|
892 |
0 |
viewerActionMenu.setText(getViewerName()); |
893 |
0 |
helpItem.setText(MessageManager.formatMessage("label.viewer_help", |
894 |
|
getViewerName())); |
895 |
|
|
896 |
0 |
buildColourMenu(); |
897 |
|
} |
898 |
|
|
899 |
|
|
900 |
|
|
901 |
|
|
902 |
|
|
903 |
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 6 |
Complexity Density: 0.4 |
|
904 |
0 |
@Override... |
905 |
|
protected String alignStructsWithAllAlignPanels() |
906 |
|
{ |
907 |
0 |
if (getAlignmentPanel() == null) |
908 |
|
{ |
909 |
0 |
return null; |
910 |
|
} |
911 |
|
|
912 |
0 |
if (_alignwith.size() == 0) |
913 |
|
{ |
914 |
0 |
_alignwith.add(getAlignmentPanel()); |
915 |
|
} |
916 |
|
|
917 |
0 |
String reply = null; |
918 |
0 |
try |
919 |
|
{ |
920 |
0 |
reply = getBinding().superposeStructures(_alignwith); |
921 |
0 |
if (reply != null && !reply.isEmpty()) |
922 |
|
{ |
923 |
0 |
String text = MessageManager |
924 |
|
.formatMessage("error.superposition_failed", reply); |
925 |
0 |
statusBar.setText(text); |
926 |
|
} |
927 |
|
} catch (Exception e) |
928 |
|
{ |
929 |
0 |
StringBuffer sp = new StringBuffer(); |
930 |
0 |
for (AlignmentViewPanel alignPanel : _alignwith) |
931 |
|
{ |
932 |
0 |
sp.append("'" + alignPanel.getViewName() + "' "); |
933 |
|
} |
934 |
0 |
Console.info("Couldn't align structures with the " + sp.toString() |
935 |
|
+ "associated alignment panels.", e); |
936 |
|
} |
937 |
0 |
return reply; |
938 |
|
} |
939 |
|
|
940 |
|
|
941 |
|
|
942 |
|
|
943 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
944 |
0 |
@Override... |
945 |
|
public void background_actionPerformed() |
946 |
|
{ |
947 |
0 |
String ttl = MessageManager.getString("label.select_background_colour"); |
948 |
0 |
ColourChooserListener listener = new ColourChooserListener() |
949 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
950 |
0 |
@Override... |
951 |
|
public void colourSelected(Color c) |
952 |
|
{ |
953 |
0 |
getBinding().setBackgroundColour(c); |
954 |
|
} |
955 |
|
}; |
956 |
0 |
JalviewColourChooser.showColourChooser(this, ttl, null, listener); |
957 |
|
} |
958 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
959 |
0 |
@Override... |
960 |
|
public void viewerColour_actionPerformed() |
961 |
|
{ |
962 |
0 |
if (viewerColour.isSelected()) |
963 |
|
{ |
964 |
|
|
965 |
0 |
getBinding().setColourBySequence(false); |
966 |
|
} |
967 |
|
} |
968 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
969 |
0 |
@Override... |
970 |
|
public void chainColour_actionPerformed() |
971 |
|
{ |
972 |
0 |
chainColour.setSelected(true); |
973 |
0 |
getBinding().colourByChain(); |
974 |
|
} |
975 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
976 |
0 |
@Override... |
977 |
|
public void chargeColour_actionPerformed() |
978 |
|
{ |
979 |
0 |
chargeColour.setSelected(true); |
980 |
0 |
getBinding().colourByCharge(); |
981 |
|
} |
982 |
|
|
|
|
| 0% |
Uncovered Elements: 19 (19) |
Complexity: 6 |
Complexity Density: 0.55 |
|
983 |
0 |
@Override... |
984 |
|
public void seqColour_actionPerformed() |
985 |
|
{ |
986 |
0 |
AAStructureBindingModel binding = getBinding(); |
987 |
0 |
binding.setColourBySequence(seqColour.isSelected()); |
988 |
0 |
if (_colourwith == null) |
989 |
|
{ |
990 |
0 |
_colourwith = new Vector<>(); |
991 |
|
} |
992 |
0 |
if (binding.isColourBySequence()) |
993 |
|
{ |
994 |
0 |
if (!binding.isLoadingFromArchive()) |
995 |
|
{ |
996 |
0 |
if (_colourwith.size() == 0 && getAlignmentPanel() != null) |
997 |
|
{ |
998 |
|
|
999 |
0 |
_colourwith.add(getAlignmentPanel().alignFrame.alignPanel); |
1000 |
|
} |
1001 |
|
} |
1002 |
|
|
1003 |
0 |
for (AlignmentViewPanel alignPanel : _colourwith) |
1004 |
|
{ |
1005 |
0 |
binding.colourBySequence(alignPanel); |
1006 |
|
} |
1007 |
0 |
seqColoursApplied = true; |
1008 |
|
} |
1009 |
|
} |
1010 |
|
|
|
|
| 0% |
Uncovered Elements: 28 (28) |
Complexity: 8 |
Complexity Density: 0.4 |
|
1011 |
0 |
@Override... |
1012 |
|
public void pdbFile_actionPerformed() |
1013 |
|
{ |
1014 |
|
|
1015 |
0 |
JalviewFileChooser chooser = new JalviewFileChooser( |
1016 |
|
Cache.getProperty("LAST_DIRECTORY")); |
1017 |
|
|
1018 |
0 |
chooser.setFileView(new JalviewFileView()); |
1019 |
0 |
chooser.setDialogTitle(MessageManager.getString("label.save_pdb_file")); |
1020 |
0 |
chooser.setToolTipText(MessageManager.getString("action.save")); |
1021 |
|
|
1022 |
0 |
int value = chooser.showSaveDialog(this); |
1023 |
|
|
1024 |
0 |
if (value == JalviewFileChooser.APPROVE_OPTION) |
1025 |
|
{ |
1026 |
0 |
BufferedReader in = null; |
1027 |
0 |
try |
1028 |
|
{ |
1029 |
|
|
1030 |
0 |
in = new BufferedReader( |
1031 |
|
new FileReader(getBinding().getStructureFiles()[0])); |
1032 |
0 |
File outFile = chooser.getSelectedFile(); |
1033 |
|
|
1034 |
0 |
PrintWriter out = new PrintWriter(new FileOutputStream(outFile)); |
1035 |
0 |
String data; |
1036 |
0 |
while ((data = in.readLine()) != null) |
1037 |
|
{ |
1038 |
0 |
if (!(data.indexOf("<PRE>") > -1 || data.indexOf("</PRE>") > -1)) |
1039 |
|
{ |
1040 |
0 |
out.println(data); |
1041 |
|
} |
1042 |
|
} |
1043 |
0 |
out.close(); |
1044 |
|
} catch (Exception ex) |
1045 |
|
{ |
1046 |
0 |
ex.printStackTrace(); |
1047 |
|
} finally |
1048 |
|
{ |
1049 |
0 |
if (in != null) |
1050 |
|
{ |
1051 |
0 |
try |
1052 |
|
{ |
1053 |
0 |
in.close(); |
1054 |
|
} catch (IOException e) |
1055 |
|
{ |
1056 |
|
|
1057 |
|
} |
1058 |
|
} |
1059 |
|
} |
1060 |
|
} |
1061 |
|
} |
1062 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.29 |
|
1063 |
0 |
@Override... |
1064 |
|
public void viewMapping_actionPerformed() |
1065 |
|
{ |
1066 |
0 |
CutAndPasteTransfer cap = new CutAndPasteTransfer(); |
1067 |
0 |
try |
1068 |
|
{ |
1069 |
0 |
cap.appendText(getBinding().printMappings()); |
1070 |
|
} catch (OutOfMemoryError e) |
1071 |
|
{ |
1072 |
0 |
new OOMWarning( |
1073 |
|
"composing sequence-structure alignments for display in text box.", |
1074 |
|
e); |
1075 |
0 |
cap.dispose(); |
1076 |
0 |
return; |
1077 |
|
} |
1078 |
0 |
Desktop.addInternalFrame(cap, |
1079 |
|
MessageManager.getString("label.pdb_sequence_mapping"), 550, |
1080 |
|
600); |
1081 |
|
} |
1082 |
|
|
1083 |
|
protected abstract String getViewerName(); |
1084 |
|
|
1085 |
|
|
1086 |
|
|
1087 |
|
|
|
|
| 0% |
Uncovered Elements: 27 (27) |
Complexity: 7 |
Complexity Density: 0.41 |
|
1088 |
0 |
@Override... |
1089 |
|
public void updateTitleAndMenus() |
1090 |
|
{ |
1091 |
0 |
AAStructureBindingModel binding = getBinding(); |
1092 |
0 |
if (binding.hasFileLoadingError()) |
1093 |
|
{ |
1094 |
0 |
repaint(); |
1095 |
0 |
return; |
1096 |
|
} |
1097 |
0 |
setChainMenuItems(binding.getChainNames()); |
1098 |
0 |
setHetatmMenuItems(binding.getHetatmNames()); |
1099 |
|
|
1100 |
0 |
this.setTitle(binding.getViewerTitle(getViewerName(), true)); |
1101 |
|
|
1102 |
|
|
1103 |
|
|
1104 |
|
|
1105 |
0 |
viewSelectionMenu.setEnabled(false); |
1106 |
0 |
if (getBinding().getMappedStructureCount() > 1 |
1107 |
|
&& getBinding().getSequence().length > 1) |
1108 |
|
{ |
1109 |
0 |
viewSelectionMenu.setEnabled(true); |
1110 |
|
} |
1111 |
|
|
1112 |
|
|
1113 |
|
|
1114 |
|
|
1115 |
0 |
viewerActionMenu.setVisible(false); |
1116 |
0 |
for (int i = 0; i < viewerActionMenu.getItemCount(); i++) |
1117 |
|
{ |
1118 |
0 |
if (viewerActionMenu.getItem(i).isEnabled()) |
1119 |
|
{ |
1120 |
0 |
viewerActionMenu.setVisible(true); |
1121 |
0 |
break; |
1122 |
|
} |
1123 |
|
} |
1124 |
|
|
1125 |
0 |
if (!binding.isLoadingFromArchive()) |
1126 |
|
{ |
1127 |
0 |
seqColour_actionPerformed(); |
1128 |
|
} |
1129 |
|
} |
1130 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1131 |
0 |
@Override... |
1132 |
|
public String toString() |
1133 |
|
{ |
1134 |
0 |
return getTitle(); |
1135 |
|
} |
1136 |
|
|
|
|
| 0% |
Uncovered Elements: 29 (29) |
Complexity: 13 |
Complexity Density: 0.76 |
|
1137 |
0 |
@Override... |
1138 |
|
public boolean hasMapping() |
1139 |
|
{ |
1140 |
0 |
if (worker != null && (addingStructures || _started)) |
1141 |
|
{ |
1142 |
0 |
return false; |
1143 |
|
} |
1144 |
0 |
if (getBinding() == null) |
1145 |
|
{ |
1146 |
0 |
if (_aps == null || _aps.size() == 0) |
1147 |
|
{ |
1148 |
|
|
1149 |
0 |
return true; |
1150 |
|
} |
1151 |
0 |
return false; |
1152 |
|
} |
1153 |
0 |
String[] pdbids = getBinding().getStructureFiles(); |
1154 |
0 |
if (pdbids == null) |
1155 |
|
{ |
1156 |
0 |
return false; |
1157 |
|
} |
1158 |
0 |
int p = 0; |
1159 |
0 |
for (String pdbid : pdbids) |
1160 |
|
{ |
1161 |
0 |
StructureMapping sm[] = getBinding().getSsm().getMapping(pdbid); |
1162 |
0 |
if (sm != null && sm.length > 0 && sm[0] != null) |
1163 |
|
{ |
1164 |
0 |
p++; |
1165 |
|
} |
1166 |
|
} |
1167 |
|
|
1168 |
|
|
1169 |
0 |
if (p == 0 || p != pdbids.length) |
1170 |
|
{ |
1171 |
0 |
return false; |
1172 |
|
} |
1173 |
|
|
1174 |
0 |
return seqColoursApplied; |
1175 |
|
} |
1176 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1177 |
0 |
@Override... |
1178 |
|
public void raiseViewer() |
1179 |
|
{ |
1180 |
0 |
toFront(); |
1181 |
|
} |
1182 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
1183 |
0 |
@Override... |
1184 |
|
public long startProgressBar(String msg) |
1185 |
|
{ |
1186 |
|
|
1187 |
|
|
1188 |
0 |
long tm = random.nextLong(); |
1189 |
0 |
if (progressBar != null) |
1190 |
|
{ |
1191 |
0 |
progressBar.setProgressBar(msg, tm); |
1192 |
|
} |
1193 |
0 |
return tm; |
1194 |
|
} |
1195 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
1196 |
0 |
@Override... |
1197 |
|
public void stopProgressBar(String msg, long handle) |
1198 |
|
{ |
1199 |
0 |
if (progressBar != null) |
1200 |
|
{ |
1201 |
0 |
progressBar.setProgressBar(msg, handle); |
1202 |
|
} |
1203 |
|
} |
1204 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1205 |
0 |
protected IProgressIndicator getProgressIndicator()... |
1206 |
|
{ |
1207 |
0 |
return progressBar; |
1208 |
|
} |
1209 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1210 |
0 |
protected void setProgressIndicator(IProgressIndicator pi)... |
1211 |
|
{ |
1212 |
0 |
progressBar = pi; |
1213 |
|
} |
1214 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
1215 |
0 |
public void setProgressMessage(String message, long id)... |
1216 |
|
{ |
1217 |
0 |
if (progressBar != null) |
1218 |
|
{ |
1219 |
0 |
progressBar.setProgressBar(message, id); |
1220 |
|
} |
1221 |
|
} |
1222 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
1223 |
0 |
@Override... |
1224 |
|
public void showConsole(boolean show) |
1225 |
|
{ |
1226 |
|
|
1227 |
|
} |
1228 |
|
|
1229 |
|
|
1230 |
|
|
1231 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 4 |
Complexity Density: 0.57 |
|
1232 |
0 |
protected void showSelectedChains()... |
1233 |
|
{ |
1234 |
0 |
List<String> toshow = new ArrayList<>(); |
1235 |
0 |
for (int i = 0; i < chainMenu.getItemCount(); i++) |
1236 |
|
{ |
1237 |
0 |
if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem) |
1238 |
|
{ |
1239 |
0 |
JCheckBoxMenuItem item = (JCheckBoxMenuItem) chainMenu.getItem(i); |
1240 |
0 |
if (item.isSelected()) |
1241 |
|
{ |
1242 |
0 |
toshow.add(item.getText()); |
1243 |
|
} |
1244 |
|
} |
1245 |
|
} |
1246 |
0 |
getBinding().showChains(toshow); |
1247 |
|
} |
1248 |
|
|
1249 |
|
|
1250 |
|
|
1251 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 4 |
Complexity Density: 0.57 |
|
1252 |
0 |
protected void showSelectedHetatms()... |
1253 |
|
{ |
1254 |
0 |
List<String> toshow = new ArrayList<>(); |
1255 |
0 |
for (int i = 0; i < hetatmMenu.getItemCount(); i++) |
1256 |
|
{ |
1257 |
0 |
if (hetatmMenu.getItem(i) instanceof JCheckBoxMenuItem) |
1258 |
|
{ |
1259 |
0 |
JCheckBoxMenuItem item = (JCheckBoxMenuItem) hetatmMenu.getItem(i); |
1260 |
0 |
if (item.isSelected()) |
1261 |
|
{ |
1262 |
0 |
toshow.add(item.getText()); |
1263 |
|
} |
1264 |
|
} |
1265 |
|
} |
1266 |
0 |
getBinding().showHetatms(toshow); |
1267 |
|
} |
1268 |
|
|
1269 |
|
|
1270 |
|
|
1271 |
|
|
1272 |
|
|
1273 |
|
@param |
1274 |
|
@return |
1275 |
|
|
|
|
| 0% |
Uncovered Elements: 37 (37) |
Complexity: 8 |
Complexity Density: 0.3 |
|
1276 |
0 |
protected String fetchPdbFile(PDBEntry processingEntry)... |
1277 |
|
{ |
1278 |
0 |
String filePath = null; |
1279 |
0 |
Pdb pdbclient = new Pdb(); |
1280 |
0 |
EBIAlfaFold afclient = new EBIAlfaFold(); |
1281 |
0 |
AlignmentI pdbseq = null; |
1282 |
0 |
String pdbid = processingEntry.getId(); |
1283 |
0 |
long handle = System.currentTimeMillis() |
1284 |
|
+ Thread.currentThread().hashCode(); |
1285 |
|
|
1286 |
|
|
1287 |
|
|
1288 |
|
|
1289 |
0 |
String msg = MessageManager.formatMessage("status.fetching_pdb", |
1290 |
|
new Object[] |
1291 |
|
{ pdbid }); |
1292 |
0 |
getAlignmentPanel().alignFrame.setProgressBar(msg, handle); |
1293 |
|
|
1294 |
|
|
1295 |
|
|
1296 |
0 |
try |
1297 |
|
{ |
1298 |
0 |
if (afclient.isValidReference(pdbid)) |
1299 |
|
{ |
1300 |
0 |
pdbseq = afclient.getSequenceRecords(pdbid, |
1301 |
|
processingEntry.getRetrievalUrl()); |
1302 |
|
} |
1303 |
|
else |
1304 |
|
{ |
1305 |
0 |
if (processingEntry.hasRetrievalUrl()) |
1306 |
|
{ |
1307 |
0 |
String safePDBId = java.net.URLEncoder.encode(pdbid, "UTF-8") |
1308 |
|
.replace("%", "__"); |
1309 |
|
|
1310 |
|
|
1311 |
0 |
File tmpFile = File.createTempFile(safePDBId, |
1312 |
0 |
"." + (PDBEntry.Type.MMCIF.toString().equals( |
1313 |
|
processingEntry.getType().toString()) ? "cif" |
1314 |
|
: "pdb")); |
1315 |
0 |
String fromUrl = processingEntry.getRetrievalUrl(); |
1316 |
0 |
UrlDownloadClient.download(fromUrl, tmpFile); |
1317 |
|
|
1318 |
|
|
1319 |
0 |
String file = tmpFile.getAbsolutePath(); |
1320 |
0 |
if (file != null) |
1321 |
|
{ |
1322 |
0 |
pdbseq = EBIAlfaFold.importDownloadedStructureFromUrl(fromUrl, |
1323 |
|
tmpFile, pdbid, null, null, null); |
1324 |
|
} |
1325 |
|
} |
1326 |
|
else |
1327 |
|
{ |
1328 |
0 |
pdbseq = pdbclient.getSequenceRecords(pdbid); |
1329 |
|
} |
1330 |
|
} |
1331 |
|
} catch (Exception e) |
1332 |
|
{ |
1333 |
0 |
jalview.bin.Console.errPrintln( |
1334 |
|
"Error retrieving PDB id " + pdbid + ": " + e.getMessage()); |
1335 |
|
} finally |
1336 |
|
{ |
1337 |
0 |
msg = pdbid + " " + MessageManager.getString("label.state_completed"); |
1338 |
0 |
getAlignmentPanel().alignFrame.setProgressBar(msg, handle); |
1339 |
|
|
1340 |
|
} |
1341 |
|
|
1342 |
|
|
1343 |
|
|
1344 |
|
|
1345 |
0 |
if (pdbseq != null && pdbseq.getHeight() > 0) |
1346 |
|
{ |
1347 |
|
|
1348 |
0 |
filePath = new File(pdbseq.getSequenceAt(0).getAllPDBEntries() |
1349 |
|
.elementAt(0).getFile()).getAbsolutePath(); |
1350 |
0 |
processingEntry.setFile(filePath); |
1351 |
|
} |
1352 |
0 |
return filePath; |
1353 |
|
} |
1354 |
|
|
1355 |
|
|
1356 |
|
|
1357 |
|
|
1358 |
|
|
1359 |
|
@return |
1360 |
|
|
|
|
| 0% |
Uncovered Elements: 19 (19) |
Complexity: 5 |
Complexity Density: 0.38 |
|
1361 |
0 |
public File saveSession()... |
1362 |
|
{ |
1363 |
0 |
if (getBinding() == null) |
1364 |
|
{ |
1365 |
0 |
return null; |
1366 |
|
} |
1367 |
0 |
File session = getBinding().saveSession(); |
1368 |
0 |
long l = session.length(); |
1369 |
0 |
int wait = 50; |
1370 |
0 |
do |
1371 |
|
{ |
1372 |
0 |
try |
1373 |
|
{ |
1374 |
0 |
Thread.sleep(5); |
1375 |
|
} catch (InterruptedException e) |
1376 |
|
{ |
1377 |
|
} |
1378 |
0 |
long nextl = session.length(); |
1379 |
0 |
if (nextl != l) |
1380 |
|
{ |
1381 |
0 |
wait = 50; |
1382 |
0 |
l = nextl; |
1383 |
|
} |
1384 |
0 |
} while (--wait > 0); |
1385 |
0 |
return session; |
1386 |
|
} |
1387 |
|
|
1388 |
|
private static boolean quitClose = false; |
1389 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1390 |
0 |
public static void setQuitClose(boolean b)... |
1391 |
|
{ |
1392 |
0 |
quitClose = b; |
1393 |
|
} |
1394 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
1395 |
0 |
@Override... |
1396 |
|
public boolean stillRunning() |
1397 |
|
{ |
1398 |
0 |
AAStructureBindingModel binding = getBinding(); |
1399 |
0 |
return binding != null && binding.isViewerRunning(); |
1400 |
|
} |
1401 |
|
|
1402 |
|
|
1403 |
|
|
1404 |
|
|
1405 |
|
|
1406 |
|
|
1407 |
|
@param |
1408 |
|
|
1409 |
|
|
|
|
| 0% |
Uncovered Elements: 42 (42) |
Complexity: 11 |
Complexity Density: 0.39 |
|
1410 |
0 |
@Override... |
1411 |
|
public void closeViewer(boolean forceClose) |
1412 |
|
{ |
1413 |
0 |
AAStructureBindingModel binding = getBinding(); |
1414 |
0 |
if (stillRunning()) |
1415 |
|
{ |
1416 |
0 |
if (!forceClose) |
1417 |
|
{ |
1418 |
0 |
String viewerName = getViewerName(); |
1419 |
|
|
1420 |
0 |
int confirm = JvOptionPane.CANCEL_OPTION; |
1421 |
0 |
if (QuitHandler.quitting()) |
1422 |
|
{ |
1423 |
|
|
1424 |
0 |
confirm = quitClose ? JvOptionPane.YES_OPTION |
1425 |
|
: JvOptionPane.NO_OPTION; |
1426 |
|
} |
1427 |
|
else |
1428 |
|
{ |
1429 |
0 |
String prompt = MessageManager |
1430 |
|
.formatMessage("label.confirm_close_viewer", new Object[] |
1431 |
|
{ binding.getViewerTitle(viewerName, false), |
1432 |
|
viewerName }); |
1433 |
0 |
prompt = JvSwingUtils.wrapTooltip(true, prompt); |
1434 |
0 |
String title = MessageManager.getString("label.close_viewer"); |
1435 |
0 |
confirm = showCloseDialog(title, prompt); |
1436 |
|
} |
1437 |
|
|
1438 |
|
|
1439 |
|
|
1440 |
|
|
1441 |
0 |
if (confirm == JvOptionPane.CANCEL_OPTION |
1442 |
|
|| confirm == JvOptionPane.CLOSED_OPTION) |
1443 |
|
{ |
1444 |
|
|
1445 |
0 |
if (confirm == JvOptionPane.CANCEL_OPTION) |
1446 |
|
{ |
1447 |
0 |
try |
1448 |
|
{ |
1449 |
|
|
1450 |
0 |
this.setClosed(false); |
1451 |
|
} catch (PropertyVetoException e) |
1452 |
|
{ |
1453 |
|
} |
1454 |
0 |
QuitHandler.abortQuit(); |
1455 |
|
} |
1456 |
0 |
return; |
1457 |
|
} |
1458 |
0 |
forceClose = confirm == JvOptionPane.YES_OPTION; |
1459 |
|
} |
1460 |
|
} |
1461 |
0 |
if (binding != null) |
1462 |
|
{ |
1463 |
0 |
binding.closeViewer(forceClose); |
1464 |
|
} |
1465 |
0 |
setAlignmentPanel(null); |
1466 |
0 |
_aps.clear(); |
1467 |
0 |
_alignwith.clear(); |
1468 |
0 |
_colourwith.clear(); |
1469 |
|
|
1470 |
|
|
1471 |
|
|
1472 |
|
|
1473 |
0 |
try |
1474 |
|
{ |
1475 |
0 |
svbs.remove(this); |
1476 |
|
} catch (Throwable t) |
1477 |
|
{ |
1478 |
0 |
Console.info( |
1479 |
|
"Unexpected exception when deregistering structure viewer", |
1480 |
|
t); |
1481 |
|
} |
1482 |
0 |
dispose(); |
1483 |
|
} |
1484 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
1485 |
0 |
private int showCloseDialog(final String title, final String prompt)... |
1486 |
|
{ |
1487 |
0 |
int confirmResponse = JvOptionPane.CANCEL_OPTION; |
1488 |
0 |
confirmResponse = JvOptionPane.showConfirmDialog(this, prompt, |
1489 |
|
MessageManager.getString("label.close_viewer"), |
1490 |
|
JvOptionPane.YES_NO_CANCEL_OPTION, |
1491 |
|
JvOptionPane.WARNING_MESSAGE); |
1492 |
0 |
return confirmResponse; |
1493 |
|
} |
1494 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
1495 |
0 |
@Override... |
1496 |
|
public void showHelp_actionPerformed() |
1497 |
|
{ |
1498 |
|
|
1499 |
|
|
1500 |
|
|
1501 |
|
|
1502 |
0 |
String url = getBinding().getHelpURL(); |
1503 |
0 |
if (url != null) |
1504 |
|
{ |
1505 |
0 |
BrowserLauncher.openURL(url); |
1506 |
|
} |
1507 |
|
|
1508 |
|
|
1509 |
|
|
1510 |
|
|
1511 |
|
|
1512 |
|
|
1513 |
|
|
1514 |
|
|
1515 |
|
|
1516 |
|
} |
1517 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1518 |
0 |
@Override... |
1519 |
|
public boolean hasViewerActionsMenu() |
1520 |
|
{ |
1521 |
0 |
return viewerActionMenu != null && viewerActionMenu.isEnabled() |
1522 |
|
&& viewerActionMenu.getItemCount() > 0 |
1523 |
|
&& viewerActionMenu.isVisible(); |
1524 |
|
} |
1525 |
|
|
1526 |
|
} |