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.jws2;
23 import jalview.api.AlignCalcWorkerI;
24 import jalview.bin.Cache;
25 import jalview.gui.AlignFrame;
26 import jalview.gui.Desktop;
27 import jalview.gui.JvSwingUtils;
28 import jalview.util.MessageManager;
29 import jalview.ws.jws2.dm.AAConSettings;
30 import jalview.ws.jws2.jabaws2.Jws2Instance;
31 import jalview.ws.params.WsParamSetI;
32 import jalview.ws.uimodel.AlignAnalysisUIText;
34 import java.awt.event.ActionEvent;
35 import java.awt.event.ActionListener;
36 import java.util.List;
38 import javax.swing.JCheckBoxMenuItem;
39 import javax.swing.JMenu;
40 import javax.swing.JMenuItem;
41 import javax.swing.JOptionPane;
42 import javax.swing.event.MenuEvent;
43 import javax.swing.event.MenuListener;
49 public class SequenceAnnotationWSClient extends Jws2Client
52 * initialise a client so its attachWSMenuEntry method can be called.
54 public SequenceAnnotationWSClient()
56 // TODO Auto-generated constructor stub
59 public SequenceAnnotationWSClient(final Jws2Instance sh,
60 AlignFrame alignFrame, WsParamSetI preset, boolean editParams)
62 super(alignFrame, preset, null);
63 initSequenceAnnotationWSClient(sh, alignFrame, preset, editParams);
66 // dan think. Do I need to change this method to run RNAalifold through the
69 public void initSequenceAnnotationWSClient(final Jws2Instance sh,
70 AlignFrame alignFrame, WsParamSetI preset, boolean editParams)
72 // dan changed! dan test. comment out if conditional
73 // if (alignFrame.getViewport().getAlignment().isNucleotide())
75 // JOptionPane.showMessageDialog(Desktop.desktop, sh.serviceType
76 // + " can only be used\nfor amino acid alignments.",
77 // "Wrong type of sequences!", JOptionPane.WARNING_MESSAGE);
81 AlignAnalysisUIText aaui = sh.getAlignAnalysisUI();
84 Class clientClass = aaui.getClient();
86 // Build an AACon style client - take alignment, return annotation for
89 List<AlignCalcWorkerI> clnts = alignFrame.getViewport()
90 .getCalcManager().getRegisteredWorkersOfClass(clientClass);
91 AbstractJabaCalcWorker worker;
92 if (clnts == null || clnts.size() == 0)
94 if (!processParams(sh, editParams))
100 worker = (AbstractJabaCalcWorker) (clientClass
101 .getConstructor(new Class[]
102 { Jws2Instance.class, AlignFrame.class,
103 WsParamSetI.class, List.class })
104 .newInstance(new Object[]
105 { sh, alignFrame, this.preset, paramset }));
106 } catch (Exception x)
109 throw new Error("Implementation error", x);
111 alignFrame.getViewport().getCalcManager().registerWorker(worker);
112 alignFrame.getViewport().getCalcManager().startWorker(worker);
117 worker = (AbstractJabaCalcWorker) clnts.get(0);
120 paramset = worker.getArguments();
121 preset = worker.getPreset();
124 if (!processParams(sh, editParams, true))
128 // reinstate worker if it was blacklisted (might have happened due to
129 // invalid parameters)
130 alignFrame.getViewport().getCalcManager().workerMayRun(worker);
131 worker.updateParameters(this.preset, paramset);
134 if (sh.action.toLowerCase().contains("disorder"))
136 // build IUPred style client. take sequences, returns annotation per
138 if (!processParams(sh, editParams))
147 new AADisorderClient(sh, alignFrame, preset, paramset));
151 public SequenceAnnotationWSClient(AAConSettings fave,
152 AlignFrame alignFrame, boolean b)
154 super(alignFrame, fave.getPreset(), fave.getJobArgset());
155 initSequenceAnnotationWSClient(fave.getService(), alignFrame,
156 fave.getPreset(), b);
162 * @see jalview.ws.jws2.Jws2Client#attachWSMenuEntry(javax.swing.JMenu,
163 * jalview.ws.jws2.jabaws2.Jws2Instance, jalview.gui.AlignFrame)
165 public void attachWSMenuEntry(JMenu wsmenu, final Jws2Instance service,
166 final AlignFrame alignFrame)
168 if (registerAAConWSInstance(wsmenu, service, alignFrame))
170 // Alignment dependent analysis calculation WS gui
173 boolean hasparams = service.hasParameters();
174 // Assume name ends in WS
175 String calcName = service.serviceType.substring(0,
176 service.serviceType.length() - 2);
178 JMenuItem annotservice = new JMenuItem(MessageManager.formatMessage(
179 "label.calcname_with_default_settings", new String[]
181 annotservice.addActionListener(new ActionListener()
185 public void actionPerformed(ActionEvent e)
187 new SequenceAnnotationWSClient(service, alignFrame, null, false);
190 wsmenu.add(annotservice);
193 // only add these menu options if the service has user-modifiable
195 annotservice = new JMenuItem(
196 MessageManager.getString("label.edit_settings_and_run"));
198 .setToolTipText(MessageManager
199 .getString("label.view_and_change_parameters_before_running_calculation"));
201 annotservice.addActionListener(new ActionListener()
203 public void actionPerformed(ActionEvent e)
205 new SequenceAnnotationWSClient(service, alignFrame, null, true);
208 wsmenu.add(annotservice);
209 List<WsParamSetI> presets = service.getParamStore().getPresets();
210 if (presets != null && presets.size() > 0)
212 JMenu presetlist = new JMenu("Run " + calcName + "with preset");
214 for (final WsParamSetI preset : presets)
216 final JMenuItem methodR = new JMenuItem(preset.getName());
217 methodR.setToolTipText("<html><p>"
218 + JvSwingUtils.wrapTooltip("<strong>"
219 + (preset.isModifiable() ? "User Preset"
220 : "Service Preset") + "</strong><br/>"
221 + preset.getDescription() + "</p>") + "</html>");
222 methodR.addActionListener(new ActionListener()
224 public void actionPerformed(ActionEvent e)
226 new SequenceAnnotationWSClient(service, alignFrame, preset,
231 presetlist.add(methodR);
233 wsmenu.add(presetlist);
239 annotservice = new JMenuItem(
240 MessageManager.getString("label.view_documentation"));
241 if (service.docUrl != null)
243 annotservice.addActionListener(new ActionListener()
247 public void actionPerformed(ActionEvent arg0)
249 Desktop.instance.showUrl(service.docUrl);
252 annotservice.setToolTipText("<html>"
253 + JvSwingUtils.wrapTooltip("View <a href=\""
254 + service.docUrl + "\">" + service.docUrl + "</a>")
256 wsmenu.add(annotservice);