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.ArrayList;
23 import java.util.List;
27 import jalview.datamodel.*;
29 import compbio.data.msa.MsaWS;
30 import compbio.metadata.Argument;
31 import compbio.metadata.Option;
32 import compbio.metadata.Preset;
33 import compbio.metadata.PresetManager;
34 import jalview.ws.jws2.dm.JabaWsParamSet;
35 import jalview.ws.jws2.jabaws2.Jws2Instance;
36 import jalview.ws.params.WsParamSetI;
44 public class MsaWSClient extends Jws2Client
47 * server is a WSDL2Java generated stub for an archetypal MsaWSI service.
51 public MsaWSClient(Jws2Instance sh, String altitle,
52 jalview.datamodel.AlignmentView msa, boolean submitGaps,
53 boolean preserveOrder, Alignment seqdataset,
54 AlignFrame _alignFrame)
56 this(sh, null, null, false, altitle, msa, submitGaps, preserveOrder,
57 seqdataset, _alignFrame);
58 // TODO Auto-generated constructor stub
61 public MsaWSClient(Jws2Instance sh, WsParamSetI preset, String altitle,
62 jalview.datamodel.AlignmentView msa, boolean submitGaps,
63 boolean preserveOrder, Alignment seqdataset,
64 AlignFrame _alignFrame)
66 this(sh, preset, null, false, altitle, msa, submitGaps, preserveOrder,
67 seqdataset, _alignFrame);
68 // TODO Auto-generated constructor stub
72 * Creates a new MsaWSClient object that uses a service given by an externally
73 * retrieved ServiceHandle
76 * service handle of type AbstractName(MsaWS)
83 * @param preserveOrder
87 public MsaWSClient(Jws2Instance sh, WsParamSetI preset,
88 List<Argument> arguments, boolean editParams, String altitle,
89 jalview.datamodel.AlignmentView msa, boolean submitGaps,
90 boolean preserveOrder, Alignment seqdataset,
91 AlignFrame _alignFrame)
93 super(_alignFrame, preset, arguments);
94 if (!processParams(sh, editParams))
99 if (!(sh.service instanceof MsaWS))
101 // redundant at mo - but may change
105 "The Service called \n"
107 + "\nis not a \nMultiple Sequence Alignment Service !",
108 "Internal Jalview Error", JOptionPane.WARNING_MESSAGE);
112 server = (MsaWS) sh.service;
113 if ((wsInfo = setWebService(sh, false)) == null)
115 JOptionPane.showMessageDialog(Desktop.desktop,
116 "The Multiple Sequence Alignment Service named "
117 + sh.serviceType + " is unknown",
118 "Internal Jalview Error", JOptionPane.WARNING_MESSAGE);
122 startMsaWSClient(altitle, msa, submitGaps, preserveOrder, seqdataset);
129 // add a class reference to the list
132 private void startMsaWSClient(String altitle, AlignmentView msa,
133 boolean submitGaps, boolean preserveOrder, Alignment seqdataset)
135 // if (!locateWebService())
140 wsInfo.setProgressText(((submitGaps) ? "Re-alignment" : "Alignment")
141 + " of " + altitle + "\nJob details\n");
142 String jobtitle = WebServiceName.toLowerCase();
143 if (jobtitle.endsWith("alignment"))
146 && (!jobtitle.endsWith("realignment") || jobtitle
147 .indexOf("profile") == -1))
149 int pos = jobtitle.indexOf("alignment");
150 jobtitle = WebServiceName.substring(0, pos) + "re-alignment of "
155 jobtitle = WebServiceName + " of " + altitle;
160 jobtitle = WebServiceName + (submitGaps ? " re" : " ")
161 + "alignment of " + altitle;
164 MsaWSThread msathread = new MsaWSThread(server, preset, paramset,
165 WsURL, wsInfo, alignFrame, WebServiceName, jobtitle, msa,
166 submitGaps, preserveOrder, seqdataset);
167 wsInfo.setthisService(msathread);
171 protected String getServiceActionKey()
176 protected String getServiceActionDescription()
178 return "Multiple Sequence Alignment";
182 * look at ourselves and work out if we are a service that can take a profile
185 * @return true if we can send gapped sequences to the alignment service
187 private boolean canSubmitGaps()
189 // TODO: query service or extract service handle props to check if we can
191 return (WebServiceName.indexOf("lustal") > -1); // cheat!
194 public void attachWSMenuEntry(JMenu rmsawsmenu,
195 final Jws2Instance service, final AlignFrame alignFrame)
197 setWebService(service, true); // headless
198 boolean finished = true, submitGaps = false;
199 JMenu msawsmenu = rmsawsmenu;
200 String svcname = WebServiceName;
201 if (svcname.endsWith("WS"))
203 svcname = svcname.substring(0, svcname.length() - 2);
205 String calcName = svcname + " ";
208 msawsmenu = new JMenu(svcname);
209 rmsawsmenu.add(msawsmenu);
212 boolean hasparams = service.hasParameters();
215 String action = "Align ";
216 if (submitGaps == true)
219 msawsmenu = new JMenu("Realign with " + svcname);
221 .setToolTipText("Align sequences to an existing alignment");
222 rmsawsmenu.add(msawsmenu);
224 final boolean withGaps = submitGaps;
226 JMenuItem method = new JMenuItem(calcName + "with Defaults");
227 method.setToolTipText(action + "with default settings");
229 method.addActionListener(new ActionListener()
231 public void actionPerformed(ActionEvent e)
233 AlignmentView msa = alignFrame.gatherSequencesForAlignment();
234 new MsaWSClient(service, alignFrame.getTitle(), msa, withGaps,
235 true, alignFrame.getViewport().getAlignment()
236 .getDataset(), alignFrame);
240 msawsmenu.add(method);
243 // only add these menu options if the service has user-modifiable
245 method = new JMenuItem("Edit settings and run ...");
246 method.setToolTipText("View and change the parameters before alignment.");
248 method.addActionListener(new ActionListener()
250 public void actionPerformed(ActionEvent e)
252 AlignmentView msa = alignFrame.gatherSequencesForAlignment();
253 new MsaWSClient(service, null, null, true, alignFrame
254 .getTitle(), msa, withGaps, true, alignFrame
255 .getViewport().getAlignment().getDataset(), alignFrame);
259 msawsmenu.add(method);
260 List<WsParamSetI> presets = service.getParamStore().getPresets();
261 if (presets != null && presets.size() > 0)
263 JMenu presetlist = new JMenu("Run " + calcName + "with preset");
265 for (final WsParamSetI preset : presets)
267 final JMenuItem methodR = new JMenuItem(preset.getName());
268 methodR.setToolTipText("<html><p>"
269 + JvSwingUtils.wrapTooltip("<strong>"
270 + (preset.isModifiable() ? "User Preset"
271 : "Service Preset") + "</strong><br/>"
272 + preset.getDescription() + "</p>") + "</html>");
273 methodR.addActionListener(new ActionListener()
275 public void actionPerformed(ActionEvent e)
277 AlignmentView msa = alignFrame
278 .gatherSequencesForAlignment();
279 new MsaWSClient(service, preset, alignFrame.getTitle(),
280 msa, false, true, alignFrame.getViewport()
281 .getAlignment().getDataset(), alignFrame);
286 presetlist.add(methodR);
288 msawsmenu.add(presetlist);
291 if (!submitGaps && canSubmitGaps())