2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
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 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
17 * The Jalview Authors are detailed in the 'AUTHORS' file.
19 package jalview.ws.jws2;
21 import java.awt.event.ActionEvent;
22 import java.awt.event.ActionListener;
23 import java.util.List;
27 import jalview.datamodel.*;
29 import compbio.data.msa.MsaWS;
30 import compbio.metadata.Argument;
31 import jalview.util.MessageManager;
32 import jalview.ws.jws2.jabaws2.Jws2Instance;
33 import jalview.ws.params.WsParamSetI;
41 public class MsaWSClient extends Jws2Client
44 * server is a WSDL2Java generated stub for an archetypal MsaWSI service.
48 public MsaWSClient(Jws2Instance sh, String altitle,
49 jalview.datamodel.AlignmentView msa, boolean submitGaps,
50 boolean preserveOrder, Alignment seqdataset,
51 AlignFrame _alignFrame)
53 this(sh, null, null, false, altitle, msa, submitGaps, preserveOrder,
54 seqdataset, _alignFrame);
55 // TODO Auto-generated constructor stub
58 public MsaWSClient(Jws2Instance sh, WsParamSetI preset, String altitle,
59 jalview.datamodel.AlignmentView msa, boolean submitGaps,
60 boolean preserveOrder, Alignment seqdataset,
61 AlignFrame _alignFrame)
63 this(sh, preset, null, false, altitle, msa, submitGaps, preserveOrder,
64 seqdataset, _alignFrame);
65 // TODO Auto-generated constructor stub
69 * Creates a new MsaWSClient object that uses a service given by an externally
70 * retrieved ServiceHandle
73 * service handle of type AbstractName(MsaWS)
80 * @param preserveOrder
84 public MsaWSClient(Jws2Instance sh, WsParamSetI preset,
85 List<Argument> arguments, boolean editParams, String altitle,
86 jalview.datamodel.AlignmentView msa, boolean submitGaps,
87 boolean preserveOrder, Alignment seqdataset,
88 AlignFrame _alignFrame)
90 super(_alignFrame, preset, arguments);
91 if (!processParams(sh, editParams))
96 if (!(sh.service instanceof MsaWS))
98 // redundant at mo - but may change
102 "The Service called \n"
104 + "\nis not a \nMultiple Sequence Alignment Service !",
105 "Internal Jalview Error", JOptionPane.WARNING_MESSAGE);
109 server = (MsaWS) sh.service;
110 if ((wsInfo = setWebService(sh, false)) == null)
112 JOptionPane.showMessageDialog(Desktop.desktop,
113 "The Multiple Sequence Alignment Service named "
114 + sh.serviceType + " is unknown",
115 "Internal Jalview Error", JOptionPane.WARNING_MESSAGE);
119 startMsaWSClient(altitle, msa, submitGaps, preserveOrder, seqdataset);
126 // add a class reference to the list
129 private void startMsaWSClient(String altitle, AlignmentView msa,
130 boolean submitGaps, boolean preserveOrder, Alignment seqdataset)
132 // if (!locateWebService())
137 wsInfo.setProgressText(((submitGaps) ? "Re-alignment" : "Alignment")
138 + " of " + altitle + "\nJob details\n");
139 String jobtitle = WebServiceName.toLowerCase();
140 if (jobtitle.endsWith("alignment"))
143 && (!jobtitle.endsWith("realignment") || jobtitle
144 .indexOf("profile") == -1))
146 int pos = jobtitle.indexOf("alignment");
147 jobtitle = WebServiceName.substring(0, pos) + "re-alignment of "
152 jobtitle = WebServiceName + " of " + altitle;
157 jobtitle = WebServiceName + (submitGaps ? " re" : " ")
158 + "alignment of " + altitle;
161 MsaWSThread msathread = new MsaWSThread(server, preset, paramset,
162 WsURL, wsInfo, alignFrame, WebServiceName, jobtitle, msa,
163 submitGaps, preserveOrder, seqdataset);
164 wsInfo.setthisService(msathread);
168 protected String getServiceActionKey()
173 protected String getServiceActionDescription()
175 return "Multiple Sequence Alignment";
179 * look at ourselves and work out if we are a service that can take a profile
182 * @return true if we can send gapped sequences to the alignment service
184 private boolean canSubmitGaps()
186 // TODO: query service or extract service handle props to check if we can
188 return (WebServiceName.indexOf("lustal") > -1); // cheat!
191 public void attachWSMenuEntry(JMenu rmsawsmenu,
192 final Jws2Instance service, final AlignFrame alignFrame)
194 setWebService(service, true); // headless
195 boolean finished = true, submitGaps = false;
196 JMenu msawsmenu = rmsawsmenu;
197 String svcname = WebServiceName;
198 if (svcname.endsWith("WS"))
200 svcname = svcname.substring(0, svcname.length() - 2);
202 String calcName = svcname + " ";
205 msawsmenu = new JMenu(svcname);
206 rmsawsmenu.add(msawsmenu);
209 boolean hasparams = service.hasParameters();
212 String action = "Align ";
213 if (submitGaps == true)
216 msawsmenu = new JMenu(MessageManager.formatMessage("label.realign_with_params", new String[]{svcname}));
218 .setToolTipText(MessageManager.getString("label.align_sequences_to_existing_alignment"));
219 rmsawsmenu.add(msawsmenu);
221 final boolean withGaps = submitGaps;
223 JMenuItem method = new JMenuItem(MessageManager.formatMessage("label.calcname_with_default_settings", new String[]{calcName}));
224 method.setToolTipText(MessageManager.formatMessage("label.action_with_default_settings", new String[]{action}));
226 method.addActionListener(new ActionListener()
228 public void actionPerformed(ActionEvent e)
230 AlignmentView msa = alignFrame.gatherSequencesForAlignment();
231 new MsaWSClient(service, alignFrame.getTitle(), msa, withGaps,
232 true, alignFrame.getViewport().getAlignment()
233 .getDataset(), alignFrame);
237 msawsmenu.add(method);
240 // only add these menu options if the service has user-modifiable
242 method = new JMenuItem(MessageManager.getString("label.edit_settings_and_run"));
243 method.setToolTipText(MessageManager.getString("label.view_and_change_parameters_before_alignment"));
245 method.addActionListener(new ActionListener()
247 public void actionPerformed(ActionEvent e)
249 AlignmentView msa = alignFrame.gatherSequencesForAlignment();
250 new MsaWSClient(service, null, null, true, alignFrame
251 .getTitle(), msa, withGaps, true, alignFrame
252 .getViewport().getAlignment().getDataset(), alignFrame);
256 msawsmenu.add(method);
257 List<WsParamSetI> presets = service.getParamStore().getPresets();
258 if (presets != null && presets.size() > 0)
260 JMenu presetlist = new JMenu(MessageManager.formatMessage("label.run_with_preset_params", new String[]{calcName}));
262 for (final WsParamSetI preset : presets)
264 final JMenuItem methodR = new JMenuItem(preset.getName());
265 methodR.setToolTipText("<html><p>"
266 + JvSwingUtils.wrapTooltip("<strong>"
267 + (preset.isModifiable() ? "User Preset"
268 : "Service Preset") + "</strong><br/>"
269 + preset.getDescription() + "</p>") + "</html>");
270 methodR.addActionListener(new ActionListener()
272 public void actionPerformed(ActionEvent e)
274 AlignmentView msa = alignFrame
275 .gatherSequencesForAlignment();
276 new MsaWSClient(service, preset, alignFrame.getTitle(),
277 msa, false, true, alignFrame.getViewport()
278 .getAlignment().getDataset(), alignFrame);
283 presetlist.add(methodR);
285 msawsmenu.add(presetlist);
288 if (!submitGaps && canSubmitGaps())