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.analysis.TreeBuilder; |
24 |
|
import jalview.analysis.scoremodels.ScoreModels; |
25 |
|
import jalview.analysis.scoremodels.SimilarityParams; |
26 |
|
import jalview.api.analysis.ScoreModelI; |
27 |
|
import jalview.api.analysis.SimilarityParamsI; |
28 |
|
import jalview.bin.Cache; |
29 |
|
import jalview.datamodel.SequenceGroup; |
30 |
|
import jalview.util.MessageManager; |
31 |
|
import jalview.util.Platform; |
32 |
|
import jalview.viewmodel.AlignmentViewport; |
33 |
|
import java.awt.BorderLayout; |
34 |
|
import java.awt.Color; |
35 |
|
import java.awt.Component; |
36 |
|
import java.awt.Dimension; |
37 |
|
import java.awt.FlowLayout; |
38 |
|
import java.awt.Font; |
39 |
|
import java.awt.GridLayout; |
40 |
|
import java.awt.Insets; |
41 |
|
import java.awt.event.ActionEvent; |
42 |
|
import java.awt.event.ActionListener; |
43 |
|
import java.awt.event.FocusEvent; |
44 |
|
import java.awt.event.FocusListener; |
45 |
|
import java.awt.event.MouseAdapter; |
46 |
|
import java.awt.event.MouseEvent; |
47 |
|
import java.beans.PropertyVetoException; |
48 |
|
import java.util.ArrayList; |
49 |
|
import java.util.List; |
50 |
|
|
51 |
|
import javax.swing.BorderFactory; |
52 |
|
import javax.swing.ButtonGroup; |
53 |
|
import javax.swing.DefaultComboBoxModel; |
54 |
|
import javax.swing.JButton; |
55 |
|
import javax.swing.JCheckBox; |
56 |
|
import javax.swing.JComboBox; |
57 |
|
import javax.swing.JInternalFrame; |
58 |
|
import javax.swing.JLabel; |
59 |
|
import javax.swing.JLayeredPane; |
60 |
|
import javax.swing.JPanel; |
61 |
|
import javax.swing.JRadioButton; |
62 |
|
import javax.swing.event.InternalFrameAdapter; |
63 |
|
import javax.swing.event.InternalFrameEvent; |
64 |
|
|
65 |
|
import jalview.analysis.AlignmentUtils; |
66 |
|
import jalview.analysis.TreeBuilder; |
67 |
|
import jalview.analysis.scoremodels.ScoreMatrix; |
68 |
|
import jalview.analysis.scoremodels.ScoreModels; |
69 |
|
import jalview.analysis.scoremodels.SimilarityParams; |
70 |
|
import jalview.api.analysis.ScoreModelI; |
71 |
|
import jalview.api.analysis.SimilarityParamsI; |
72 |
|
import jalview.bin.Cache; |
73 |
|
import jalview.datamodel.AlignmentAnnotation; |
74 |
|
import jalview.datamodel.SequenceGroup; |
75 |
|
import jalview.util.MessageManager; |
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
|
|
| 3.7% |
Uncovered Elements: 335 (348) |
Complexity: 88 |
Complexity Density: 0.35 |
|
80 |
|
public class CalculationChooser extends JPanel |
81 |
|
{ |
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
private static boolean treeMatchGaps = true; |
89 |
|
|
90 |
|
private static final Font VERDANA_11PT = new Font("Verdana", 0, 11); |
91 |
|
|
92 |
|
|
93 |
|
private static final int MIN_PAIRWISE_SELECTION = 2; |
94 |
|
|
95 |
|
private static final int MIN_TREE_SELECTION = 3; |
96 |
|
|
97 |
|
private static final int MIN_PCA_SELECTION = 4; |
98 |
|
|
99 |
|
private String secondaryStructureModelName; |
100 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
101 |
0 |
private void getSecondaryStructureModelName()... |
102 |
|
{ |
103 |
|
|
104 |
0 |
ScoreModels scoreModels = ScoreModels.getInstance(); |
105 |
0 |
for (ScoreModelI sm : scoreModels.getModels()) |
106 |
|
{ |
107 |
0 |
if (sm.isSecondaryStructure()) |
108 |
|
{ |
109 |
0 |
secondaryStructureModelName = sm.getName(); |
110 |
|
} |
111 |
|
} |
112 |
|
|
113 |
|
} |
114 |
|
|
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
|
119 |
|
private static final int MIN_PASIMAP_SELECTION = 9; |
120 |
|
|
121 |
|
AlignFrame af; |
122 |
|
|
123 |
|
JRadioButton pairwise; |
124 |
|
|
125 |
|
JRadioButton pca; |
126 |
|
|
127 |
|
JRadioButton pasimap; |
128 |
|
|
129 |
|
JRadioButton neighbourJoining; |
130 |
|
|
131 |
|
JRadioButton averageDistance; |
132 |
|
|
133 |
|
JComboBox<String> modelNames; |
134 |
|
|
135 |
|
JComboBox<String> ssSourceDropdown; |
136 |
|
|
137 |
|
JButton calculate; |
138 |
|
|
139 |
|
private JInternalFrame frame; |
140 |
|
|
141 |
|
private JCheckBox includeGaps; |
142 |
|
|
143 |
|
private JCheckBox matchGaps; |
144 |
|
|
145 |
|
private JCheckBox includeGappedColumns; |
146 |
|
|
147 |
|
private JCheckBox shorterSequence; |
148 |
|
|
149 |
|
final ComboBoxTooltipRenderer renderer = new ComboBoxTooltipRenderer(); |
150 |
|
|
151 |
|
List<String> tips = new ArrayList<>(); |
152 |
|
|
153 |
|
|
154 |
|
|
155 |
|
|
156 |
|
private PCAPanel pcaPanel; |
157 |
|
|
158 |
|
private PaSiMapPanel pasimapPanel; |
159 |
|
|
160 |
|
|
161 |
|
|
162 |
|
|
163 |
|
@param |
164 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
165 |
0 |
public CalculationChooser(AlignFrame alignFrame)... |
166 |
|
{ |
167 |
0 |
this.af = alignFrame; |
168 |
0 |
init(); |
169 |
0 |
af.alignPanel.setCalculationDialog(this); |
170 |
|
|
171 |
|
} |
172 |
|
|
173 |
|
|
174 |
|
|
175 |
|
|
|
|
| 0% |
Uncovered Elements: 109 (109) |
Complexity: 6 |
Complexity Density: 0.06 |
|
176 |
0 |
void init()... |
177 |
|
{ |
178 |
0 |
getSecondaryStructureModelName(); |
179 |
0 |
setLayout(new BorderLayout()); |
180 |
0 |
frame = new JInternalFrame(); |
181 |
0 |
frame.setFrameIcon(null); |
182 |
0 |
frame.setContentPane(this); |
183 |
0 |
this.setBackground(Color.white); |
184 |
0 |
frame.addFocusListener(new FocusListener() |
185 |
|
{ |
186 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
187 |
0 |
@Override... |
188 |
|
public void focusLost(FocusEvent e) |
189 |
|
{ |
190 |
|
} |
191 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
192 |
0 |
@Override... |
193 |
|
public void focusGained(FocusEvent e) |
194 |
|
{ |
195 |
0 |
validateCalcTypes(); |
196 |
|
} |
197 |
|
}); |
198 |
|
|
199 |
|
|
200 |
|
|
201 |
|
|
202 |
|
|
203 |
|
|
204 |
|
|
205 |
0 |
pca = new JRadioButton( |
206 |
|
MessageManager.getString("label.principal_component_analysis")); |
207 |
0 |
pca.setOpaque(false); |
208 |
|
|
209 |
0 |
pasimap = new JRadioButton( |
210 |
|
|
211 |
|
MessageManager.getString("label.pasimap")); |
212 |
0 |
pasimap.setOpaque(false); |
213 |
|
|
214 |
0 |
neighbourJoining = new JRadioButton( |
215 |
|
MessageManager.getString("label.tree_calc_nj")); |
216 |
0 |
neighbourJoining.setSelected(true); |
217 |
0 |
neighbourJoining.setOpaque(false); |
218 |
|
|
219 |
0 |
averageDistance = new JRadioButton( |
220 |
|
MessageManager.getString("label.tree_calc_av")); |
221 |
0 |
averageDistance.setOpaque(false); |
222 |
|
|
223 |
0 |
pairwise = new JRadioButton( |
224 |
|
MessageManager.getString("action.pairwise_alignment")); |
225 |
0 |
pairwise.setOpaque(false); |
226 |
|
|
227 |
0 |
JPanel calcChoicePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
228 |
0 |
calcChoicePanel.setOpaque(false); |
229 |
|
|
230 |
|
|
231 |
0 |
JPanel treePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
232 |
0 |
treePanel.setOpaque(false); |
233 |
|
|
234 |
0 |
JvSwingUtils.createTitledBorder(treePanel, |
235 |
|
MessageManager.getString("label.tree"), true); |
236 |
|
|
237 |
|
|
238 |
0 |
JPanel pcaBorderless = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
239 |
0 |
Insets b = treePanel.getBorder().getBorderInsets(treePanel); |
240 |
0 |
pcaBorderless.setBorder( |
241 |
|
BorderFactory.createEmptyBorder(2, b.left, 2, b.right)); |
242 |
0 |
pcaBorderless.setOpaque(false); |
243 |
|
|
244 |
0 |
pcaBorderless.add(pca, FlowLayout.LEFT); |
245 |
0 |
calcChoicePanel.add(pcaBorderless, FlowLayout.LEFT); |
246 |
|
|
247 |
|
|
248 |
0 |
JPanel pasimapBorderless = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
249 |
|
|
250 |
|
|
251 |
|
|
252 |
|
|
253 |
|
|
254 |
0 |
pasimapBorderless.setBorder( |
255 |
|
BorderFactory.createEmptyBorder(2, b.left, 2, b.right)); |
256 |
|
|
257 |
|
|
258 |
|
|
259 |
|
|
260 |
|
|
261 |
|
|
262 |
|
|
263 |
0 |
pasimapBorderless.setOpaque(false); |
264 |
|
|
265 |
0 |
pasimapBorderless.add(pasimap, FlowLayout.LEFT); |
266 |
|
|
267 |
0 |
if (!Platform.isJS()) |
268 |
|
{ |
269 |
|
|
270 |
0 |
calcChoicePanel.add(pasimapBorderless, FlowLayout.LEFT); |
271 |
|
|
272 |
|
|
273 |
|
|
274 |
|
|
275 |
|
|
276 |
|
} |
277 |
|
|
278 |
0 |
treePanel.add(neighbourJoining); |
279 |
0 |
treePanel.add(averageDistance); |
280 |
|
|
281 |
0 |
calcChoicePanel.add(treePanel); |
282 |
0 |
calcChoicePanel.add(pairwise, FlowLayout.CENTER); |
283 |
|
|
284 |
0 |
ButtonGroup calcTypes = new ButtonGroup(); |
285 |
0 |
calcTypes.add(pca); |
286 |
0 |
if (!Platform.isJS()) |
287 |
|
{ |
288 |
|
|
289 |
0 |
calcTypes.add(pasimap); |
290 |
|
} |
291 |
0 |
calcTypes.add(neighbourJoining); |
292 |
0 |
calcTypes.add(averageDistance); |
293 |
0 |
calcTypes.add(pairwise); |
294 |
|
|
295 |
0 |
ActionListener calcChanged = new ActionListener() |
296 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
297 |
0 |
@Override... |
298 |
|
public void actionPerformed(ActionEvent e) |
299 |
|
{ |
300 |
0 |
validateCalcTypes(); |
301 |
|
} |
302 |
|
}; |
303 |
0 |
pca.addActionListener(calcChanged); |
304 |
0 |
pasimap.addActionListener(calcChanged); |
305 |
|
|
306 |
|
|
307 |
0 |
neighbourJoining.addActionListener(calcChanged); |
308 |
0 |
averageDistance.addActionListener(calcChanged); |
309 |
|
|
310 |
|
|
311 |
0 |
ssSourceDropdown = buildSSSourcesOptionsList(); |
312 |
0 |
ssSourceDropdown.setVisible(false); |
313 |
0 |
pairwise.addActionListener(calcChanged); |
314 |
|
|
315 |
|
|
316 |
|
|
317 |
0 |
modelNames = buildModelOptionsList(); |
318 |
|
|
319 |
|
|
320 |
0 |
modelNames.addActionListener(new ActionListener() |
321 |
|
{ |
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
322 |
0 |
@Override... |
323 |
|
public void actionPerformed(ActionEvent e) |
324 |
|
{ |
325 |
0 |
String selectedModel = modelNames.getSelectedItem().toString(); |
326 |
|
|
327 |
0 |
if (selectedModel.equals(secondaryStructureModelName)) |
328 |
|
{ |
329 |
0 |
ssSourceDropdown.setVisible(true); |
330 |
|
} |
331 |
|
else |
332 |
|
{ |
333 |
0 |
ssSourceDropdown.setVisible(false); |
334 |
|
} |
335 |
|
} |
336 |
|
}); |
337 |
|
|
338 |
0 |
JPanel scoreModelPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); |
339 |
0 |
scoreModelPanel.setOpaque(false); |
340 |
0 |
scoreModelPanel.add(modelNames); |
341 |
0 |
scoreModelPanel.add(ssSourceDropdown); |
342 |
|
|
343 |
|
|
344 |
|
|
345 |
|
|
346 |
0 |
JPanel paramsPanel = new JPanel(new GridLayout(5, 1)); |
347 |
0 |
paramsPanel.setOpaque(false); |
348 |
0 |
includeGaps = new JCheckBox("Include gaps"); |
349 |
0 |
matchGaps = new JCheckBox("Match gaps"); |
350 |
0 |
includeGappedColumns = new JCheckBox("Include gapped columns"); |
351 |
0 |
shorterSequence = new JCheckBox("Match on shorter sequence"); |
352 |
0 |
paramsPanel.add(new JLabel("Pairwise sequence scoring options")); |
353 |
0 |
paramsPanel.add(includeGaps); |
354 |
0 |
paramsPanel.add(matchGaps); |
355 |
0 |
paramsPanel.add(includeGappedColumns); |
356 |
0 |
paramsPanel.add(shorterSequence); |
357 |
|
|
358 |
|
|
359 |
|
|
360 |
|
|
361 |
0 |
calculate = new JButton(MessageManager.getString("action.calculate")); |
362 |
0 |
calculate.setFont(VERDANA_11PT); |
363 |
0 |
calculate.addActionListener(new java.awt.event.ActionListener() |
364 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
365 |
0 |
@Override... |
366 |
|
public void actionPerformed(ActionEvent e) |
367 |
|
{ |
368 |
0 |
calculate_actionPerformed(); |
369 |
|
} |
370 |
|
}); |
371 |
0 |
JButton close = new JButton(MessageManager.getString("action.close")); |
372 |
0 |
close.setFont(VERDANA_11PT); |
373 |
0 |
close.addActionListener(new java.awt.event.ActionListener() |
374 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
375 |
0 |
@Override... |
376 |
|
public void actionPerformed(ActionEvent e) |
377 |
|
{ |
378 |
0 |
close_actionPerformed(); |
379 |
|
} |
380 |
|
}); |
381 |
0 |
JPanel actionPanel = new JPanel(); |
382 |
0 |
actionPanel.setOpaque(false); |
383 |
0 |
actionPanel.add(calculate); |
384 |
0 |
actionPanel.add(close); |
385 |
|
|
386 |
0 |
boolean includeParams = false; |
387 |
0 |
this.add(calcChoicePanel, BorderLayout.CENTER); |
388 |
0 |
calcChoicePanel.add(scoreModelPanel); |
389 |
0 |
if (includeParams) |
390 |
|
{ |
391 |
0 |
scoreModelPanel.add(paramsPanel); |
392 |
|
} |
393 |
0 |
this.add(actionPanel, BorderLayout.SOUTH); |
394 |
|
|
395 |
0 |
int width = 375; |
396 |
0 |
int height = includeParams ? 420 : 240; |
397 |
|
|
398 |
0 |
setMinimumSize(new Dimension(325, height - 10)); |
399 |
0 |
String title = MessageManager.getString("label.choose_calculation"); |
400 |
0 |
if (af.getViewport().getViewName() != null) |
401 |
|
{ |
402 |
0 |
title = title + " (" + af.getViewport().getViewName() + ")"; |
403 |
|
} |
404 |
|
|
405 |
0 |
Desktop.addInternalFrame(frame, title, width, height, false); |
406 |
0 |
calcChoicePanel.doLayout(); |
407 |
0 |
revalidate(); |
408 |
|
|
409 |
|
|
410 |
|
|
411 |
0 |
frame.addInternalFrameListener(new InternalFrameAdapter() |
412 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
413 |
0 |
@Override... |
414 |
|
public void internalFrameClosed(InternalFrameEvent evt) |
415 |
|
{ |
416 |
0 |
af.alignPanel.setCalculationDialog(null); |
417 |
|
}; |
418 |
|
}); |
419 |
|
|
420 |
0 |
validateCalcTypes(); |
421 |
0 |
frame.setLayer(JLayeredPane.PALETTE_LAYER); |
422 |
|
} |
423 |
|
|
424 |
|
|
425 |
|
|
426 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 8 |
Complexity Density: 0.62 |
|
427 |
0 |
protected void validateCalcTypes()... |
428 |
|
{ |
429 |
0 |
int size = af.getViewport().getAlignment().getHeight(); |
430 |
0 |
if (af.getViewport().getSelectionGroup() != null) |
431 |
|
{ |
432 |
0 |
size = af.getViewport().getSelectionGroup().getSize(); |
433 |
|
} |
434 |
|
|
435 |
|
|
436 |
|
|
437 |
|
|
438 |
|
|
439 |
0 |
boolean checkPca = checkEnabled(pca, size, MIN_PCA_SELECTION); |
440 |
0 |
boolean checkPasimap = checkEnabled(pasimap, size, |
441 |
|
MIN_PASIMAP_SELECTION); |
442 |
|
|
443 |
0 |
boolean checkNeighbourJoining = checkEnabled(neighbourJoining, size, |
444 |
|
MIN_TREE_SELECTION); |
445 |
0 |
boolean checkAverageDistance = checkEnabled(averageDistance, size, |
446 |
|
MIN_TREE_SELECTION); |
447 |
0 |
boolean checkPairwise = checkEnabled(pairwise, size, |
448 |
|
MIN_PAIRWISE_SELECTION); |
449 |
|
|
450 |
0 |
if (checkPca || checkPasimap || checkPca || checkNeighbourJoining |
451 |
|
|| checkAverageDistance || checkPairwise) |
452 |
|
{ |
453 |
0 |
calculate.setToolTipText(null); |
454 |
0 |
calculate.setEnabled(true); |
455 |
|
} |
456 |
|
else |
457 |
|
{ |
458 |
0 |
calculate.setEnabled(false); |
459 |
|
} |
460 |
0 |
updateScoreModels(modelNames, tips); |
461 |
|
} |
462 |
|
|
463 |
|
|
464 |
|
|
465 |
|
|
466 |
|
|
467 |
|
@param |
468 |
|
|
469 |
|
@param |
470 |
|
|
471 |
|
@param |
472 |
|
|
473 |
|
@return |
474 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 4 |
Complexity Density: 0.36 |
|
475 |
0 |
private boolean checkEnabled(JRadioButton calc, int size, int minsize)... |
476 |
|
{ |
477 |
0 |
String ttip = MessageManager |
478 |
|
.formatMessage("label.you_need_at_least_n_sequences", minsize); |
479 |
|
|
480 |
0 |
calc.setEnabled(size >= minsize); |
481 |
0 |
if (!calc.isEnabled()) |
482 |
|
{ |
483 |
0 |
calc.setToolTipText(ttip); |
484 |
|
} |
485 |
|
else |
486 |
|
{ |
487 |
0 |
calc.setToolTipText(null); |
488 |
|
} |
489 |
0 |
if (calc.isSelected()) |
490 |
|
{ |
491 |
0 |
modelNames.setEnabled(calc.isEnabled()); |
492 |
0 |
if (calc.isEnabled()) |
493 |
|
{ |
494 |
0 |
return true; |
495 |
|
} |
496 |
|
else |
497 |
|
{ |
498 |
0 |
calculate.setToolTipText(ttip); |
499 |
|
} |
500 |
|
} |
501 |
0 |
return false; |
502 |
|
} |
503 |
|
|
504 |
|
|
505 |
|
|
506 |
|
|
507 |
|
|
508 |
|
|
509 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
510 |
0 |
protected JComboBox<String> buildModelOptionsList()... |
511 |
|
{ |
512 |
0 |
final JComboBox<String> scoreModelsCombo = new JComboBox<>(); |
513 |
0 |
scoreModelsCombo.setRenderer(renderer); |
514 |
|
|
515 |
|
|
516 |
|
|
517 |
|
|
518 |
|
|
519 |
|
|
520 |
0 |
final MouseAdapter mouseListener = new MouseAdapter() |
521 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
522 |
0 |
@Override... |
523 |
|
public void mouseEntered(MouseEvent e) |
524 |
|
{ |
525 |
0 |
scoreModelsCombo.setToolTipText( |
526 |
|
tips.get(scoreModelsCombo.getSelectedIndex())); |
527 |
|
} |
528 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
529 |
0 |
@Override... |
530 |
|
public void mouseExited(MouseEvent e) |
531 |
|
{ |
532 |
0 |
scoreModelsCombo.setToolTipText(null); |
533 |
|
} |
534 |
|
}; |
535 |
0 |
for (Component c : scoreModelsCombo.getComponents()) |
536 |
|
{ |
537 |
0 |
c.addMouseListener(mouseListener); |
538 |
|
} |
539 |
|
|
540 |
0 |
updateScoreModels(scoreModelsCombo, tips); |
541 |
|
|
542 |
|
|
543 |
|
|
544 |
|
|
545 |
0 |
renderer.setTooltips(tips); |
546 |
|
|
547 |
0 |
return scoreModelsCombo; |
548 |
|
} |
549 |
|
|
|
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 5 |
Complexity Density: 0.29 |
|
550 |
0 |
private JComboBox<String> buildSSSourcesOptionsList()... |
551 |
|
{ |
552 |
0 |
final JComboBox<String> comboBox = new JComboBox<>(); |
553 |
0 |
Object curSel = comboBox.getSelectedItem(); |
554 |
0 |
DefaultComboBoxModel<String> sourcesModel = new DefaultComboBoxModel<>(); |
555 |
|
|
556 |
0 |
List<String> ssSources = getApplicableSecondaryStructureSources(); |
557 |
|
|
558 |
0 |
if (ssSources == null) |
559 |
|
{ |
560 |
0 |
return comboBox; |
561 |
|
} |
562 |
0 |
ssSources.add(0, MessageManager.getString("option.ss_providers_all")); |
563 |
|
|
564 |
0 |
boolean selectedIsPresent = false; |
565 |
0 |
for (String source : ssSources) |
566 |
|
{ |
567 |
0 |
if (curSel != null && source.equals(curSel)) |
568 |
|
{ |
569 |
0 |
selectedIsPresent = true; |
570 |
0 |
curSel = source; |
571 |
|
} |
572 |
0 |
sourcesModel.addElement(source); |
573 |
|
|
574 |
|
} |
575 |
|
|
576 |
0 |
if (selectedIsPresent) |
577 |
|
{ |
578 |
0 |
sourcesModel.setSelectedItem(curSel); |
579 |
|
} |
580 |
0 |
comboBox.setModel(sourcesModel); |
581 |
|
|
582 |
0 |
return comboBox; |
583 |
|
} |
584 |
|
|
|
|
| 0% |
Uncovered Elements: 27 (27) |
Complexity: 5 |
Complexity Density: 0.24 |
|
585 |
0 |
private void updateScoreModels(JComboBox<String> comboBox,... |
586 |
|
List<String> toolTips) |
587 |
|
{ |
588 |
0 |
Object curSel = comboBox.getSelectedItem(); |
589 |
0 |
toolTips.clear(); |
590 |
0 |
DefaultComboBoxModel<String> model = new DefaultComboBoxModel<>(); |
591 |
|
|
592 |
|
|
593 |
|
|
594 |
|
|
595 |
0 |
boolean nucleotide = af.getViewport().getAlignment().isNucleotide(); |
596 |
0 |
AlignmentAnnotation[] alignmentAnnotations = af.getViewport() |
597 |
|
.getAlignment().getAlignmentAnnotation(); |
598 |
|
|
599 |
0 |
boolean ssPresent = AlignmentUtils |
600 |
|
.isSecondaryStructurePresent(alignmentAnnotations); |
601 |
|
|
602 |
0 |
List<ScoreModelI> models = getApplicableScoreModels(nucleotide, |
603 |
|
pca.isSelected(), ssPresent, (pasimap.isSelected() || pairwise.isSelected())); |
604 |
|
|
605 |
|
|
606 |
|
|
607 |
|
|
608 |
|
|
609 |
0 |
boolean selectedIsPresent = false; |
610 |
0 |
for (ScoreModelI sm : models) |
611 |
|
{ |
612 |
0 |
if (curSel != null && sm.getName().equals(curSel)) |
613 |
|
{ |
614 |
0 |
selectedIsPresent = true; |
615 |
0 |
curSel = sm.getName(); |
616 |
|
} |
617 |
0 |
model.addElement(sm.getName()); |
618 |
|
|
619 |
|
|
620 |
|
|
621 |
|
|
622 |
|
|
623 |
0 |
String tooltip = sm.getDescription(); |
624 |
0 |
if (tooltip == null) |
625 |
|
{ |
626 |
0 |
tooltip = MessageManager.getStringOrReturn("label.score_model_", |
627 |
|
sm.getName()); |
628 |
|
} |
629 |
0 |
toolTips.add(tooltip); |
630 |
|
} |
631 |
|
|
632 |
0 |
if (selectedIsPresent) |
633 |
|
{ |
634 |
0 |
model.setSelectedItem(curSel); |
635 |
|
} |
636 |
|
|
637 |
0 |
comboBox.setModel(model); |
638 |
0 |
comboBox.setEnabled(model.getSize() > 0); |
639 |
|
|
640 |
|
} |
641 |
|
|
642 |
|
|
643 |
|
|
644 |
|
|
645 |
|
|
646 |
|
|
647 |
|
|
648 |
|
|
649 |
|
|
650 |
|
|
651 |
|
|
652 |
|
@param |
653 |
|
@param |
654 |
|
@param |
655 |
|
|
656 |
|
@param |
657 |
|
|
658 |
|
@return |
659 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 13 |
Complexity Density: 1.62 |
|
660 |
16 |
protected static List<ScoreModelI> getApplicableScoreModels(... |
661 |
|
boolean nucleotide, boolean forPca, boolean ssPresent, |
662 |
|
boolean forPasimap) |
663 |
|
{ |
664 |
16 |
List<ScoreModelI> filtered = new ArrayList<>(); |
665 |
|
|
666 |
16 |
ScoreModels scoreModels = ScoreModels.getInstance(); |
667 |
16 |
for (ScoreModelI sm : scoreModels.getModels()) |
668 |
|
{ |
669 |
112 |
if ((!forPasimap || sm instanceof ScoreMatrix) |
670 |
|
&& ((!nucleotide && sm.isProtein()) || (nucleotide && sm.isDNA())) |
671 |
|
&& (!sm.isSecondaryStructure() || ssPresent)) |
672 |
|
|
673 |
|
{ |
674 |
44 |
filtered.add(sm); |
675 |
|
} |
676 |
|
} |
677 |
|
|
678 |
|
|
679 |
|
|
680 |
|
|
681 |
|
|
682 |
16 |
if (!forPasimap && nucleotide && forPca |
683 |
|
&& Cache.getDefault("BLOSUM62_PCA_FOR_NUCLEOTIDE", false)) |
684 |
|
{ |
685 |
1 |
filtered.add(scoreModels.getBlosum62()); |
686 |
|
} |
687 |
|
|
688 |
16 |
return filtered; |
689 |
|
} |
690 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
691 |
0 |
protected List<String> getApplicableSecondaryStructureSources()... |
692 |
|
{ |
693 |
0 |
AlignmentAnnotation[] annotations = af.getViewport().getAlignment() |
694 |
|
.getAlignmentAnnotation(); |
695 |
|
|
696 |
0 |
List<String> ssSources = AlignmentUtils |
697 |
|
.extractSSSourceInAlignmentAnnotation(annotations); |
698 |
0 |
return ssSources; |
699 |
|
} |
700 |
|
|
701 |
|
|
702 |
|
|
703 |
|
|
|
|
| 0% |
Uncovered Elements: 31 (31) |
Complexity: 7 |
Complexity Density: 0.37 |
|
704 |
0 |
protected void calculate_actionPerformed()... |
705 |
|
{ |
706 |
0 |
boolean doPCA = pca.isSelected(); |
707 |
0 |
boolean doPaSiMap = pasimap.isSelected(); |
708 |
0 |
boolean doPairwise = pairwise.isSelected(); |
709 |
0 |
String modelName = modelNames.getSelectedItem() == null ? "" |
710 |
|
: modelNames.getSelectedItem().toString(); |
711 |
0 |
String ssSource = ""; |
712 |
0 |
Object selectedItem = ssSourceDropdown.getSelectedItem(); |
713 |
0 |
if (selectedItem != null) |
714 |
|
{ |
715 |
0 |
ssSource = selectedItem.toString(); |
716 |
|
} |
717 |
0 |
SimilarityParamsI params = getSimilarityParameters(doPCA); |
718 |
0 |
if (ssSource.length() > 0) |
719 |
|
{ |
720 |
0 |
params.setSecondaryStructureSource(ssSource); |
721 |
|
} |
722 |
|
|
723 |
0 |
if (doPCA) |
724 |
|
{ |
725 |
0 |
openPcaPanel(modelName, params); |
726 |
|
} |
727 |
0 |
else if (doPaSiMap) |
728 |
|
{ |
729 |
0 |
openPasimapPanel(modelName, params); |
730 |
|
} |
731 |
0 |
else if (doPairwise) |
732 |
|
{ |
733 |
0 |
openPairwisePanel(modelName, params); |
734 |
|
} |
735 |
|
else |
736 |
|
{ |
737 |
0 |
openTreePanel(modelName, params); |
738 |
|
} |
739 |
|
|
740 |
0 |
closeFrame(); |
741 |
|
} |
742 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
743 |
0 |
private void openPairwisePanel(String modelName, SimilarityParamsI params)... |
744 |
|
{ |
745 |
0 |
ScoreModelI sm = ScoreModels.getInstance().getScoreModel(modelName, |
746 |
|
af.alignPanel); |
747 |
0 |
if (sm == null || !(sm instanceof ScoreMatrix)) |
748 |
|
{ |
749 |
0 |
return; |
750 |
|
} |
751 |
0 |
new Thread(new Runnable() |
752 |
|
{ |
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
753 |
0 |
@Override... |
754 |
|
public void run() |
755 |
|
{ |
756 |
0 |
String pairwise_alignment_title = af.formCalculationTitle( |
757 |
|
MessageManager.getString("action.pairwise_alignment") |
758 |
|
+ " with " + sm.getName(), |
759 |
|
af.getViewport().getSelectionGroup() != null, |
760 |
|
af.getTitle()); |
761 |
0 |
JInternalFrame frame = new JInternalFrame(); |
762 |
0 |
frame.setFrameIcon(null); |
763 |
0 |
frame.setContentPane( |
764 |
|
new PairwiseAlignPanel(af.getViewport(), (ScoreMatrix) sm)); |
765 |
0 |
Desktop.addInternalFrame(frame, pairwise_alignment_title, 600, 500); |
766 |
|
} |
767 |
|
}).start(); |
768 |
|
} |
769 |
|
|
770 |
|
|
771 |
|
|
772 |
|
|
773 |
|
@param |
774 |
|
@param |
775 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 4 |
Complexity Density: 0.57 |
|
776 |
0 |
protected void openTreePanel(String modelName, SimilarityParamsI params)... |
777 |
|
{ |
778 |
|
|
779 |
|
|
780 |
|
|
781 |
|
|
782 |
0 |
AlignViewport viewport = af.getViewport(); |
783 |
0 |
SequenceGroup sg = viewport.getSelectionGroup(); |
784 |
0 |
if (sg != null && sg.getSize() < MIN_TREE_SELECTION) |
785 |
|
{ |
786 |
0 |
JvOptionPane.showMessageDialog(Desktop.desktop, |
787 |
|
MessageManager.formatMessage( |
788 |
|
"label.you_need_at_least_n_sequences", |
789 |
|
MIN_TREE_SELECTION), |
790 |
|
MessageManager.getString("label.not_enough_sequences"), |
791 |
|
JvOptionPane.WARNING_MESSAGE); |
792 |
0 |
return; |
793 |
|
} |
794 |
|
|
795 |
0 |
String treeType = neighbourJoining.isSelected() |
796 |
|
? TreeBuilder.NEIGHBOUR_JOINING |
797 |
|
: TreeBuilder.AVERAGE_DISTANCE; |
798 |
0 |
af.newTreePanel(treeType, modelName, params); |
799 |
|
} |
800 |
|
|
801 |
|
|
802 |
|
|
803 |
|
|
804 |
|
@param |
805 |
|
@param |
806 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 5 |
Complexity Density: 0.83 |
|
807 |
0 |
protected void openPcaPanel(String modelName, SimilarityParamsI params)... |
808 |
|
{ |
809 |
0 |
AlignViewport viewport = af.getViewport(); |
810 |
|
|
811 |
|
|
812 |
|
|
813 |
|
|
814 |
|
|
815 |
0 |
if (((viewport.getSelectionGroup() != null) |
816 |
|
&& (viewport.getSelectionGroup().getSize() < MIN_PCA_SELECTION) |
817 |
|
&& (viewport.getSelectionGroup().getSize() > 0)) |
818 |
|
|| (viewport.getAlignment().getHeight() < MIN_PCA_SELECTION)) |
819 |
|
{ |
820 |
0 |
JvOptionPane.showInternalMessageDialog(this, |
821 |
|
MessageManager.formatMessage( |
822 |
|
"label.you_need_at_least_n_sequences", |
823 |
|
MIN_PCA_SELECTION), |
824 |
|
MessageManager |
825 |
|
.getString("label.sequence_selection_insufficient"), |
826 |
|
JvOptionPane.WARNING_MESSAGE); |
827 |
0 |
return; |
828 |
|
} |
829 |
|
|
830 |
|
|
831 |
|
|
832 |
|
|
833 |
0 |
pcaPanel = new PCAPanel(af.alignPanel, modelName, params); |
834 |
0 |
new Thread(pcaPanel).start(); |
835 |
|
|
836 |
|
} |
837 |
|
|
838 |
|
|
839 |
|
|
840 |
|
|
841 |
|
@param |
842 |
|
@param |
843 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 5 |
Complexity Density: 0.83 |
|
844 |
0 |
protected void openPasimapPanel(String modelName,... |
845 |
|
SimilarityParamsI params) |
846 |
|
{ |
847 |
0 |
AlignViewport viewport = af.getViewport(); |
848 |
|
|
849 |
|
|
850 |
|
|
851 |
|
|
852 |
|
|
853 |
0 |
if (((viewport.getSelectionGroup() != null) |
854 |
|
&& (viewport.getSelectionGroup() |
855 |
|
.getSize() < MIN_PASIMAP_SELECTION) |
856 |
|
&& (viewport.getSelectionGroup().getSize() > 0)) |
857 |
|
|| (viewport.getAlignment() |
858 |
|
.getHeight() < MIN_PASIMAP_SELECTION)) |
859 |
|
{ |
860 |
0 |
JvOptionPane.showInternalMessageDialog(this, |
861 |
|
MessageManager.formatMessage( |
862 |
|
"label.you_need_at_least_n_sequences", |
863 |
|
MIN_PASIMAP_SELECTION), |
864 |
|
MessageManager |
865 |
|
.getString("label.sequence_selection_insufficient"), |
866 |
|
JvOptionPane.WARNING_MESSAGE); |
867 |
0 |
return; |
868 |
|
} |
869 |
|
|
870 |
|
|
871 |
|
|
872 |
|
|
873 |
0 |
pasimapPanel = new PaSiMapPanel(af.alignPanel, modelName); |
874 |
0 |
new Thread(pasimapPanel).start(); |
875 |
|
|
876 |
|
} |
877 |
|
|
878 |
|
|
879 |
|
|
880 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 2 |
Complexity Density: 1 |
|
881 |
0 |
protected void closeFrame()... |
882 |
|
{ |
883 |
0 |
try |
884 |
|
{ |
885 |
0 |
frame.setClosed(true); |
886 |
|
} catch (PropertyVetoException ex) |
887 |
|
{ |
888 |
|
} |
889 |
|
} |
890 |
|
|
891 |
|
|
892 |
|
|
893 |
|
|
894 |
|
|
895 |
|
@param |
896 |
|
@return |
897 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
898 |
0 |
protected SimilarityParamsI getSimilarityParameters(boolean doPCA)... |
899 |
|
{ |
900 |
|
|
901 |
|
|
902 |
|
|
903 |
|
|
904 |
|
|
905 |
0 |
boolean includeGapGap = true; |
906 |
0 |
boolean includeGapResidue = true; |
907 |
0 |
boolean matchOnShortestLength = false; |
908 |
|
|
909 |
|
|
910 |
|
|
911 |
|
|
912 |
|
|
913 |
|
|
914 |
|
|
915 |
0 |
boolean matchGap = doPCA ? false : treeMatchGaps; |
916 |
|
|
917 |
0 |
return new SimilarityParams(includeGapGap, matchGap, includeGapResidue, |
918 |
|
matchOnShortestLength); |
919 |
|
} |
920 |
|
|
921 |
|
|
922 |
|
|
923 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 2 |
Complexity Density: 1 |
|
924 |
0 |
protected void close_actionPerformed()... |
925 |
|
{ |
926 |
0 |
try |
927 |
|
{ |
928 |
0 |
frame.setClosed(true); |
929 |
|
} catch (Exception ex) |
930 |
|
{ |
931 |
|
} |
932 |
|
} |
933 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
934 |
0 |
public PCAPanel getPcaPanel()... |
935 |
|
{ |
936 |
0 |
return pcaPanel; |
937 |
|
} |
938 |
|
} |