2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 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.awt.event.ActionEvent;
24 import java.awt.event.ActionListener;
29 import jalview.datamodel.*;
38 public class MsaWSClient extends WS1Client
41 * server is a WSDL2Java generated stub for an archetypal MsaWSI service.
43 ext.vamsas.MuscleWS server;
45 AlignFrame alignFrame;
48 * Creates a new MsaWSClient object that uses a service given by an externally
49 * retrieved ServiceHandle
52 * service handle of type AbstractName(MsaWS)
59 * @param preserveOrder
63 public MsaWSClient(ext.vamsas.ServiceHandle sh, String altitle,
64 jalview.datamodel.AlignmentView msa, boolean submitGaps,
65 boolean preserveOrder, Alignment seqdataset,
66 AlignFrame _alignFrame)
69 alignFrame = _alignFrame;
70 if (!sh.getAbstractName().equals("MsaWS"))
75 "The Service called \n"
77 + "\nis not a \nMultiple Sequence Alignment Service !",
78 "Internal Jalview Error", JOptionPane.WARNING_MESSAGE);
83 if ((wsInfo = setWebService(sh)) == null)
85 JOptionPane.showMessageDialog(
87 "The Multiple Sequence Alignment Service named "
88 + sh.getName() + " is unknown",
89 "Internal Jalview Error", JOptionPane.WARNING_MESSAGE);
93 startMsaWSClient(altitle, msa, submitGaps, preserveOrder, seqdataset);
100 // add a class reference to the list
103 private void startMsaWSClient(String altitle, AlignmentView msa,
104 boolean submitGaps, boolean preserveOrder, Alignment seqdataset)
106 if (!locateWebService())
111 wsInfo.setProgressText(((submitGaps) ? "Re-alignment" : "Alignment")
112 + " of " + altitle + "\nJob details\n");
113 String jobtitle = WebServiceName.toLowerCase();
114 if (jobtitle.endsWith("alignment"))
117 && (!jobtitle.endsWith("realignment") || jobtitle
118 .indexOf("profile") == -1))
120 int pos = jobtitle.indexOf("alignment");
121 jobtitle = WebServiceName.substring(0, pos) + "re-alignment of "
126 jobtitle = WebServiceName + " of " + altitle;
131 jobtitle = WebServiceName + (submitGaps ? " re" : " ")
132 + "alignment of " + altitle;
135 MsaWSThread msathread = new MsaWSThread(server, WsURL, wsInfo,
136 alignFrame, WebServiceName, jobtitle, msa, submitGaps,
137 preserveOrder, seqdataset);
138 wsInfo.setthisService(msathread);
143 * Initializes the server field with a valid service implementation.
145 * @return true if service was located.
147 private boolean locateWebService()
149 // TODO: MuscleWS transmuted to generic MsaWS client
150 MuscleWSServiceLocator loc = new MuscleWSServiceLocator(); // Default
154 this.server = (MuscleWS) loc.getMuscleWS(new java.net.URL(WsURL));
155 ((MuscleWSSoapBindingStub) this.server).setTimeout(60000); // One minute
157 } catch (Exception ex)
159 wsInfo.setProgressText("Serious! " + WebServiceName
160 + " Service location failed\nfor URL :" + WsURL + "\n"
162 wsInfo.setStatus(WebserviceInfo.ERROR);
163 ex.printStackTrace();
168 loc.getEngine().setOption("axis", "1");
173 protected String getServiceActionKey()
178 protected String getServiceActionDescription()
180 return "Multiple Sequence Alignment";
184 * look at ourselves and work out if we are a service that can take a profile
187 * @return true if we can send gapped sequences to the alignment service
189 private boolean canSubmitGaps()
191 // TODO: query service or extract service handle props to check if we can
193 return (WebServiceName.indexOf("lustal") > -1); // cheat!
196 public void attachWSMenuEntry(JMenu msawsmenu,
197 final ServiceHandle serviceHandle, final AlignFrame alignFrame)
199 setWebService(serviceHandle, true); // headless
200 JMenuItem method = new JMenuItem(WebServiceName);
201 method.setToolTipText(WsURL);
202 method.addActionListener(new ActionListener()
204 public void actionPerformed(ActionEvent e)
206 AlignmentView msa = alignFrame.gatherSequencesForAlignment();
207 new jalview.ws.jws1.MsaWSClient(serviceHandle, alignFrame
208 .getTitle(), msa, false, true, alignFrame.getViewport()
209 .getAlignment().getDataset(), alignFrame);
214 msawsmenu.add(method);
217 // We know that ClustalWS can accept partial alignments for refinement.
218 final JMenuItem methodR = new JMenuItem(serviceHandle.getName()
220 methodR.setToolTipText(WsURL);
221 methodR.addActionListener(new ActionListener()
223 public void actionPerformed(ActionEvent e)
225 AlignmentView msa = alignFrame.gatherSequencesForAlignment();
226 new jalview.ws.jws1.MsaWSClient(serviceHandle, alignFrame
227 .getTitle(), msa, true, true, alignFrame.getViewport()
228 .getAlignment().getDataset(), alignFrame);
233 msawsmenu.add(methodR);