2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5)
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.jws2;
20 import java.awt.event.ActionEvent;
21 import java.awt.event.ActionListener;
25 import jalview.datamodel.*;
27 import compbio.data.msa.MsaWS;
28 import jalview.ws.jws2.Jws2Discoverer.Jws2Instance;
36 public class MsaWSClient extends Jws2Client
39 * server is a WSDL2Java generated stub for an archetypal MsaWSI service.
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(Jws2Discoverer.Jws2Instance sh, String altitle,
61 jalview.datamodel.AlignmentView msa, boolean submitGaps,
62 boolean preserveOrder, Alignment seqdataset,
63 AlignFrame _alignFrame)
66 alignFrame = _alignFrame;
67 if (!(sh.service instanceof MsaWS))
69 // redundant at mo - but may change
73 "The Service called \n"
75 + "\nis not a \nMultiple Sequence Alignment Service !",
76 "Internal Jalview Error", JOptionPane.WARNING_MESSAGE);
81 if ((wsInfo = setWebService(sh, false)) == null)
83 JOptionPane.showMessageDialog(Desktop.desktop,
84 "The Multiple Sequence Alignment Service named "
85 + sh.serviceType + " 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);
139 protected String getServiceActionKey()
144 protected String getServiceActionDescription()
146 return "Multiple Sequence Alignment";
150 * look at ourselves and work out if we are a service that can take a profile
153 * @return true if we can send gapped sequences to the alignment service
155 private boolean canSubmitGaps()
157 // TODO: query service or extract service handle props to check if we can
159 return (WebServiceName.indexOf("lustal") > -1); // cheat!
162 public void attachWSMenuEntry(JMenu msawsmenu,
163 final Jws2Instance service, final AlignFrame alignFrame)
165 setWebService(service, true); // headless
166 JMenuItem method = new JMenuItem(WebServiceName);
167 method.setToolTipText(WsURL);
168 method.addActionListener(new ActionListener()
170 public void actionPerformed(ActionEvent e)
172 AlignmentView msa = alignFrame.gatherSequencesForAlignment();
173 new MsaWSClient(service, alignFrame.getTitle(),
174 msa, false, true, alignFrame.getViewport().getAlignment()
175 .getDataset(), alignFrame);
180 msawsmenu.add(method);
183 // We know that ClustalWS can accept partial alignments for refinement.
184 final JMenuItem methodR = new JMenuItem(WebServiceName
186 methodR.setToolTipText(WsURL);
187 methodR.addActionListener(new ActionListener()
189 public void actionPerformed(ActionEvent e)
191 AlignmentView msa = alignFrame.gatherSequencesForAlignment();
192 new MsaWSClient(service, alignFrame.getTitle(),
193 msa, true, true, alignFrame.getViewport().getAlignment()
194 .getDataset(), alignFrame);
199 msawsmenu.add(methodR);