2 * Jalview - A Sequence Alignment Editor and Viewer
3 * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
21 import java.awt.event.ActionEvent;
22 import java.awt.event.ActionListener;
27 import jalview.datamodel.*;
36 public class MsaWSClient
40 * server is a WSDL2Java generated stub for an archetypal MsaWSI service.
42 ext.vamsas.MuscleWS server;
43 AlignFrame alignFrame;
46 * Creates a new MsaWSClient object that uses a service
47 * given by an externally retrieved ServiceHandle
49 * @param sh service handle of type AbstractName(MsaWS)
50 * @param altitle DOCUMENT ME!
51 * @param msa DOCUMENT ME!
52 * @param submitGaps DOCUMENT ME!
53 * @param preserveOrder DOCUMENT ME!
56 public MsaWSClient(ext.vamsas.ServiceHandle sh, String altitle,
57 jalview.datamodel.AlignmentView msa,
58 boolean submitGaps, boolean preserveOrder,
60 AlignFrame _alignFrame)
63 alignFrame = _alignFrame;
64 if (!sh.getAbstractName().equals("MsaWS"))
66 JOptionPane.showMessageDialog(Desktop.desktop,
67 "The Service called \n" + sh.getName() +
68 "\nis not a \nMultiple Sequence Alignment Service !",
69 "Internal Jalview Error",
70 JOptionPane.WARNING_MESSAGE);
75 if ( (wsInfo = setWebService(sh)) == null)
77 JOptionPane.showMessageDialog(Desktop.desktop,
78 "The Multiple Sequence Alignment Service named " +
80 " is unknown", "Internal Jalview Error",
81 JOptionPane.WARNING_MESSAGE);
85 startMsaWSClient(altitle, msa, submitGaps, preserveOrder, seqdataset);
92 // add a class reference to the list
95 private void startMsaWSClient(String altitle, AlignmentView msa,
96 boolean submitGaps, boolean preserveOrder,
99 if (!locateWebService())
104 wsInfo.setProgressText( ( (submitGaps) ? "Re-alignment" : "Alignment") +
105 " of " + altitle + "\nJob details\n");
106 String jobtitle = WebServiceName.toLowerCase();
107 if (jobtitle.endsWith("alignment"))
110 && (!jobtitle.endsWith("realignment")
111 || jobtitle.indexOf("profile") == -1))
113 int pos = jobtitle.indexOf("alignment");
114 jobtitle = WebServiceName.substring(0, pos) + "re-alignment of " +
119 jobtitle = WebServiceName + " of " + altitle;
124 jobtitle = WebServiceName + (submitGaps ? " re" : " ") + "alignment of " +
128 MsaWSThread msathread = new MsaWSThread(server, WsURL, wsInfo, alignFrame,
132 submitGaps, preserveOrder,
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 timeout
155 wsInfo.setProgressText("Serious! " + WebServiceName +
156 " Service location failed\nfor URL :" + WsURL +
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";
180 * look at ourselves and work out if we are a service that can take a profile and align to it
181 * @return true if we can send gapped sequences to the alignment service
183 private boolean canSubmitGaps()
185 // TODO: query service or extract service handle props to check if we can realign
186 return (WebServiceName.indexOf("lustal") > -1); // cheat!
188 public void attachWSMenuEntry(JMenu msawsmenu, final ServiceHandle serviceHandle, final AlignFrame alignFrame)
190 setWebService(serviceHandle, true); // headless
191 JMenuItem method = new JMenuItem(WebServiceName);
192 method.setToolTipText(WsURL);
193 method.addActionListener(new ActionListener()
195 public void actionPerformed(ActionEvent e)
197 AlignmentView msa = alignFrame.gatherSequencesForAlignment();
198 new jalview.ws.MsaWSClient(serviceHandle, alignFrame.getTitle(), msa,
200 alignFrame.getViewport().getAlignment().getDataset(),
206 msawsmenu.add(method);
209 // We know that ClustalWS can accept partial alignments for refinement.
210 final JMenuItem methodR = new JMenuItem(serviceHandle.getName()+" Realign");
211 methodR.setToolTipText(WsURL);
212 methodR.addActionListener(new ActionListener()
214 public void actionPerformed(ActionEvent e)
216 AlignmentView msa = alignFrame.gatherSequencesForAlignment();
217 new jalview.ws.MsaWSClient(serviceHandle, alignFrame.getTitle(), msa,
219 alignFrame.getViewport().getAlignment().getDataset(),
225 msawsmenu.add(methodR);