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 jalview.datamodel.AlignmentI;
24 import jalview.datamodel.AlignmentView;
25 import jalview.gui.AlignFrame;
26 import jalview.gui.Desktop;
27 import jalview.gui.JvOptionPane;
28 import jalview.gui.WebserviceInfo;
29 import jalview.util.MessageManager;
31 import java.awt.event.ActionEvent;
32 import java.awt.event.ActionListener;
34 import javax.swing.JMenu;
35 import javax.swing.JMenuItem;
37 import ext.vamsas.MuscleWSServiceLocator;
38 import ext.vamsas.MuscleWSSoapBindingStub;
39 import ext.vamsas.ServiceHandle;
47 public class MsaWSClient extends WS1Client
50 * server is a WSDL2Java generated stub for an archetypal MsaWSI service.
52 ext.vamsas.MuscleWS server;
55 * Creates a new MsaWSClient object that uses a service given by an externally
56 * retrieved ServiceHandle
59 * service handle of type AbstractName(MsaWS)
66 * @param preserveOrder
70 public MsaWSClient(ext.vamsas.ServiceHandle sh, String altitle,
71 jalview.datamodel.AlignmentView msa, boolean submitGaps,
72 boolean preserveOrder, AlignmentI seqdataset,
73 AlignFrame _alignFrame)
76 alignFrame = _alignFrame;
77 if (!sh.getAbstractName().equals("MsaWS"))
79 JvOptionPane.showMessageDialog(Desktop.getDesktopPane(),
80 MessageManager.formatMessage(
81 "label.service_called_is_not_msa_service",
84 MessageManager.getString("label.internal_jalview_error"),
85 JvOptionPane.WARNING_MESSAGE);
90 if ((wsInfo = setWebService(sh)) == null)
92 JvOptionPane.showMessageDialog(Desktop.getDesktopPane(), MessageManager
93 .formatMessage("label.msa_service_is_unknown", new String[]
95 MessageManager.getString("label.internal_jalview_error"),
96 JvOptionPane.WARNING_MESSAGE);
100 startMsaWSClient(altitle, msa, submitGaps, preserveOrder, seqdataset);
107 // add a class reference to the list
110 private void startMsaWSClient(String altitle, AlignmentView msa,
111 boolean submitGaps, boolean preserveOrder, AlignmentI seqdataset)
113 if (!locateWebService())
118 wsInfo.setProgressText(((submitGaps) ? "Re-alignment" : "Alignment")
119 + " of " + altitle + "\nJob details\n");
120 String jobtitle = WebServiceName.toLowerCase();
121 if (jobtitle.endsWith("alignment"))
123 if (submitGaps && (!jobtitle.endsWith("realignment")
124 || jobtitle.indexOf("profile") == -1))
126 int pos = jobtitle.indexOf("alignment");
127 jobtitle = WebServiceName.substring(0, pos) + "re-alignment of "
132 jobtitle = WebServiceName + " of " + altitle;
137 jobtitle = WebServiceName + (submitGaps ? " re" : " ")
138 + "alignment of " + altitle;
141 MsaWSThread msathread = new MsaWSThread(server, WsURL, wsInfo,
142 alignFrame, WebServiceName, jobtitle, msa, submitGaps,
143 preserveOrder, seqdataset);
144 wsInfo.setthisService(msathread);
149 * Initializes the server field with a valid service implementation.
151 * @return true if service was located.
153 private boolean locateWebService()
155 // TODO: MuscleWS transmuted to generic MsaWS client
156 MuscleWSServiceLocator loc = new MuscleWSServiceLocator(); // Default
160 this.server = loc.getMuscleWS(new java.net.URL(WsURL));
161 ((MuscleWSSoapBindingStub) this.server).setTimeout(60000); // One minute
163 } catch (Exception ex)
165 wsInfo.setProgressText("Serious! " + WebServiceName
166 + " Service location failed\nfor URL :" + WsURL + "\n"
168 wsInfo.setStatus(WebserviceInfo.ERROR);
169 ex.printStackTrace();
174 loc.getEngine().setOption("axis", "1");
179 protected String getServiceActionKey()
184 protected String getServiceActionDescription()
186 return "Multiple Sequence Alignment";
190 * look at ourselves and work out if we are a service that can take a profile
193 * @return true if we can send gapped sequences to the alignment service
195 private boolean canSubmitGaps()
197 // TODO: query service or extract service handle props to check if we can
199 return (WebServiceName.indexOf("lustal") > -1); // cheat!
203 public void attachWSMenuEntry(JMenu msawsmenu,
204 final ServiceHandle serviceHandle, final AlignFrame alignFrame)
206 setWebService(serviceHandle, true); // headless
207 JMenuItem method = new JMenuItem(WebServiceName);
208 method.setToolTipText(WsURL);
209 method.addActionListener(new ActionListener()
212 public void actionPerformed(ActionEvent e)
214 AlignmentView msa = alignFrame.gatherSequencesForAlignment();
215 new jalview.ws.jws1.MsaWSClient(serviceHandle,
216 alignFrame.getTitle(), msa, false, true,
217 alignFrame.getViewport().getAlignment().getDataset(),
223 msawsmenu.add(method);
226 // We know that ClustalWS can accept partial alignments for refinement.
227 final JMenuItem methodR = new JMenuItem(
228 serviceHandle.getName() + " Realign");
229 methodR.setToolTipText(WsURL);
230 methodR.addActionListener(new ActionListener()
233 public void actionPerformed(ActionEvent e)
235 AlignmentView msa = alignFrame.gatherSequencesForAlignment();
236 new jalview.ws.jws1.MsaWSClient(serviceHandle,
237 alignFrame.getTitle(), msa, true, true,
238 alignFrame.getViewport().getAlignment().getDataset(),
244 msawsmenu.add(methodR);