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.*;
31 import jalview.util.MessageManager;
39 public class MsaWSClient extends WS1Client
42 * server is a WSDL2Java generated stub for an archetypal MsaWSI service.
44 ext.vamsas.MuscleWS server;
46 AlignFrame alignFrame;
49 * Creates a new MsaWSClient object that uses a service given by an externally
50 * retrieved ServiceHandle
53 * service handle of type AbstractName(MsaWS)
60 * @param preserveOrder
64 public MsaWSClient(ext.vamsas.ServiceHandle sh, String altitle,
65 jalview.datamodel.AlignmentView msa, boolean submitGaps,
66 boolean preserveOrder, Alignment seqdataset,
67 AlignFrame _alignFrame)
70 alignFrame = _alignFrame;
71 if (!sh.getAbstractName().equals("MsaWS"))
76 MessageManager.formatMessage("label.service_called_is_not_msa_service", new String[]{sh.getName()}),
77 MessageManager.getString("label.internal_jalview_error"), JOptionPane.WARNING_MESSAGE);
82 if ((wsInfo = setWebService(sh)) == null)
84 JOptionPane.showMessageDialog(
86 MessageManager.formatMessage("label.msa_service_is_unknown", new String[]{sh.getName()}),
87 MessageManager.getString("label.internal_jalview_error"), JOptionPane.WARNING_MESSAGE);
91 startMsaWSClient(altitle, msa, submitGaps, preserveOrder, seqdataset);
98 // add a class reference to the list
101 private void startMsaWSClient(String altitle, AlignmentView msa,
102 boolean submitGaps, boolean preserveOrder, Alignment seqdataset)
104 if (!locateWebService())
109 wsInfo.setProgressText(((submitGaps) ? "Re-alignment" : "Alignment")
110 + " of " + altitle + "\nJob details\n");
111 String jobtitle = WebServiceName.toLowerCase();
112 if (jobtitle.endsWith("alignment"))
115 && (!jobtitle.endsWith("realignment") || jobtitle
116 .indexOf("profile") == -1))
118 int pos = jobtitle.indexOf("alignment");
119 jobtitle = WebServiceName.substring(0, pos) + "re-alignment of "
124 jobtitle = WebServiceName + " of " + altitle;
129 jobtitle = WebServiceName + (submitGaps ? " re" : " ")
130 + "alignment of " + altitle;
133 MsaWSThread msathread = new MsaWSThread(server, WsURL, wsInfo,
134 alignFrame, WebServiceName, jobtitle, msa, submitGaps,
135 preserveOrder, seqdataset);
136 wsInfo.setthisService(msathread);
141 * Initializes the server field with a valid service implementation.
143 * @return true if service was located.
145 private boolean locateWebService()
147 // TODO: MuscleWS transmuted to generic MsaWS client
148 MuscleWSServiceLocator loc = new MuscleWSServiceLocator(); // Default
152 this.server = (MuscleWS) loc.getMuscleWS(new java.net.URL(WsURL));
153 ((MuscleWSSoapBindingStub) this.server).setTimeout(60000); // One minute
155 } catch (Exception ex)
157 wsInfo.setProgressText("Serious! " + WebServiceName
158 + " Service location failed\nfor URL :" + WsURL + "\n"
160 wsInfo.setStatus(WebserviceInfo.ERROR);
161 ex.printStackTrace();
166 loc.getEngine().setOption("axis", "1");
171 protected String getServiceActionKey()
176 protected String getServiceActionDescription()
178 return "Multiple Sequence Alignment";
182 * look at ourselves and work out if we are a service that can take a profile
185 * @return true if we can send gapped sequences to the alignment service
187 private boolean canSubmitGaps()
189 // TODO: query service or extract service handle props to check if we can
191 return (WebServiceName.indexOf("lustal") > -1); // cheat!
194 public void attachWSMenuEntry(JMenu msawsmenu,
195 final ServiceHandle serviceHandle, final AlignFrame alignFrame)
197 setWebService(serviceHandle, true); // headless
198 JMenuItem method = new JMenuItem(WebServiceName);
199 method.setToolTipText(WsURL);
200 method.addActionListener(new ActionListener()
202 public void actionPerformed(ActionEvent e)
204 AlignmentView msa = alignFrame.gatherSequencesForAlignment();
205 new jalview.ws.jws1.MsaWSClient(serviceHandle, alignFrame
206 .getTitle(), msa, false, true, alignFrame.getViewport()
207 .getAlignment().getDataset(), alignFrame);
212 msawsmenu.add(method);
215 // We know that ClustalWS can accept partial alignments for refinement.
216 final JMenuItem methodR = new JMenuItem(serviceHandle.getName()
218 methodR.setToolTipText(WsURL);
219 methodR.addActionListener(new ActionListener()
221 public void actionPerformed(ActionEvent e)
223 AlignmentView msa = alignFrame.gatherSequencesForAlignment();
224 new jalview.ws.jws1.MsaWSClient(serviceHandle, alignFrame
225 .getTitle(), msa, true, true, alignFrame.getViewport()
226 .getAlignment().getDataset(), alignFrame);
231 msawsmenu.add(methodR);