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