1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.ws.jws2; |
22 |
|
|
23 |
|
import jalview.datamodel.AlignmentI; |
24 |
|
import jalview.datamodel.AlignmentView; |
25 |
|
import jalview.gui.AlignFrame; |
26 |
|
import jalview.gui.Desktop; |
27 |
|
import jalview.gui.JvOptionPane; |
28 |
|
import jalview.gui.JvSwingUtils; |
29 |
|
import jalview.util.MessageManager; |
30 |
|
import jalview.ws.jws2.jabaws2.Jws2Instance; |
31 |
|
import jalview.ws.params.WsParamSetI; |
32 |
|
|
33 |
|
import java.awt.event.ActionEvent; |
34 |
|
import java.awt.event.ActionListener; |
35 |
|
import java.awt.event.MouseAdapter; |
36 |
|
import java.awt.event.MouseEvent; |
37 |
|
import java.util.List; |
38 |
|
|
39 |
|
import javax.swing.JMenu; |
40 |
|
import javax.swing.JMenuItem; |
41 |
|
import javax.swing.ToolTipManager; |
42 |
|
|
43 |
|
import compbio.data.msa.MsaWS; |
44 |
|
import compbio.metadata.Argument; |
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
@author |
50 |
|
@version |
51 |
|
|
|
|
| 46.2% |
Uncovered Elements: 78 (145) |
Complexity: 38 |
Complexity Density: 0.42 |
|
52 |
|
public class MsaWSClient extends Jws2Client |
53 |
|
{ |
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
MsaWS server; |
58 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
59 |
0 |
public MsaWSClient(Jws2Instance sh, String altitle,... |
60 |
|
jalview.datamodel.AlignmentView msa, boolean submitGaps, |
61 |
|
boolean preserveOrder, AlignmentI seqdataset, |
62 |
|
AlignFrame _alignFrame) |
63 |
|
{ |
64 |
0 |
this(sh, null, null, false, altitle, msa, submitGaps, preserveOrder, |
65 |
|
seqdataset, _alignFrame); |
66 |
|
|
67 |
|
} |
68 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
69 |
0 |
public MsaWSClient(Jws2Instance sh, WsParamSetI preset, String altitle,... |
70 |
|
jalview.datamodel.AlignmentView msa, boolean submitGaps, |
71 |
|
boolean preserveOrder, AlignmentI seqdataset, |
72 |
|
AlignFrame _alignFrame) |
73 |
|
{ |
74 |
0 |
this(sh, preset, null, false, altitle, msa, submitGaps, preserveOrder, |
75 |
|
seqdataset, _alignFrame); |
76 |
|
|
77 |
|
} |
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
@param |
84 |
|
|
85 |
|
@param |
86 |
|
|
87 |
|
@param |
88 |
|
|
89 |
|
@param |
90 |
|
|
91 |
|
@param |
92 |
|
|
93 |
|
|
94 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 4 |
Complexity Density: 0.36 |
|
95 |
0 |
public MsaWSClient(Jws2Instance sh, WsParamSetI preset,... |
96 |
|
List<Argument> arguments, boolean editParams, String altitle, |
97 |
|
jalview.datamodel.AlignmentView msa, boolean submitGaps, |
98 |
|
boolean preserveOrder, AlignmentI seqdataset, |
99 |
|
AlignFrame _alignFrame) |
100 |
|
{ |
101 |
0 |
super(_alignFrame, preset, arguments); |
102 |
0 |
if (!processParams(sh, editParams)) |
103 |
|
{ |
104 |
0 |
return; |
105 |
|
} |
106 |
|
|
107 |
0 |
if (!(sh.service instanceof MsaWS)) |
108 |
|
{ |
109 |
|
|
110 |
0 |
JvOptionPane.showMessageDialog(Desktop.desktop, |
111 |
|
MessageManager.formatMessage( |
112 |
|
"label.service_called_is_not_msa_service", |
113 |
|
new String[] |
114 |
|
{ sh.serviceType }), |
115 |
|
MessageManager.getString("label.internal_jalview_error"), |
116 |
|
JvOptionPane.WARNING_MESSAGE); |
117 |
|
|
118 |
0 |
return; |
119 |
|
} |
120 |
0 |
server = (MsaWS) sh.service; |
121 |
0 |
if ((wsInfo = setWebService(sh, false)) == null) |
122 |
|
{ |
123 |
0 |
JvOptionPane.showMessageDialog(Desktop.desktop, MessageManager |
124 |
|
.formatMessage("label.msa_service_is_unknown", new String[] |
125 |
|
{ sh.serviceType }), |
126 |
|
MessageManager.getString("label.internal_jalview_error"), |
127 |
|
JvOptionPane.WARNING_MESSAGE); |
128 |
|
|
129 |
0 |
return; |
130 |
|
} |
131 |
|
|
132 |
0 |
startMsaWSClient(altitle, msa, submitGaps, preserveOrder, seqdataset); |
133 |
|
|
134 |
|
} |
135 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
136 |
4767 |
public MsaWSClient()... |
137 |
|
{ |
138 |
4767 |
super(); |
139 |
|
|
140 |
|
} |
141 |
|
|
|
|
| 0% |
Uncovered Elements: 25 (25) |
Complexity: 8 |
Complexity Density: 0.53 |
|
142 |
0 |
private void startMsaWSClient(String altitle, AlignmentView msa,... |
143 |
|
boolean submitGaps, boolean preserveOrder, AlignmentI seqdataset) |
144 |
|
{ |
145 |
|
|
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
|
150 |
0 |
wsInfo.setProgressText(((submitGaps) ? "Re-alignment" : "Alignment") |
151 |
|
+ " of " + altitle + "\nJob details\n"); |
152 |
0 |
String jobtitle = WebServiceName.toLowerCase(); |
153 |
0 |
if (jobtitle.endsWith("alignment")) |
154 |
|
{ |
155 |
0 |
if (submitGaps && (!jobtitle.endsWith("realignment") |
156 |
|
|| jobtitle.indexOf("profile") == -1)) |
157 |
|
{ |
158 |
0 |
int pos = jobtitle.indexOf("alignment"); |
159 |
0 |
jobtitle = WebServiceName.substring(0, pos) + "re-alignment of " |
160 |
|
+ altitle; |
161 |
|
} |
162 |
|
else |
163 |
|
{ |
164 |
0 |
jobtitle = WebServiceName + " of " + altitle; |
165 |
|
} |
166 |
|
} |
167 |
|
else |
168 |
|
{ |
169 |
0 |
jobtitle = WebServiceName + (submitGaps ? " re" : " ") |
170 |
|
+ "alignment of " + altitle; |
171 |
|
} |
172 |
|
|
173 |
0 |
MsaWSThread msathread = new MsaWSThread(server, preset, paramset, WsURL, |
174 |
|
wsInfo, alignFrame, WebServiceName, jobtitle, msa, submitGaps, |
175 |
|
preserveOrder, seqdataset); |
176 |
0 |
if (msathread.hasValidInput()) |
177 |
|
{ |
178 |
0 |
wsInfo.setthisService(msathread); |
179 |
0 |
wsInfo.setVisible(true); |
180 |
0 |
msathread.start(); |
181 |
|
} |
182 |
|
else |
183 |
|
{ |
184 |
0 |
wsInfo.setVisible(false); |
185 |
0 |
JvOptionPane.showMessageDialog(alignFrame, |
186 |
|
MessageManager.getString("info.invalid_msa_input_mininfo"), |
187 |
|
MessageManager.getString("info.invalid_msa_notenough"), |
188 |
|
JvOptionPane.INFORMATION_MESSAGE); |
189 |
|
} |
190 |
|
} |
191 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
192 |
0 |
protected String getServiceActionKey()... |
193 |
|
{ |
194 |
0 |
return "MsaWS"; |
195 |
|
} |
196 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
197 |
0 |
protected String getServiceActionDescription()... |
198 |
|
{ |
199 |
0 |
return "Multiple Sequence Alignment"; |
200 |
|
} |
201 |
|
|
202 |
|
|
203 |
|
|
204 |
|
|
205 |
|
|
206 |
|
@return |
207 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
208 |
9534 |
private boolean canSubmitGaps()... |
209 |
|
{ |
210 |
|
|
211 |
|
|
212 |
9534 |
return (WebServiceName.indexOf("lustal") > -1); |
213 |
|
} |
214 |
|
|
|
|
| 93.9% |
Uncovered Elements: 4 (66) |
Complexity: 12 |
Complexity Density: 0.25 |
|
215 |
4767 |
@Override... |
216 |
|
public void attachWSMenuEntry(JMenu rmsawsmenu, |
217 |
|
final Jws2Instance service, final AlignFrame alignFrame) |
218 |
|
{ |
219 |
4767 |
if (registerAAConWSInstance(rmsawsmenu, service, alignFrame)) |
220 |
|
{ |
221 |
|
|
222 |
0 |
return; |
223 |
|
} |
224 |
4767 |
setWebService(service, true); |
225 |
4767 |
boolean finished = true, submitGaps = false; |
226 |
4767 |
JMenu msawsmenu = rmsawsmenu; |
227 |
4767 |
String svcname = WebServiceName; |
228 |
4767 |
if (svcname.endsWith("WS")) |
229 |
|
{ |
230 |
4767 |
svcname = svcname.substring(0, svcname.length() - 2); |
231 |
|
} |
232 |
4767 |
String calcName = svcname + " "; |
233 |
4767 |
if (canSubmitGaps()) |
234 |
|
{ |
235 |
1235 |
msawsmenu = new JMenu(svcname); |
236 |
1235 |
rmsawsmenu.add(msawsmenu); |
237 |
1235 |
calcName = ""; |
238 |
|
} |
239 |
4767 |
boolean hasparams = service.hasParameters(); |
240 |
4767 |
do |
241 |
|
{ |
242 |
6002 |
String action = "Align "; |
243 |
6002 |
if (submitGaps == true) |
244 |
|
{ |
245 |
1235 |
action = "Realign "; |
246 |
1235 |
msawsmenu = new JMenu(MessageManager |
247 |
|
.formatMessage("label.realign_with_params", new String[] |
248 |
|
{ svcname })); |
249 |
1235 |
msawsmenu.setToolTipText(MessageManager |
250 |
|
.getString("label.align_sequences_to_existing_alignment")); |
251 |
1235 |
rmsawsmenu.add(msawsmenu); |
252 |
|
} |
253 |
6002 |
final boolean withGaps = submitGaps; |
254 |
|
|
255 |
6002 |
JMenuItem method = new JMenuItem(MessageManager.formatMessage( |
256 |
|
"label.calcname_with_default_settings", new String[] |
257 |
|
{ calcName })); |
258 |
6002 |
method.setToolTipText(MessageManager.formatMessage( |
259 |
|
"label.action_with_default_settings", new String[] |
260 |
|
{ action })); |
261 |
|
|
262 |
6002 |
method.addActionListener(new ActionListener() |
263 |
|
{ |
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
264 |
0 |
@Override... |
265 |
|
public void actionPerformed(ActionEvent e) |
266 |
|
{ |
267 |
0 |
AlignmentView msa = alignFrame.gatherSequencesForAlignment(); |
268 |
|
|
269 |
0 |
if (msa != null) |
270 |
|
{ |
271 |
0 |
new MsaWSClient(service, alignFrame.getTitle(), msa, withGaps, |
272 |
|
true, |
273 |
|
alignFrame.getViewport().getAlignment().getDataset(), |
274 |
|
alignFrame); |
275 |
|
} |
276 |
|
|
277 |
|
} |
278 |
|
}); |
279 |
6002 |
msawsmenu.add(method); |
280 |
6002 |
if (hasparams) |
281 |
|
{ |
282 |
|
|
283 |
|
|
284 |
6000 |
method = new JMenuItem( |
285 |
|
MessageManager.getString("label.edit_settings_and_run")); |
286 |
6000 |
method.setToolTipText(MessageManager.getString( |
287 |
|
"label.view_and_change_parameters_before_alignment")); |
288 |
|
|
289 |
6000 |
method.addActionListener(new ActionListener() |
290 |
|
{ |
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
291 |
0 |
@Override... |
292 |
|
public void actionPerformed(ActionEvent e) |
293 |
|
{ |
294 |
0 |
AlignmentView msa = alignFrame.gatherSequencesForAlignment(); |
295 |
0 |
if (msa != null) |
296 |
|
{ |
297 |
0 |
new MsaWSClient(service, null, null, true, |
298 |
|
alignFrame.getTitle(), msa, withGaps, true, |
299 |
|
alignFrame.getViewport().getAlignment().getDataset(), |
300 |
|
alignFrame); |
301 |
|
} |
302 |
|
|
303 |
|
} |
304 |
|
}); |
305 |
6000 |
msawsmenu.add(method); |
306 |
6000 |
List<WsParamSetI> presets = service.getParamStore().getPresets(); |
307 |
6000 |
if (presets != null && presets.size() > 0) |
308 |
|
{ |
309 |
3059 |
JMenu presetlist = new JMenu(MessageManager.formatMessage( |
310 |
|
"label.run_with_preset_params", new String[] |
311 |
|
{ calcName })); |
312 |
|
|
313 |
3059 |
final int showToolTipFor = ToolTipManager.sharedInstance() |
314 |
|
.getDismissDelay(); |
315 |
3059 |
for (final WsParamSetI preset : presets) |
316 |
|
{ |
317 |
7404 |
final JMenuItem methodR = new JMenuItem(preset.getName()); |
318 |
7404 |
final int QUICK_TOOLTIP = 1500; |
319 |
|
|
320 |
|
|
321 |
7404 |
methodR.addMouseListener(new MouseAdapter() |
322 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
323 |
0 |
@Override... |
324 |
|
public void mouseEntered(MouseEvent e) |
325 |
|
{ |
326 |
0 |
ToolTipManager.sharedInstance() |
327 |
|
.setDismissDelay(QUICK_TOOLTIP); |
328 |
|
} |
329 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
330 |
0 |
@Override... |
331 |
|
public void mouseExited(MouseEvent e) |
332 |
|
{ |
333 |
0 |
ToolTipManager.sharedInstance() |
334 |
|
.setDismissDelay(showToolTipFor); |
335 |
|
} |
336 |
|
|
337 |
|
}); |
338 |
7404 |
String tooltip = JvSwingUtils.wrapTooltip(true, "<strong>" |
339 |
7404 |
+ (preset.isModifiable() |
340 |
|
? MessageManager.getString("label.user_preset") |
341 |
|
: MessageManager |
342 |
|
.getString("label.service_preset")) |
343 |
|
+ "</strong><br/>" + preset.getDescription()); |
344 |
7404 |
methodR.setToolTipText(tooltip); |
345 |
7404 |
methodR.addActionListener(new ActionListener() |
346 |
|
{ |
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
347 |
0 |
@Override... |
348 |
|
public void actionPerformed(ActionEvent e) |
349 |
|
{ |
350 |
0 |
AlignmentView msa = alignFrame |
351 |
|
.gatherSequencesForAlignment(); |
352 |
|
|
353 |
0 |
if (msa != null) |
354 |
|
{ |
355 |
0 |
MsaWSClient msac = new MsaWSClient(service, preset, |
356 |
|
alignFrame.getTitle(), msa, false, true, |
357 |
|
alignFrame.getViewport().getAlignment() |
358 |
|
.getDataset(), |
359 |
|
alignFrame); |
360 |
|
} |
361 |
|
|
362 |
|
} |
363 |
|
|
364 |
|
}); |
365 |
7404 |
presetlist.add(methodR); |
366 |
|
} |
367 |
3059 |
msawsmenu.add(presetlist); |
368 |
|
} |
369 |
|
} |
370 |
6002 |
if (!submitGaps && canSubmitGaps()) |
371 |
|
{ |
372 |
1235 |
submitGaps = true; |
373 |
1235 |
finished = false; |
374 |
|
} |
375 |
|
else |
376 |
|
{ |
377 |
4767 |
finished = true; |
378 |
|
} |
379 |
6002 |
} while (!finished); |
380 |
|
} |
381 |
|
} |