2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
3 * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, 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,
62 String altitle, jalview.datamodel.AlignmentView msa,
63 boolean submitGaps, 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!
195 public void attachWSMenuEntry(JMenu rmsawsmenu,
196 final Jws2Instance service, final AlignFrame alignFrame)
198 setWebService(service, true); // headless
199 boolean finished = true, submitGaps = false;
200 JMenu msawsmenu = rmsawsmenu;
201 String svcname = WebServiceName;
202 if (svcname.endsWith("WS"))
204 svcname = svcname.substring(0, svcname.length() - 2);
206 String calcName = svcname + " ";
209 msawsmenu = new JMenu(svcname);
210 rmsawsmenu.add(msawsmenu);
213 boolean hasparams = service.hasParameters();
216 String action = "Align ";
217 if (submitGaps == true)
220 msawsmenu = new JMenu("Realign with " + svcname);
222 .setToolTipText("Align sequences to an existing alignment");
223 rmsawsmenu.add(msawsmenu);
225 final boolean withGaps = submitGaps;
227 JMenuItem method = new JMenuItem(calcName + "with Defaults");
228 method.setToolTipText(action + "with default settings");
230 method.addActionListener(new ActionListener()
232 public void actionPerformed(ActionEvent e)
234 AlignmentView msa = alignFrame.gatherSequencesForAlignment();
235 new MsaWSClient(service, alignFrame.getTitle(), msa, withGaps,
236 true, alignFrame.getViewport().getAlignment()
237 .getDataset(), alignFrame);
241 msawsmenu.add(method);
244 // only add these menu options if the service has user-modifiable
246 method = new JMenuItem("Edit settings and run ...");
247 method.setToolTipText("View and change the parameters before alignment.");
249 method.addActionListener(new ActionListener()
251 public void actionPerformed(ActionEvent e)
253 AlignmentView msa = alignFrame.gatherSequencesForAlignment();
254 new MsaWSClient(service, null, null, true, alignFrame
255 .getTitle(), msa, withGaps, true, alignFrame
256 .getViewport().getAlignment().getDataset(), alignFrame);
260 msawsmenu.add(method);
261 List<WsParamSetI> presets = service.getParamStore().getPresets();
262 if (presets != null && presets.size() > 0)
264 JMenu presetlist = new JMenu("Run "+calcName + "with preset");
266 for (final WsParamSetI preset : presets)
268 final JMenuItem methodR = new JMenuItem(preset.getName());
269 methodR.setToolTipText("<html><p>"
270 + JvSwingUtils.wrapTooltip("<strong>"
271 + (preset.isModifiable() ? "User Preset"
272 : "Service Preset") + "</strong><br/>"
273 + preset.getDescription() + "</p>") + "</html>");
274 methodR.addActionListener(new ActionListener()
276 public void actionPerformed(ActionEvent e)
278 AlignmentView msa = alignFrame
279 .gatherSequencesForAlignment();
280 new MsaWSClient(service, preset, alignFrame.getTitle(),
281 msa, false, true, alignFrame.getViewport()
282 .getAlignment().getDataset(), alignFrame);
287 presetlist.add(methodR);
289 msawsmenu.add(presetlist);
292 if (!submitGaps && canSubmitGaps())