2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.ws.jws2;
23 import java.awt.event.ActionEvent;
24 import java.awt.event.ActionListener;
25 import java.util.List;
29 import jalview.datamodel.*;
31 import compbio.data.msa.MsaWS;
32 import compbio.metadata.Argument;
33 import jalview.util.MessageManager;
34 import jalview.ws.jws2.jabaws2.Jws2Instance;
35 import jalview.ws.params.WsParamSetI;
43 public class MsaWSClient extends Jws2Client
46 * server is a WSDL2Java generated stub for an archetypal MsaWSI service.
50 public MsaWSClient(Jws2Instance sh, String altitle,
51 jalview.datamodel.AlignmentView msa, boolean submitGaps,
52 boolean preserveOrder, Alignment seqdataset,
53 AlignFrame _alignFrame)
55 this(sh, null, null, false, altitle, msa, submitGaps, preserveOrder,
56 seqdataset, _alignFrame);
57 // TODO Auto-generated constructor stub
60 public MsaWSClient(Jws2Instance sh, WsParamSetI preset, String altitle,
61 jalview.datamodel.AlignmentView msa, boolean submitGaps,
62 boolean preserveOrder, Alignment seqdataset,
63 AlignFrame _alignFrame)
65 this(sh, preset, null, false, altitle, msa, submitGaps, preserveOrder,
66 seqdataset, _alignFrame);
67 // TODO Auto-generated constructor stub
71 * Creates a new MsaWSClient object that uses a service given by an externally
72 * retrieved ServiceHandle
75 * service handle of type AbstractName(MsaWS)
82 * @param preserveOrder
86 public MsaWSClient(Jws2Instance sh, WsParamSetI preset,
87 List<Argument> arguments, boolean editParams, String altitle,
88 jalview.datamodel.AlignmentView msa, boolean submitGaps,
89 boolean preserveOrder, Alignment seqdataset,
90 AlignFrame _alignFrame)
92 super(_alignFrame, preset, arguments);
93 if (!processParams(sh, editParams))
98 if (!(sh.service instanceof MsaWS))
100 // redundant at mo - but may change
104 "The Service called \n"
106 + "\nis not a \nMultiple Sequence Alignment Service !",
107 "Internal Jalview Error", JOptionPane.WARNING_MESSAGE);
111 server = (MsaWS) sh.service;
112 if ((wsInfo = setWebService(sh, false)) == null)
114 JOptionPane.showMessageDialog(Desktop.desktop,
115 "The Multiple Sequence Alignment Service named "
116 + sh.serviceType + " is unknown",
117 "Internal Jalview Error", JOptionPane.WARNING_MESSAGE);
121 startMsaWSClient(altitle, msa, submitGaps, preserveOrder, seqdataset);
128 // add a class reference to the list
131 private void startMsaWSClient(String altitle, AlignmentView msa,
132 boolean submitGaps, boolean preserveOrder, Alignment seqdataset)
134 // if (!locateWebService())
139 wsInfo.setProgressText(((submitGaps) ? "Re-alignment" : "Alignment")
140 + " of " + altitle + "\nJob details\n");
141 String jobtitle = WebServiceName.toLowerCase();
142 if (jobtitle.endsWith("alignment"))
145 && (!jobtitle.endsWith("realignment") || jobtitle
146 .indexOf("profile") == -1))
148 int pos = jobtitle.indexOf("alignment");
149 jobtitle = WebServiceName.substring(0, pos) + "re-alignment of "
154 jobtitle = WebServiceName + " of " + altitle;
159 jobtitle = WebServiceName + (submitGaps ? " re" : " ")
160 + "alignment of " + altitle;
163 MsaWSThread msathread = new MsaWSThread(server, preset, paramset,
164 WsURL, wsInfo, alignFrame, WebServiceName, jobtitle, msa,
165 submitGaps, preserveOrder, seqdataset);
166 wsInfo.setthisService(msathread);
170 protected String getServiceActionKey()
175 protected String getServiceActionDescription()
177 return "Multiple Sequence Alignment";
181 * look at ourselves and work out if we are a service that can take a profile
184 * @return true if we can send gapped sequences to the alignment service
186 private boolean canSubmitGaps()
188 // TODO: query service or extract service handle props to check if we can
190 return (WebServiceName.indexOf("lustal") > -1); // cheat!
193 public void attachWSMenuEntry(JMenu rmsawsmenu,
194 final Jws2Instance service, final AlignFrame alignFrame)
196 setWebService(service, true); // headless
197 boolean finished = true, submitGaps = false;
198 JMenu msawsmenu = rmsawsmenu;
199 String svcname = WebServiceName;
200 if (svcname.endsWith("WS"))
202 svcname = svcname.substring(0, svcname.length() - 2);
204 String calcName = svcname + " ";
207 msawsmenu = new JMenu(svcname);
208 rmsawsmenu.add(msawsmenu);
211 boolean hasparams = service.hasParameters();
214 String action = "Align ";
215 if (submitGaps == true)
218 msawsmenu = new JMenu(MessageManager.formatMessage(
219 "label.realign_with_params", new String[]
221 msawsmenu.setToolTipText(MessageManager
222 .getString("label.align_sequences_to_existing_alignment"));
223 rmsawsmenu.add(msawsmenu);
225 final boolean withGaps = submitGaps;
227 JMenuItem method = new JMenuItem(MessageManager.formatMessage(
228 "label.calcname_with_default_settings", new String[]
230 method.setToolTipText(MessageManager.formatMessage(
231 "label.action_with_default_settings", new String[]
234 method.addActionListener(new ActionListener()
236 public void actionPerformed(ActionEvent e)
238 AlignmentView msa = alignFrame.gatherSequencesForAlignment();
239 new MsaWSClient(service, alignFrame.getTitle(), msa, withGaps,
240 true, alignFrame.getViewport().getAlignment()
241 .getDataset(), alignFrame);
245 msawsmenu.add(method);
248 // only add these menu options if the service has user-modifiable
250 method = new JMenuItem(
251 MessageManager.getString("label.edit_settings_and_run"));
252 method.setToolTipText(MessageManager
253 .getString("label.view_and_change_parameters_before_alignment"));
255 method.addActionListener(new ActionListener()
257 public void actionPerformed(ActionEvent e)
259 AlignmentView msa = alignFrame.gatherSequencesForAlignment();
260 new MsaWSClient(service, null, null, true, alignFrame
261 .getTitle(), msa, withGaps, true, alignFrame
262 .getViewport().getAlignment().getDataset(), alignFrame);
266 msawsmenu.add(method);
267 List<WsParamSetI> presets = service.getParamStore().getPresets();
268 if (presets != null && presets.size() > 0)
270 JMenu presetlist = new JMenu(MessageManager.formatMessage(
271 "label.run_with_preset_params", new String[]
274 for (final WsParamSetI preset : presets)
276 final JMenuItem methodR = new JMenuItem(preset.getName());
277 methodR.setToolTipText("<html><p>"
278 + JvSwingUtils.wrapTooltip("<strong>"
279 + (preset.isModifiable() ? "User Preset"
280 : "Service Preset") + "</strong><br/>"
281 + preset.getDescription() + "</p>") + "</html>");
282 methodR.addActionListener(new ActionListener()
284 public void actionPerformed(ActionEvent e)
286 AlignmentView msa = alignFrame
287 .gatherSequencesForAlignment();
288 new MsaWSClient(service, preset, alignFrame.getTitle(),
289 msa, false, true, alignFrame.getViewport()
290 .getAlignment().getDataset(), alignFrame);
295 presetlist.add(methodR);
297 msawsmenu.add(presetlist);
300 if (!submitGaps && canSubmitGaps())