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;
56 AlignFrame alignFrame;
59 * Creates a new MsaWSClient object that uses a service given by an externally
60 * retrieved ServiceHandle
63 * service handle of type AbstractName(MsaWS)
70 * @param preserveOrder
74 public MsaWSClient(ext.vamsas.ServiceHandle sh, String altitle,
75 jalview.datamodel.AlignmentView msa, boolean submitGaps,
76 boolean preserveOrder, AlignmentI seqdataset,
77 AlignFrame _alignFrame)
80 alignFrame = _alignFrame;
81 if (!sh.getAbstractName().equals("MsaWS"))
83 JvOptionPane.showMessageDialog(Desktop.desktop,
84 MessageManager.formatMessage(
85 "label.service_called_is_not_msa_service",
88 MessageManager.getString("label.internal_jalview_error"),
89 JvOptionPane.WARNING_MESSAGE);
94 if ((wsInfo = setWebService(sh)) == null)
96 JvOptionPane.showMessageDialog(Desktop.desktop, MessageManager
97 .formatMessage("label.msa_service_is_unknown", new String[]
99 MessageManager.getString("label.internal_jalview_error"),
100 JvOptionPane.WARNING_MESSAGE);
104 startMsaWSClient(altitle, msa, submitGaps, preserveOrder, seqdataset);
111 // add a class reference to the list
114 private void startMsaWSClient(String altitle, AlignmentView msa,
115 boolean submitGaps, boolean preserveOrder, AlignmentI seqdataset)
117 if (!locateWebService())
122 wsInfo.setProgressText(((submitGaps) ? "Re-alignment" : "Alignment")
123 + " of " + altitle + "\nJob details\n");
124 String jobtitle = WebServiceName.toLowerCase(Locale.ROOT);
125 if (jobtitle.endsWith("alignment"))
127 if (submitGaps && (!jobtitle.endsWith("realignment")
128 || jobtitle.indexOf("profile") == -1))
130 int pos = jobtitle.indexOf("alignment");
131 jobtitle = WebServiceName.substring(0, pos) + "re-alignment of "
136 jobtitle = WebServiceName + " of " + altitle;
141 jobtitle = WebServiceName + (submitGaps ? " re" : " ")
142 + "alignment of " + altitle;
145 MsaWSThread msathread = new MsaWSThread(server, WsURL, wsInfo,
146 alignFrame, WebServiceName, jobtitle, msa, submitGaps,
147 preserveOrder, seqdataset);
148 wsInfo.setthisService(msathread);
153 * Initializes the server field with a valid service implementation.
155 * @return true if service was located.
157 private boolean locateWebService()
159 // TODO: MuscleWS transmuted to generic MsaWS client
160 MuscleWSServiceLocator loc = new MuscleWSServiceLocator(); // Default
164 this.server = loc.getMuscleWS(new java.net.URL(WsURL));
165 ((MuscleWSSoapBindingStub) this.server).setTimeout(60000); // One minute
167 } catch (Exception ex)
169 wsInfo.setProgressText("Serious! " + WebServiceName
170 + " Service location failed\nfor URL :" + WsURL + "\n"
172 wsInfo.setStatus(WebserviceInfo.ERROR);
173 ex.printStackTrace();
178 loc.getEngine().setOption("axis", "1");
183 protected String getServiceActionKey()
188 protected String getServiceActionDescription()
190 return "Multiple Sequence Alignment";
194 * look at ourselves and work out if we are a service that can take a profile
197 * @return true if we can send gapped sequences to the alignment service
199 private boolean canSubmitGaps()
201 // TODO: query service or extract service handle props to check if we can
203 return (WebServiceName.indexOf("lustal") > -1); // cheat!
207 public void attachWSMenuEntry(JMenu msawsmenu,
208 final ServiceHandle serviceHandle, final AlignFrame alignFrame)
210 setWebService(serviceHandle, true); // headless
211 JMenuItem method = new JMenuItem(WebServiceName);
212 method.setToolTipText(WsURL);
213 method.addActionListener(new ActionListener()
216 public void actionPerformed(ActionEvent e)
218 AlignmentView msa = alignFrame.gatherSequencesForAlignment();
219 new jalview.ws.jws1.MsaWSClient(serviceHandle,
220 alignFrame.getTitle(), msa, false, true,
221 alignFrame.getViewport().getAlignment().getDataset(),
227 msawsmenu.add(method);
230 // We know that ClustalWS can accept partial alignments for refinement.
231 final JMenuItem methodR = new JMenuItem(
232 serviceHandle.getName() + " Realign");
233 methodR.setToolTipText(WsURL);
234 methodR.addActionListener(new ActionListener()
237 public void actionPerformed(ActionEvent e)
239 AlignmentView msa = alignFrame.gatherSequencesForAlignment();
240 new jalview.ws.jws1.MsaWSClient(serviceHandle,
241 alignFrame.getTitle(), msa, true, true,
242 alignFrame.getViewport().getAlignment().getDataset(),
248 msawsmenu.add(methodR);