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;
22 import java.util.List;
26 import jalview.datamodel.*;
28 import compbio.data.msa.MsaWS;
29 import compbio.metadata.Argument;
30 import compbio.metadata.Preset;
31 import compbio.metadata.PresetManager;
32 import jalview.ws.jws2.Jws2Discoverer.Jws2Instance;
40 public class MsaWSClient extends Jws2Client
43 * server is a WSDL2Java generated stub for an archetypal MsaWSI service.
46 AlignFrame alignFrame;
47 private Preset preset;
48 private List<Argument> paramset;
51 public MsaWSClient(Jws2Discoverer.Jws2Instance sh, String altitle,
52 jalview.datamodel.AlignmentView msa, boolean submitGaps,
53 boolean preserveOrder, Alignment seqdataset,
54 AlignFrame _alignFrame)
56 this(sh, null, null, altitle, msa, submitGaps, preserveOrder, seqdataset, _alignFrame);
57 // TODO Auto-generated constructor stub
60 public MsaWSClient(Jws2Discoverer.Jws2Instance sh, Preset preset, String altitle,
61 jalview.datamodel.AlignmentView msa, boolean submitGaps,
62 boolean preserveOrder, Alignment seqdataset,
63 AlignFrame _alignFrame)
65 this(sh, preset, null, altitle, msa, submitGaps, preserveOrder, seqdataset, _alignFrame);
66 // TODO Auto-generated constructor stub
69 * Creates a new MsaWSClient object that uses a service given by an externally
70 * retrieved ServiceHandle
73 * service handle of type AbstractName(MsaWS)
80 * @param preserveOrder
84 public MsaWSClient(Jws2Discoverer.Jws2Instance sh, Preset preset, List<Argument> arguments, String altitle,
85 jalview.datamodel.AlignmentView msa, boolean submitGaps,
86 boolean preserveOrder, Alignment seqdataset,
87 AlignFrame _alignFrame) {
89 alignFrame = _alignFrame;
90 if (!(sh.service instanceof MsaWS))
92 // redundant at mo - but may change
96 "The Service called \n"
98 + "\nis not a \nMultiple Sequence Alignment Service !",
99 "Internal Jalview Error", JOptionPane.WARNING_MESSAGE);
104 this.preset = preset;
105 this.paramset = arguments;
106 if ((wsInfo = setWebService(sh, false)) == null)
108 JOptionPane.showMessageDialog(Desktop.desktop,
109 "The Multiple Sequence Alignment Service named "
110 + sh.serviceType + " is unknown",
111 "Internal Jalview Error", JOptionPane.WARNING_MESSAGE);
115 startMsaWSClient(altitle, msa, submitGaps, preserveOrder, seqdataset);
122 // add a class reference to the list
125 private void startMsaWSClient(String altitle, AlignmentView msa,
126 boolean submitGaps, boolean preserveOrder, Alignment seqdataset)
128 //if (!locateWebService())
133 wsInfo.setProgressText(((submitGaps) ? "Re-alignment" : "Alignment")
134 + " of " + altitle + "\nJob details\n");
135 String jobtitle = WebServiceName.toLowerCase();
136 if (jobtitle.endsWith("alignment"))
139 && (!jobtitle.endsWith("realignment") || jobtitle
140 .indexOf("profile") == -1))
142 int pos = jobtitle.indexOf("alignment");
143 jobtitle = WebServiceName.substring(0, pos) + "re-alignment of "
148 jobtitle = WebServiceName + " of " + altitle;
153 jobtitle = WebServiceName + (submitGaps ? " re" : " ")
154 + "alignment of " + altitle;
157 MsaWSThread msathread = new MsaWSThread(server, preset, paramset, WsURL, wsInfo,
158 alignFrame, WebServiceName, jobtitle, msa, submitGaps,
159 preserveOrder, seqdataset);
160 wsInfo.setthisService(msathread);
164 protected String getServiceActionKey()
169 protected String getServiceActionDescription()
171 return "Multiple Sequence Alignment";
175 * look at ourselves and work out if we are a service that can take a profile
178 * @return true if we can send gapped sequences to the alignment service
180 private boolean canSubmitGaps()
182 // TODO: query service or extract service handle props to check if we can
184 return (WebServiceName.indexOf("lustal") > -1); // cheat!
187 public void attachWSMenuEntry(JMenu msawsmenu,
188 final Jws2Instance service, final AlignFrame alignFrame)
190 setWebService(service, 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 MsaWSClient(service, alignFrame.getTitle(),
199 msa, false, true, alignFrame.getViewport().getAlignment()
200 .getDataset(), alignFrame);
205 msawsmenu.add(method);
208 // We know that ClustalWS can accept partial alignments for refinement.
209 final JMenuItem methodR = new JMenuItem(WebServiceName
211 methodR.setToolTipText(WsURL);
212 methodR.addActionListener(new ActionListener()
214 public void actionPerformed(ActionEvent e)
216 AlignmentView msa = alignFrame.gatherSequencesForAlignment();
217 new MsaWSClient(service, alignFrame.getTitle(),
218 msa, true, true, alignFrame.getViewport().getAlignment()
219 .getDataset(), alignFrame);
224 msawsmenu.add(methodR);
227 PresetManager presets = service.getPresets();
228 if (presets!=null && presets.getPresets().size()>0)
230 JMenu presetlist = new JMenu("Presets for "+WebServiceName+"(Without gaps)");
232 for (final Preset preset : (List<Preset>) presets.getPresets())
234 final JMenuItem methodR = new JMenuItem(preset.getName());
235 methodR.setToolTipText(preset.getDescription());
236 methodR.addActionListener(new ActionListener()
238 public void actionPerformed(ActionEvent e)
240 AlignmentView msa = alignFrame.gatherSequencesForAlignment();
241 new MsaWSClient(service, preset, alignFrame.getTitle(),
242 msa, false, true, alignFrame.getViewport().getAlignment()
243 .getDataset(), alignFrame);
248 presetlist.add(methodR);
250 msawsmenu.add(presetlist);