2 * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
3 * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
21 import java.awt.event.ActionEvent;
22 import java.awt.event.ActionListener;
27 import jalview.datamodel.*;
36 public class MsaWSClient extends WSClient
39 * server is a WSDL2Java generated stub for an archetypal MsaWSI service.
41 ext.vamsas.MuscleWS server;
43 AlignFrame alignFrame;
46 * Creates a new MsaWSClient object that uses a service given by an externally
47 * retrieved ServiceHandle
50 * service handle of type AbstractName(MsaWS)
57 * @param preserveOrder
61 public MsaWSClient(ext.vamsas.ServiceHandle sh, String altitle,
62 jalview.datamodel.AlignmentView msa, boolean submitGaps,
63 boolean preserveOrder, Alignment seqdataset,
64 AlignFrame _alignFrame)
67 alignFrame = _alignFrame;
68 if (!sh.getAbstractName().equals("MsaWS"))
73 "The Service called \n"
75 + "\nis not a \nMultiple Sequence Alignment Service !",
76 "Internal Jalview Error", JOptionPane.WARNING_MESSAGE);
81 if ((wsInfo = setWebService(sh)) == null)
83 JOptionPane.showMessageDialog(Desktop.desktop,
84 "The Multiple Sequence Alignment Service named "
85 + sh.getName() + " is unknown",
86 "Internal Jalview Error", JOptionPane.WARNING_MESSAGE);
90 startMsaWSClient(altitle, msa, submitGaps, preserveOrder, seqdataset);
97 // add a class reference to the list
100 private void startMsaWSClient(String altitle, AlignmentView msa,
101 boolean submitGaps, boolean preserveOrder, Alignment seqdataset)
103 if (!locateWebService())
108 wsInfo.setProgressText(((submitGaps) ? "Re-alignment" : "Alignment")
109 + " of " + altitle + "\nJob details\n");
110 String jobtitle = WebServiceName.toLowerCase();
111 if (jobtitle.endsWith("alignment"))
114 && (!jobtitle.endsWith("realignment") || jobtitle
115 .indexOf("profile") == -1))
117 int pos = jobtitle.indexOf("alignment");
118 jobtitle = WebServiceName.substring(0, pos) + "re-alignment of "
123 jobtitle = WebServiceName + " of " + altitle;
128 jobtitle = WebServiceName + (submitGaps ? " re" : " ")
129 + "alignment of " + altitle;
132 MsaWSThread msathread = new MsaWSThread(server, WsURL, wsInfo,
133 alignFrame, WebServiceName, jobtitle, msa, submitGaps,
134 preserveOrder, seqdataset);
135 wsInfo.setthisService(msathread);
140 * Initializes the server field with a valid service implementation.
142 * @return true if service was located.
144 private boolean locateWebService()
146 // TODO: MuscleWS transmuted to generic MsaWS client
147 MuscleWSServiceLocator loc = new MuscleWSServiceLocator(); // Default
151 this.server = (MuscleWS) loc.getMuscleWS(new java.net.URL(WsURL));
152 ((MuscleWSSoapBindingStub) this.server).setTimeout(60000); // One minute
154 } catch (Exception ex)
156 wsInfo.setProgressText("Serious! " + WebServiceName
157 + " Service location failed\nfor URL :" + WsURL + "\n"
159 wsInfo.setStatus(WebserviceInfo.ERROR);
160 ex.printStackTrace();
165 loc.getEngine().setOption("axis", "1");
170 protected String getServiceActionKey()
175 protected String getServiceActionDescription()
177 return "Multiple Sequence Alignment";
181 * look at ourselves and work out if we are a service that can take a profile
184 * @return true if we can send gapped sequences to the alignment service
186 private boolean canSubmitGaps()
188 // TODO: query service or extract service handle props to check if we can
190 return (WebServiceName.indexOf("lustal") > -1); // cheat!
193 public void attachWSMenuEntry(JMenu msawsmenu,
194 final ServiceHandle serviceHandle, final AlignFrame alignFrame)
196 setWebService(serviceHandle, true); // headless
197 JMenuItem method = new JMenuItem(WebServiceName);
198 method.setToolTipText(WsURL);
199 method.addActionListener(new ActionListener()
201 public void actionPerformed(ActionEvent e)
203 AlignmentView msa = alignFrame.gatherSequencesForAlignment();
204 new jalview.ws.MsaWSClient(serviceHandle, alignFrame.getTitle(),
205 msa, false, true, alignFrame.getViewport().getAlignment()
206 .getDataset(), alignFrame);
211 msawsmenu.add(method);
214 // We know that ClustalWS can accept partial alignments for refinement.
215 final JMenuItem methodR = new JMenuItem(serviceHandle.getName()
217 methodR.setToolTipText(WsURL);
218 methodR.addActionListener(new ActionListener()
220 public void actionPerformed(ActionEvent e)
222 AlignmentView msa = alignFrame.gatherSequencesForAlignment();
223 new jalview.ws.MsaWSClient(serviceHandle, alignFrame.getTitle(),
224 msa, true, true, alignFrame.getViewport().getAlignment()
225 .getDataset(), alignFrame);
230 msawsmenu.add(methodR);