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.scoremodels.ScoreModels; |
24 |
|
import jalview.api.analysis.ScoreModelI; |
25 |
|
import jalview.api.analysis.SimilarityParamsI; |
26 |
|
import jalview.bin.Console; |
27 |
|
import jalview.datamodel.Alignment; |
28 |
|
import jalview.datamodel.AlignmentI; |
29 |
|
import jalview.datamodel.AlignmentView; |
30 |
|
import jalview.datamodel.HiddenColumns; |
31 |
|
import jalview.datamodel.SequenceGroup; |
32 |
|
import jalview.datamodel.SequenceI; |
33 |
|
import jalview.gui.ImageExporter.ImageWriterI; |
34 |
|
import jalview.jbgui.GPCAPanel; |
35 |
|
import jalview.util.ImageMaker; |
36 |
|
import jalview.util.MessageManager; |
37 |
|
import jalview.viewmodel.AlignmentViewport; |
38 |
|
import jalview.viewmodel.PaSiMapModel; |
39 |
|
|
40 |
|
import java.awt.BorderLayout; |
41 |
|
import java.awt.Dimension; |
42 |
|
import java.awt.Graphics; |
43 |
|
import java.awt.event.ActionEvent; |
44 |
|
import java.awt.event.ActionListener; |
45 |
|
import java.awt.print.PageFormat; |
46 |
|
import java.awt.print.Printable; |
47 |
|
import java.awt.print.PrinterException; |
48 |
|
import java.awt.print.PrinterJob; |
49 |
|
|
50 |
|
import javax.swing.ButtonGroup; |
51 |
|
import javax.swing.JMenuItem; |
52 |
|
import javax.swing.JRadioButtonMenuItem; |
53 |
|
import javax.swing.event.InternalFrameAdapter; |
54 |
|
import javax.swing.event.InternalFrameEvent; |
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
|
|
| 0% |
Uncovered Elements: 153 (153) |
Complexity: 32 |
Complexity Density: 0.27 |
|
59 |
|
public class PaSiMapPanel extends SpatialPanel<PaSiMapModel> |
60 |
|
implements Runnable, IProgressIndicator |
61 |
|
{ |
62 |
|
|
63 |
|
private static final int MAX_PASIMAP_SEQ = 20000; |
64 |
|
|
65 |
|
private final int GAP_OPEN_COST = 100; |
66 |
|
|
67 |
|
private final int GAP_EXTEND_COST = 5; |
68 |
|
private String newPasimapTitle; |
69 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
70 |
0 |
@Override ... |
71 |
|
public String getSpatialName() { |
72 |
0 |
return MessageManager.getString("label.pasimap"); |
73 |
|
} |
74 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
75 |
0 |
@Override ... |
76 |
|
public String getSpatialNameDetails() { |
77 |
0 |
return MessageManager.getString("label.pasimap_details"); |
78 |
|
} |
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
@param |
85 |
|
@param |
86 |
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 2 |
Complexity Density: 0.12 |
|
87 |
0 |
public PaSiMapPanel(AlignmentPanel alignPanel, String modelName)... |
88 |
|
{ |
89 |
0 |
super(); |
90 |
0 |
init(alignPanel); |
91 |
0 |
boolean nucleotide = av.getAlignment().isNucleotide(); |
92 |
|
|
93 |
0 |
boolean selected = av.getSelectionGroup() != null |
94 |
|
&& av.getSelectionGroup().getSize() > 0; |
95 |
0 |
SequenceI[] seqs; |
96 |
0 |
if (!selected) |
97 |
|
{ |
98 |
0 |
seqs = av.getAlignment().getSequencesArray(); |
99 |
|
} |
100 |
|
else |
101 |
|
{ |
102 |
0 |
seqs = av.getSelectionGroup().getSequencesInOrder(av.getAlignment()); |
103 |
|
} |
104 |
|
|
105 |
0 |
ScoreModelI scoreModel = ScoreModels.getInstance() |
106 |
|
.getScoreModel(modelName, ap); |
107 |
0 |
setPasimapModel(new PaSiMapModel(av, seqs, nucleotide, scoreModel)); |
108 |
|
|
109 |
0 |
newPasimapTitle = alignPanel.alignFrame.formCalculationTitle( |
110 |
|
MessageManager.formatMessage("label.calc_title", "PaSiMap", |
111 |
|
scoreModel.getName()), |
112 |
|
selected, ap.alignFrame.getTitle()); |
113 |
|
|
114 |
0 |
PaintRefresher.Register(this, av.getSequenceSetId()); |
115 |
|
|
116 |
0 |
setRotatableCanvas(new RotatableCanvas(alignPanel)); |
117 |
0 |
this.getContentPane().add(getRotatableCanvas(), BorderLayout.CENTER); |
118 |
|
|
119 |
0 |
addKeyListener(getRotatableCanvas()); |
120 |
0 |
validate(); |
121 |
|
} |
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
|
|
|
| 0% |
Uncovered Elements: 57 (57) |
Complexity: 9 |
Complexity Density: 0.2 |
|
126 |
0 |
@Override... |
127 |
|
public void run() |
128 |
|
{ |
129 |
0 |
working = true; |
130 |
0 |
progId = System.currentTimeMillis(); |
131 |
0 |
progressBar = new jalview.gui.ProgressBar(statusPanel, statusBar); |
132 |
0 |
String message = MessageManager |
133 |
|
.getString("label.pasimap_recalculating"); |
134 |
0 |
if (getParent() == null) |
135 |
|
{ |
136 |
0 |
progressBar = ap.alignFrame; |
137 |
0 |
message = MessageManager.getString("label.pasimap_calculating"); |
138 |
|
} |
139 |
0 |
progressBar.setProgressBar(message, progId); |
140 |
0 |
try |
141 |
|
{ |
142 |
0 |
SequenceGroup selGroup = av.getSelectionGroup(); |
143 |
|
|
144 |
0 |
if (selGroup == null) |
145 |
|
{ |
146 |
0 |
selGroup = new SequenceGroup(av.getAlignment().getSequences()); |
147 |
0 |
selGroup.setStartRes(0); |
148 |
0 |
selGroup.setEndRes(av.getAlignment().getWidth() - 1); |
149 |
|
} |
150 |
|
|
151 |
0 |
if (selGroup.getSize() > MAX_PASIMAP_SEQ) |
152 |
|
{ |
153 |
0 |
int start = selGroup.getStartRes(), end = selGroup.getEndRes(); |
154 |
0 |
selGroup = new SequenceGroup( |
155 |
|
selGroup.getSequences().subList(0, MAX_PASIMAP_SEQ)); |
156 |
0 |
selGroup.setStartRes(start); |
157 |
0 |
selGroup.setEndRes(end); |
158 |
0 |
Console.warn("Truncated input sequences for PASIMAP analysis to " |
159 |
|
+ MAX_PASIMAP_SEQ); |
160 |
|
} |
161 |
|
|
162 |
0 |
final PairwiseAlignPanel pap = new PairwiseAlignPanel(av, selGroup, true, |
163 |
|
GAP_OPEN_COST, GAP_EXTEND_COST, false, null); |
164 |
0 |
pap.setDiscardAlignments(true); |
165 |
0 |
pap.setQuiet(true); |
166 |
|
|
167 |
0 |
System.out.println(pap != null); |
168 |
0 |
addProgressListenerFor(pap); |
169 |
0 |
progressBar.registerHandler(progId, new IProgressIndicatorHandler() |
170 |
|
{ |
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
171 |
0 |
@Override... |
172 |
|
public boolean cancelActivity(long id) |
173 |
|
{ |
174 |
0 |
getPasimapModel().cancel(); |
175 |
0 |
return true; |
176 |
|
} |
177 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
178 |
0 |
@Override... |
179 |
|
public boolean canCancel() |
180 |
|
{ |
181 |
0 |
return getPasimapModel().canCancel(); |
182 |
|
} |
183 |
|
}); |
184 |
0 |
getPasimapModel().calculate(pap); |
185 |
0 |
if (!getPasimapModel().isCancelled()) |
186 |
|
{ |
187 |
|
|
188 |
0 |
outputAlignment.setVisible(!pap.isDiscardAlignments() && !pap.isQuiet()); |
189 |
0 |
xCombobox.setSelectedIndex(0); |
190 |
0 |
yCombobox.setSelectedIndex(1); |
191 |
0 |
zCombobox.setSelectedIndex(2); |
192 |
|
|
193 |
0 |
getPasimapModel().updateRc(getRotatableCanvas()); |
194 |
|
|
195 |
0 |
setTop(getPasimapModel().getTop()); |
196 |
0 |
initClusterMenu(); |
197 |
|
} |
198 |
|
} catch (OutOfMemoryError er) |
199 |
|
{ |
200 |
0 |
new OOMWarning("calculating PaSiMap", er); |
201 |
0 |
working = false; |
202 |
0 |
return; |
203 |
|
} finally |
204 |
|
{ |
205 |
0 |
if (!getPasimapModel().isCancelled()) { |
206 |
|
|
207 |
0 |
progressBar.setProgressBar("", progId); |
208 |
|
} |
209 |
|
} |
210 |
|
|
211 |
0 |
repaint(); |
212 |
0 |
if (!getPasimapModel().isCancelled() && getParent() == null) |
213 |
|
{ |
214 |
0 |
Desktop.addInternalFrame(this, |
215 |
|
newPasimapTitle, |
216 |
|
475, 450); |
217 |
0 |
this.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT)); |
218 |
|
} |
219 |
0 |
working = false; |
220 |
|
} |
221 |
|
|
222 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
223 |
0 |
@Override... |
224 |
|
protected void viewMenu_menuSelected() |
225 |
|
{ |
226 |
0 |
buildAssociatedViewMenu(); |
227 |
|
} |
228 |
|
|
229 |
|
|
230 |
|
|
231 |
|
|
232 |
|
|
|
|
| 0% |
Uncovered Elements: 28 (28) |
Complexity: 5 |
Complexity Density: 0.23 |
|
233 |
0 |
void buildAssociatedViewMenu()... |
234 |
|
{ |
235 |
0 |
AlignmentPanel[] aps = PaintRefresher |
236 |
|
.getAssociatedPanels(av.getSequenceSetId()); |
237 |
0 |
if (aps.length == 1 && getRotatableCanvas().av == aps[0].av) |
238 |
|
{ |
239 |
0 |
associateViewsMenu.setVisible(false); |
240 |
0 |
return; |
241 |
|
} |
242 |
|
|
243 |
0 |
associateViewsMenu.setVisible(true); |
244 |
|
|
245 |
0 |
if ((viewMenu |
246 |
|
.getItem(viewMenu.getItemCount() - 2) instanceof JMenuItem)) |
247 |
|
{ |
248 |
0 |
viewMenu.insertSeparator(viewMenu.getItemCount() - 1); |
249 |
|
} |
250 |
|
|
251 |
0 |
associateViewsMenu.removeAll(); |
252 |
|
|
253 |
0 |
JRadioButtonMenuItem item; |
254 |
0 |
ButtonGroup buttonGroup = new ButtonGroup(); |
255 |
0 |
int iSize = aps.length; |
256 |
|
|
257 |
0 |
for (int i = 0; i < iSize; i++) |
258 |
|
{ |
259 |
0 |
final AlignmentPanel panel = aps[i]; |
260 |
0 |
item = new JRadioButtonMenuItem(panel.av.getViewName(), |
261 |
|
panel.av == getRotatableCanvas().av); |
262 |
0 |
buttonGroup.add(item); |
263 |
0 |
item.addActionListener(new ActionListener() |
264 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
265 |
0 |
@Override... |
266 |
|
public void actionPerformed(ActionEvent evt) |
267 |
|
{ |
268 |
0 |
selectAssociatedView(panel); |
269 |
|
} |
270 |
|
}); |
271 |
|
|
272 |
0 |
associateViewsMenu.add(item); |
273 |
|
} |
274 |
|
|
275 |
0 |
final JRadioButtonMenuItem itemf = new JRadioButtonMenuItem( |
276 |
|
"All Views"); |
277 |
|
|
278 |
0 |
buttonGroup.add(itemf); |
279 |
|
|
280 |
0 |
itemf.setSelected(getRotatableCanvas().isApplyToAllViews()); |
281 |
0 |
itemf.addActionListener(new ActionListener() |
282 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
283 |
0 |
@Override... |
284 |
|
public void actionPerformed(ActionEvent evt) |
285 |
|
{ |
286 |
0 |
getRotatableCanvas().setApplyToAllViews(itemf.isSelected()); |
287 |
|
} |
288 |
|
}); |
289 |
0 |
associateViewsMenu.add(itemf); |
290 |
|
|
291 |
|
} |
292 |
|
|
293 |
|
|
294 |
|
|
295 |
|
|
296 |
|
@see |
297 |
|
|
298 |
|
|
299 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.33 |
|
300 |
0 |
@Override... |
301 |
|
protected void outputPoints_actionPerformed() |
302 |
|
{ |
303 |
0 |
CutAndPasteTransfer cap = new CutAndPasteTransfer(); |
304 |
0 |
try |
305 |
|
{ |
306 |
0 |
cap.setText(getPasimapModel().getPointsasCsv(false, |
307 |
|
xCombobox.getSelectedIndex(), yCombobox.getSelectedIndex(), |
308 |
|
zCombobox.getSelectedIndex())); |
309 |
0 |
Desktop.addInternalFrame(cap, MessageManager |
310 |
|
.formatMessage("label.points_for_params", new String[] |
311 |
|
{ this.getTitle() }), 500, 500); |
312 |
|
} catch (OutOfMemoryError oom) |
313 |
|
{ |
314 |
0 |
new OOMWarning("exporting PaSiMap points", oom); |
315 |
0 |
cap.dispose(); |
316 |
|
} |
317 |
|
} |
318 |
|
|
319 |
|
|
320 |
|
|
321 |
|
|
322 |
|
@see |
323 |
|
|
324 |
|
|
325 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.33 |
|
326 |
0 |
@Override... |
327 |
|
protected void outputProjPoints_actionPerformed() |
328 |
|
{ |
329 |
0 |
CutAndPasteTransfer cap = new CutAndPasteTransfer(); |
330 |
0 |
try |
331 |
|
{ |
332 |
0 |
cap.setText(getPasimapModel().getPointsasCsv(true, |
333 |
|
xCombobox.getSelectedIndex(), yCombobox.getSelectedIndex(), |
334 |
|
zCombobox.getSelectedIndex())); |
335 |
0 |
Desktop.addInternalFrame(cap, MessageManager.formatMessage( |
336 |
|
"label.transformed_points_for_params", new String[] |
337 |
|
{ this.getTitle() }), 500, 500); |
338 |
|
} catch (OutOfMemoryError oom) |
339 |
|
{ |
340 |
0 |
new OOMWarning("exporting transformed PaSiMap points", oom); |
341 |
0 |
cap.dispose(); |
342 |
|
} |
343 |
|
} |
344 |
|
|
345 |
|
|
346 |
|
|
347 |
|
|
348 |
|
@see |
349 |
|
|
350 |
|
|
351 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.33 |
|
352 |
0 |
@Override... |
353 |
|
protected void outputAlignment_actionPerformed() |
354 |
|
{ |
355 |
0 |
CutAndPasteTransfer cap = new CutAndPasteTransfer(); |
356 |
0 |
try |
357 |
|
{ |
358 |
0 |
cap.setText(getPasimapModel().getAlignmentOutput()); |
359 |
0 |
Desktop.addInternalFrame(cap, MessageManager.formatMessage( |
360 |
|
"label.pairwise_alignment_for_params", new String[] |
361 |
|
{ this.getTitle() }), 500, 500); |
362 |
|
} catch (OutOfMemoryError oom) |
363 |
|
{ |
364 |
0 |
new OOMWarning("exporting pairwise alignments", oom); |
365 |
0 |
cap.dispose(); |
366 |
|
} |
367 |
|
} |
368 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
369 |
0 |
@Override... |
370 |
|
protected void resetButton_actionPerformed() |
371 |
|
{ |
372 |
0 |
int t = getTop(); |
373 |
0 |
setTop(0); |
374 |
0 |
xCombobox.setSelectedIndex(0); |
375 |
0 |
yCombobox.setSelectedIndex(1); |
376 |
0 |
setTop(t); |
377 |
0 |
zCombobox.setSelectedIndex(2); |
378 |
|
} |
379 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
380 |
0 |
public PaSiMapModel getPasimapModel()... |
381 |
|
{ |
382 |
0 |
return spatialModel; |
383 |
|
} |
384 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
385 |
0 |
public void setPasimapModel(PaSiMapModel pasimapModel)... |
386 |
|
{ |
387 |
0 |
this.spatialModel = pasimapModel; |
388 |
|
} |
389 |
|
} |