2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ 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 jalview.datamodel.AlignmentI;
24 import jalview.datamodel.AlignmentView;
25 import jalview.gui.AlignFrame;
26 import jalview.gui.Desktop;
27 import jalview.gui.WebserviceInfo;
28 import jalview.util.MessageManager;
30 import java.awt.event.ActionEvent;
31 import java.awt.event.ActionListener;
33 import javax.swing.JMenu;
34 import javax.swing.JMenuItem;
35 import javax.swing.JOptionPane;
37 import ext.vamsas.MuscleWSServiceLocator;
38 import ext.vamsas.MuscleWSSoapBindingStub;
39 import ext.vamsas.ServiceHandle;
47 public class MsaWSClient extends WS1Client
50 * server is a WSDL2Java generated stub for an archetypal MsaWSI service.
52 ext.vamsas.MuscleWS server;
54 AlignFrame alignFrame;
57 * Creates a new MsaWSClient object that uses a service given by an externally
58 * retrieved ServiceHandle
61 * service handle of type AbstractName(MsaWS)
68 * @param preserveOrder
72 public MsaWSClient(ext.vamsas.ServiceHandle sh, String altitle,
73 jalview.datamodel.AlignmentView msa, boolean submitGaps,
74 boolean preserveOrder, AlignmentI seqdataset,
75 AlignFrame _alignFrame)
78 alignFrame = _alignFrame;
79 if (!sh.getAbstractName().equals("MsaWS"))
81 JOptionPane.showMessageDialog(Desktop.desktop, MessageManager
82 .formatMessage("label.service_called_is_not_msa_service",
83 new String[] { sh.getName() }), MessageManager
84 .getString("label.internal_jalview_error"),
85 JOptionPane.WARNING_MESSAGE);
90 if ((wsInfo = setWebService(sh)) == null)
92 JOptionPane.showMessageDialog(Desktop.desktop, MessageManager
93 .formatMessage("label.msa_service_is_unknown",
94 new String[] { sh.getName() }), MessageManager
95 .getString("label.internal_jalview_error"),
96 JOptionPane.WARNING_MESSAGE);
100 startMsaWSClient(altitle, msa, submitGaps, preserveOrder, seqdataset);
107 // add a class reference to the list
110 private void startMsaWSClient(String altitle, AlignmentView msa,
111 boolean submitGaps, boolean preserveOrder, AlignmentI seqdataset)
113 if (!locateWebService())
118 wsInfo.setProgressText(((submitGaps) ? "Re-alignment" : "Alignment")
119 + " of " + altitle + "\nJob details\n");
120 String jobtitle = WebServiceName.toLowerCase();
121 if (jobtitle.endsWith("alignment"))
124 && (!jobtitle.endsWith("realignment") || jobtitle
125 .indexOf("profile") == -1))
127 int pos = jobtitle.indexOf("alignment");
128 jobtitle = WebServiceName.substring(0, pos) + "re-alignment of "
133 jobtitle = WebServiceName + " of " + altitle;
138 jobtitle = WebServiceName + (submitGaps ? " re" : " ")
139 + "alignment of " + altitle;
142 MsaWSThread msathread = new MsaWSThread(server, WsURL, wsInfo,
143 alignFrame, WebServiceName, jobtitle, msa, submitGaps,
144 preserveOrder, seqdataset);
145 wsInfo.setthisService(msathread);
150 * Initializes the server field with a valid service implementation.
152 * @return true if service was located.
154 private boolean locateWebService()
156 // TODO: MuscleWS transmuted to generic MsaWS client
157 MuscleWSServiceLocator loc = new MuscleWSServiceLocator(); // Default
161 this.server = loc.getMuscleWS(new java.net.URL(WsURL));
162 ((MuscleWSSoapBindingStub) this.server).setTimeout(60000); // One minute
164 } catch (Exception ex)
166 wsInfo.setProgressText("Serious! " + WebServiceName
167 + " Service location failed\nfor URL :" + WsURL + "\n"
169 wsInfo.setStatus(WebserviceInfo.ERROR);
170 ex.printStackTrace();
175 loc.getEngine().setOption("axis", "1");
180 protected String getServiceActionKey()
185 protected String getServiceActionDescription()
187 return "Multiple Sequence Alignment";
191 * look at ourselves and work out if we are a service that can take a profile
194 * @return true if we can send gapped sequences to the alignment service
196 private boolean canSubmitGaps()
198 // TODO: query service or extract service handle props to check if we can
200 return (WebServiceName.indexOf("lustal") > -1); // cheat!
204 public void attachWSMenuEntry(JMenu msawsmenu,
205 final ServiceHandle serviceHandle, final AlignFrame alignFrame)
207 setWebService(serviceHandle, true); // headless
208 JMenuItem method = new JMenuItem(WebServiceName);
209 method.setToolTipText(WsURL);
210 method.addActionListener(new ActionListener()
213 public void actionPerformed(ActionEvent e)
215 AlignmentView msa = alignFrame.gatherSequencesForAlignment();
216 new jalview.ws.jws1.MsaWSClient(serviceHandle, alignFrame
217 .getTitle(), msa, false, true, alignFrame.getViewport()
218 .getAlignment().getDataset(), alignFrame);
223 msawsmenu.add(method);
226 // We know that ClustalWS can accept partial alignments for refinement.
227 final JMenuItem methodR = new JMenuItem(serviceHandle.getName()
229 methodR.setToolTipText(WsURL);
230 methodR.addActionListener(new ActionListener()
233 public void actionPerformed(ActionEvent e)
235 AlignmentView msa = alignFrame.gatherSequencesForAlignment();
236 new jalview.ws.jws1.MsaWSClient(serviceHandle, alignFrame
237 .getTitle(), msa, true, true, alignFrame.getViewport()
238 .getAlignment().getDataset(), alignFrame);
243 msawsmenu.add(methodR);