2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ 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.jws1;
23 import java.util.Locale;
25 import jalview.datamodel.AlignmentI;
26 import jalview.datamodel.AlignmentView;
27 import jalview.gui.AlignFrame;
28 import jalview.gui.Desktop;
29 import jalview.gui.JvOptionPane;
30 import jalview.gui.WebserviceInfo;
31 import jalview.util.MessageManager;
33 import java.awt.event.ActionEvent;
34 import java.awt.event.ActionListener;
36 import javax.swing.JMenu;
37 import javax.swing.JMenuItem;
39 import ext.vamsas.MuscleWSServiceLocator;
40 import ext.vamsas.MuscleWSSoapBindingStub;
41 import ext.vamsas.ServiceHandle;
49 public class MsaWSClient extends WS1Client
52 * server is a WSDL2Java generated stub for an archetypal MsaWSI service.
54 ext.vamsas.MuscleWS server;
57 * Creates a new MsaWSClient object that uses a service given by an externally
58 * retrieved ServiceHandle
61 * service handle of type AbstractName(MsaWS)
68 * @param preserveOrder
72 public MsaWSClient(ext.vamsas.ServiceHandle sh, String altitle,
73 jalview.datamodel.AlignmentView msa, boolean submitGaps,
74 boolean preserveOrder, AlignmentI seqdataset,
75 AlignFrame _alignFrame)
78 alignFrame = _alignFrame;
79 if (!sh.getAbstractName().equals("MsaWS"))
81 JvOptionPane.showMessageDialog(Desktop.getDesktopPane(),
82 MessageManager.formatMessage(
83 "label.service_called_is_not_msa_service",
86 MessageManager.getString("label.internal_jalview_error"),
87 JvOptionPane.WARNING_MESSAGE);
92 if ((wsInfo = setWebService(sh)) == null)
94 JvOptionPane.showMessageDialog(Desktop.getDesktopPane(), MessageManager
95 .formatMessage("label.msa_service_is_unknown", new String[]
97 MessageManager.getString("label.internal_jalview_error"),
98 JvOptionPane.WARNING_MESSAGE);
102 startMsaWSClient(altitle, msa, submitGaps, preserveOrder, seqdataset);
109 // add a class reference to the list
112 private void startMsaWSClient(String altitle, AlignmentView msa,
113 boolean submitGaps, boolean preserveOrder, AlignmentI seqdataset)
115 if (!locateWebService())
120 wsInfo.setProgressText(((submitGaps) ? "Re-alignment" : "Alignment")
121 + " of " + altitle + "\nJob details\n");
122 String jobtitle = WebServiceName.toLowerCase(Locale.ROOT);
123 if (jobtitle.endsWith("alignment"))
125 if (submitGaps && (!jobtitle.endsWith("realignment")
126 || jobtitle.indexOf("profile") == -1))
128 int pos = jobtitle.indexOf("alignment");
129 jobtitle = WebServiceName.substring(0, pos) + "re-alignment of "
134 jobtitle = WebServiceName + " of " + altitle;
139 jobtitle = WebServiceName + (submitGaps ? " re" : " ")
140 + "alignment of " + altitle;
143 MsaWSThread msathread = new MsaWSThread(server, WsURL, wsInfo,
144 alignFrame, WebServiceName, jobtitle, msa, submitGaps,
145 preserveOrder, seqdataset);
146 wsInfo.setthisService(msathread);
151 * Initializes the server field with a valid service implementation.
153 * @return true if service was located.
155 private boolean locateWebService()
157 // TODO: MuscleWS transmuted to generic MsaWS client
158 MuscleWSServiceLocator loc = new MuscleWSServiceLocator(); // Default
162 this.server = loc.getMuscleWS(new java.net.URL(WsURL));
163 ((MuscleWSSoapBindingStub) this.server).setTimeout(60000); // One minute
165 } catch (Exception ex)
167 wsInfo.setProgressText("Serious! " + WebServiceName
168 + " Service location failed\nfor URL :" + WsURL + "\n"
170 wsInfo.setStatus(WebserviceInfo.ERROR);
171 ex.printStackTrace();
176 loc.getEngine().setOption("axis", "1");
181 protected String getServiceActionKey()
186 protected String getServiceActionDescription()
188 return "Multiple Sequence Alignment";
192 * look at ourselves and work out if we are a service that can take a profile
195 * @return true if we can send gapped sequences to the alignment service
197 private boolean canSubmitGaps()
199 // TODO: query service or extract service handle props to check if we can
201 return (WebServiceName.indexOf("lustal") > -1); // cheat!
205 public void attachWSMenuEntry(JMenu msawsmenu,
206 final ServiceHandle serviceHandle, final AlignFrame alignFrame)
208 setWebService(serviceHandle, true); // headless
209 JMenuItem method = new JMenuItem(WebServiceName);
210 method.setToolTipText(WsURL);
211 method.addActionListener(new ActionListener()
214 public void actionPerformed(ActionEvent e)
216 AlignmentView msa = alignFrame.gatherSequencesForAlignment();
217 new jalview.ws.jws1.MsaWSClient(serviceHandle,
218 alignFrame.getTitle(), msa, false, true,
219 alignFrame.getViewport().getAlignment().getDataset(),
225 msawsmenu.add(method);
228 // We know that ClustalWS can accept partial alignments for refinement.
229 final JMenuItem methodR = new JMenuItem(
230 serviceHandle.getName() + " Realign");
231 methodR.setToolTipText(WsURL);
232 methodR.addActionListener(new ActionListener()
235 public void actionPerformed(ActionEvent e)
237 AlignmentView msa = alignFrame.gatherSequencesForAlignment();
238 new jalview.ws.jws1.MsaWSClient(serviceHandle,
239 alignFrame.getTitle(), msa, true, true,
240 alignFrame.getViewport().getAlignment().getDataset(),
246 msawsmenu.add(methodR);