2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5)
3 * Copyright (C) 2010 J Procter, AM Waterhouse, 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/>.
20 import java.awt.event.ActionEvent;
21 import java.awt.event.ActionListener;
26 import jalview.datamodel.*;
35 public class MsaWSClient extends WS1Client
38 * server is a WSDL2Java generated stub for an archetypal MsaWSI service.
40 ext.vamsas.MuscleWS server;
42 AlignFrame alignFrame;
45 * Creates a new MsaWSClient object that uses a service given by an externally
46 * retrieved ServiceHandle
49 * service handle of type AbstractName(MsaWS)
56 * @param preserveOrder
60 public MsaWSClient(ext.vamsas.ServiceHandle sh, String altitle,
61 jalview.datamodel.AlignmentView msa, boolean submitGaps,
62 boolean preserveOrder, Alignment seqdataset,
63 AlignFrame _alignFrame)
66 alignFrame = _alignFrame;
67 if (!sh.getAbstractName().equals("MsaWS"))
72 "The Service called \n"
74 + "\nis not a \nMultiple Sequence Alignment Service !",
75 "Internal Jalview Error", JOptionPane.WARNING_MESSAGE);
80 if ((wsInfo = setWebService(sh)) == null)
82 JOptionPane.showMessageDialog(Desktop.desktop,
83 "The Multiple Sequence Alignment Service named "
84 + sh.getName() + " is unknown",
85 "Internal Jalview Error", JOptionPane.WARNING_MESSAGE);
89 startMsaWSClient(altitle, msa, submitGaps, preserveOrder, seqdataset);
96 // add a class reference to the list
99 private void startMsaWSClient(String altitle, AlignmentView msa,
100 boolean submitGaps, boolean preserveOrder, Alignment seqdataset)
102 if (!locateWebService())
107 wsInfo.setProgressText(((submitGaps) ? "Re-alignment" : "Alignment")
108 + " of " + altitle + "\nJob details\n");
109 String jobtitle = WebServiceName.toLowerCase();
110 if (jobtitle.endsWith("alignment"))
113 && (!jobtitle.endsWith("realignment") || jobtitle
114 .indexOf("profile") == -1))
116 int pos = jobtitle.indexOf("alignment");
117 jobtitle = WebServiceName.substring(0, pos) + "re-alignment of "
122 jobtitle = WebServiceName + " of " + altitle;
127 jobtitle = WebServiceName + (submitGaps ? " re" : " ")
128 + "alignment of " + altitle;
131 MsaWSThread msathread = new MsaWSThread(server, WsURL, wsInfo,
132 alignFrame, WebServiceName, jobtitle, msa, submitGaps,
133 preserveOrder, seqdataset);
134 wsInfo.setthisService(msathread);
139 * Initializes the server field with a valid service implementation.
141 * @return true if service was located.
143 private boolean locateWebService()
145 // TODO: MuscleWS transmuted to generic MsaWS client
146 MuscleWSServiceLocator loc = new MuscleWSServiceLocator(); // Default
150 this.server = (MuscleWS) loc.getMuscleWS(new java.net.URL(WsURL));
151 ((MuscleWSSoapBindingStub) this.server).setTimeout(60000); // One minute
153 } catch (Exception ex)
155 wsInfo.setProgressText("Serious! " + WebServiceName
156 + " Service location failed\nfor URL :" + WsURL + "\n"
158 wsInfo.setStatus(WebserviceInfo.ERROR);
159 ex.printStackTrace();
164 loc.getEngine().setOption("axis", "1");
169 protected String getServiceActionKey()
174 protected String getServiceActionDescription()
176 return "Multiple Sequence Alignment";
180 * look at ourselves and work out if we are a service that can take a profile
183 * @return true if we can send gapped sequences to the alignment service
185 private boolean canSubmitGaps()
187 // TODO: query service or extract service handle props to check if we can
189 return (WebServiceName.indexOf("lustal") > -1); // cheat!
192 public void attachWSMenuEntry(JMenu msawsmenu,
193 final ServiceHandle serviceHandle, final AlignFrame alignFrame)
195 setWebService(serviceHandle, true); // headless
196 JMenuItem method = new JMenuItem(WebServiceName);
197 method.setToolTipText(WsURL);
198 method.addActionListener(new ActionListener()
200 public void actionPerformed(ActionEvent e)
202 AlignmentView msa = alignFrame.gatherSequencesForAlignment();
203 new jalview.ws.MsaWSClient(serviceHandle, alignFrame.getTitle(),
204 msa, false, true, alignFrame.getViewport().getAlignment()
205 .getDataset(), alignFrame);
210 msawsmenu.add(method);
213 // We know that ClustalWS can accept partial alignments for refinement.
214 final JMenuItem methodR = new JMenuItem(serviceHandle.getName()
216 methodR.setToolTipText(WsURL);
217 methodR.addActionListener(new ActionListener()
219 public void actionPerformed(ActionEvent e)
221 AlignmentView msa = alignFrame.gatherSequencesForAlignment();
222 new jalview.ws.MsaWSClient(serviceHandle, alignFrame.getTitle(),
223 msa, true, true, alignFrame.getViewport().getAlignment()
224 .getDataset(), alignFrame);
229 msawsmenu.add(methodR);