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