2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
3 * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
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/>.
18 package jalview.ws.jws2;
20 import java.awt.event.ActionEvent;
21 import java.awt.event.ActionListener;
22 import java.util.List;
26 import jalview.datamodel.*;
28 import compbio.data.msa.MsaWS;
29 import compbio.metadata.Argument;
30 import jalview.ws.jws2.jabaws2.Jws2Instance;
31 import jalview.ws.params.WsParamSetI;
39 public class MsaWSClient extends Jws2Client
42 * server is a WSDL2Java generated stub for an archetypal MsaWSI service.
46 public MsaWSClient(Jws2Instance sh, String altitle,
47 jalview.datamodel.AlignmentView msa, boolean submitGaps,
48 boolean preserveOrder, Alignment seqdataset,
49 AlignFrame _alignFrame)
51 this(sh, null, null, false, altitle, msa, submitGaps, preserveOrder,
52 seqdataset, _alignFrame);
53 // TODO Auto-generated constructor stub
56 public MsaWSClient(Jws2Instance sh, WsParamSetI preset, String altitle,
57 jalview.datamodel.AlignmentView msa, boolean submitGaps,
58 boolean preserveOrder, Alignment seqdataset,
59 AlignFrame _alignFrame)
61 this(sh, preset, null, false, altitle, msa, submitGaps, preserveOrder,
62 seqdataset, _alignFrame);
63 // TODO Auto-generated constructor stub
67 * Creates a new MsaWSClient object that uses a service given by an externally
68 * retrieved ServiceHandle
71 * service handle of type AbstractName(MsaWS)
78 * @param preserveOrder
82 public MsaWSClient(Jws2Instance sh, WsParamSetI preset,
83 List<Argument> arguments, boolean editParams, String altitle,
84 jalview.datamodel.AlignmentView msa, boolean submitGaps,
85 boolean preserveOrder, Alignment seqdataset,
86 AlignFrame _alignFrame)
88 super(_alignFrame, preset, arguments);
89 if (!processParams(sh, editParams))
94 if (!(sh.service instanceof MsaWS))
96 // redundant at mo - but may change
100 "The Service called \n"
102 + "\nis not a \nMultiple Sequence Alignment Service !",
103 "Internal Jalview Error", JOptionPane.WARNING_MESSAGE);
107 server = (MsaWS) sh.service;
108 if ((wsInfo = setWebService(sh, false)) == null)
110 JOptionPane.showMessageDialog(Desktop.desktop,
111 "The Multiple Sequence Alignment Service named "
112 + sh.serviceType + " is unknown",
113 "Internal Jalview Error", JOptionPane.WARNING_MESSAGE);
117 startMsaWSClient(altitle, msa, submitGaps, preserveOrder, seqdataset);
124 // add a class reference to the list
127 private void startMsaWSClient(String altitle, AlignmentView msa,
128 boolean submitGaps, boolean preserveOrder, Alignment seqdataset)
130 // if (!locateWebService())
135 wsInfo.setProgressText(((submitGaps) ? "Re-alignment" : "Alignment")
136 + " of " + altitle + "\nJob details\n");
137 String jobtitle = WebServiceName.toLowerCase();
138 if (jobtitle.endsWith("alignment"))
141 && (!jobtitle.endsWith("realignment") || jobtitle
142 .indexOf("profile") == -1))
144 int pos = jobtitle.indexOf("alignment");
145 jobtitle = WebServiceName.substring(0, pos) + "re-alignment of "
150 jobtitle = WebServiceName + " of " + altitle;
155 jobtitle = WebServiceName + (submitGaps ? " re" : " ")
156 + "alignment of " + altitle;
159 MsaWSThread msathread = new MsaWSThread(server, preset, paramset,
160 WsURL, wsInfo, alignFrame, WebServiceName, jobtitle, msa,
161 submitGaps, preserveOrder, seqdataset);
162 wsInfo.setthisService(msathread);
166 protected String getServiceActionKey()
171 protected String getServiceActionDescription()
173 return "Multiple Sequence Alignment";
177 * look at ourselves and work out if we are a service that can take a profile
180 * @return true if we can send gapped sequences to the alignment service
182 private boolean canSubmitGaps()
184 // TODO: query service or extract service handle props to check if we can
186 return (WebServiceName.indexOf("lustal") > -1); // cheat!
189 public void attachWSMenuEntry(JMenu rmsawsmenu,
190 final Jws2Instance service, final AlignFrame alignFrame)
192 setWebService(service, true); // headless
193 boolean finished = true, submitGaps = false;
194 JMenu msawsmenu = rmsawsmenu;
195 String svcname = WebServiceName;
196 if (svcname.endsWith("WS"))
198 svcname = svcname.substring(0, svcname.length() - 2);
200 String calcName = svcname + " ";
203 msawsmenu = new JMenu(svcname);
204 rmsawsmenu.add(msawsmenu);
207 boolean hasparams = service.hasParameters();
210 String action = "Align ";
211 if (submitGaps == true)
214 msawsmenu = new JMenu("Realign with " + svcname);
216 .setToolTipText("Align sequences to an existing alignment");
217 rmsawsmenu.add(msawsmenu);
219 final boolean withGaps = submitGaps;
221 JMenuItem method = new JMenuItem(calcName + "with Defaults");
222 method.setToolTipText(action + "with default settings");
224 method.addActionListener(new ActionListener()
226 public void actionPerformed(ActionEvent e)
228 AlignmentView msa = alignFrame.gatherSequencesForAlignment();
229 new MsaWSClient(service, alignFrame.getTitle(), msa, withGaps,
230 true, alignFrame.getViewport().getAlignment()
231 .getDataset(), alignFrame);
235 msawsmenu.add(method);
238 // only add these menu options if the service has user-modifiable
240 method = new JMenuItem("Edit settings and run ...");
241 method.setToolTipText("View and change the parameters before alignment.");
243 method.addActionListener(new ActionListener()
245 public void actionPerformed(ActionEvent e)
247 AlignmentView msa = alignFrame.gatherSequencesForAlignment();
248 new MsaWSClient(service, null, null, true, alignFrame
249 .getTitle(), msa, withGaps, true, alignFrame
250 .getViewport().getAlignment().getDataset(), alignFrame);
254 msawsmenu.add(method);
255 List<WsParamSetI> presets = service.getParamStore().getPresets();
256 if (presets != null && presets.size() > 0)
258 JMenu presetlist = new JMenu("Run " + calcName + "with preset");
260 for (final WsParamSetI preset : presets)
262 final JMenuItem methodR = new JMenuItem(preset.getName());
263 methodR.setToolTipText("<html><p>"
264 + JvSwingUtils.wrapTooltip("<strong>"
265 + (preset.isModifiable() ? "User Preset"
266 : "Service Preset") + "</strong><br/>"
267 + preset.getDescription() + "</p>") + "</html>");
268 methodR.addActionListener(new ActionListener()
270 public void actionPerformed(ActionEvent e)
272 AlignmentView msa = alignFrame
273 .gatherSequencesForAlignment();
274 new MsaWSClient(service, preset, alignFrame.getTitle(),
275 msa, false, true, alignFrame.getViewport()
276 .getAlignment().getDataset(), alignFrame);
281 presetlist.add(methodR);
283 msawsmenu.add(presetlist);
286 if (!submitGaps && canSubmitGaps())