2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
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/>.
18 package jalview.ws.jws1;
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(
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.jws1.MsaWSClient(serviceHandle, alignFrame
205 .getTitle(), msa, false, true, alignFrame.getViewport()
206 .getAlignment().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.jws1.MsaWSClient(serviceHandle, alignFrame
224 .getTitle(), msa, true, true, alignFrame.getViewport()
225 .getAlignment().getDataset(), alignFrame);
230 msawsmenu.add(methodR);