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.jws2;
23 import jalview.api.AlignCalcWorkerI;
24 import jalview.gui.AlignFrame;
25 import jalview.gui.Desktop;
26 import jalview.gui.JvSwingUtils;
27 import jalview.util.MessageManager;
28 import jalview.ws.jws2.dm.AAConSettings;
29 import jalview.ws.jws2.jabaws2.Jws2Instance;
30 import jalview.ws.params.WsParamSetI;
31 import jalview.ws.uimodel.AlignAnalysisUIText;
33 import java.awt.event.ActionEvent;
34 import java.awt.event.ActionListener;
35 import java.util.List;
37 import javax.swing.JMenu;
38 import javax.swing.JMenuItem;
44 public class SequenceAnnotationWSClient extends Jws2Client
47 * initialise a client so its attachWSMenuEntry method can be called.
49 public SequenceAnnotationWSClient()
51 // TODO Auto-generated constructor stub
54 public SequenceAnnotationWSClient(final Jws2Instance sh,
55 AlignFrame alignFrame, WsParamSetI preset, boolean editParams)
57 super(alignFrame, preset, null);
58 initSequenceAnnotationWSClient(sh, alignFrame, preset, editParams);
61 // dan think. Do I need to change this method to run RNAalifold through the
64 public void initSequenceAnnotationWSClient(final Jws2Instance sh,
65 AlignFrame alignFrame, WsParamSetI preset, boolean editParams)
67 // dan changed! dan test. comment out if conditional
68 // if (alignFrame.getViewport().getAlignment().isNucleotide())
70 // JOptionPane.showMessageDialog(Desktop.desktop, sh.serviceType
71 // + " can only be used\nfor amino acid alignments.",
72 // "Wrong type of sequences!", JOptionPane.WARNING_MESSAGE);
76 AlignAnalysisUIText aaui = sh.getAlignAnalysisUI();
79 Class clientClass = aaui.getClient();
81 // Build an AACon style client - take alignment, return annotation for
84 List<AlignCalcWorkerI> clnts = alignFrame.getViewport()
85 .getCalcManager().getRegisteredWorkersOfClass(clientClass);
86 AbstractJabaCalcWorker worker;
87 if (clnts == null || clnts.size() == 0)
89 if (!processParams(sh, editParams))
95 worker = (AbstractJabaCalcWorker) (clientClass
96 .getConstructor(new Class[] { Jws2Instance.class,
97 AlignFrame.class, WsParamSetI.class, List.class })
98 .newInstance(new Object[] { sh, alignFrame, this.preset,
100 } catch (Exception x)
104 MessageManager.getString("error.implementation_error"), x);
106 alignFrame.getViewport().getCalcManager().registerWorker(worker);
107 alignFrame.getViewport().getCalcManager().startWorker(worker);
112 worker = (AbstractJabaCalcWorker) clnts.get(0);
115 paramset = worker.getArguments();
116 preset = worker.getPreset();
119 if (!processParams(sh, editParams, true))
123 // reinstate worker if it was blacklisted (might have happened due to
124 // invalid parameters)
125 alignFrame.getViewport().getCalcManager().workerMayRun(worker);
126 worker.updateParameters(this.preset, paramset);
129 if (sh.action.toLowerCase().contains("disorder"))
131 // build IUPred style client. take sequences, returns annotation per
133 if (!processParams(sh, editParams))
142 new AADisorderClient(sh, alignFrame, preset, paramset));
146 public SequenceAnnotationWSClient(AAConSettings fave,
147 AlignFrame alignFrame, boolean b)
149 super(alignFrame, fave.getPreset(), fave.getJobArgset());
150 initSequenceAnnotationWSClient(fave.getService(), alignFrame,
151 fave.getPreset(), b);
157 * @see jalview.ws.jws2.Jws2Client#attachWSMenuEntry(javax.swing.JMenu,
158 * jalview.ws.jws2.jabaws2.Jws2Instance, jalview.gui.AlignFrame)
160 public void attachWSMenuEntry(JMenu wsmenu, final Jws2Instance service,
161 final AlignFrame alignFrame)
163 if (registerAAConWSInstance(wsmenu, service, alignFrame))
165 // Alignment dependent analysis calculation WS gui
168 boolean hasparams = service.hasParameters();
169 // Assume name ends in WS
170 String calcName = service.serviceType.substring(0,
171 service.serviceType.length() - 2);
173 JMenuItem annotservice = new JMenuItem(MessageManager.formatMessage(
174 "label.calcname_with_default_settings",
175 new String[] { calcName }));
176 annotservice.addActionListener(new ActionListener()
180 public void actionPerformed(ActionEvent e)
182 new SequenceAnnotationWSClient(service, alignFrame, null, false);
185 wsmenu.add(annotservice);
188 // only add these menu options if the service has user-modifiable
190 annotservice = new JMenuItem(
191 MessageManager.getString("label.edit_settings_and_run"));
193 .setToolTipText(MessageManager
194 .getString("label.view_and_change_parameters_before_running_calculation"));
196 annotservice.addActionListener(new ActionListener()
198 public void actionPerformed(ActionEvent e)
200 new SequenceAnnotationWSClient(service, alignFrame, null, true);
203 wsmenu.add(annotservice);
204 List<WsParamSetI> presets = service.getParamStore().getPresets();
205 if (presets != null && presets.size() > 0)
207 JMenu presetlist = new JMenu(MessageManager.formatMessage(
208 "label.run_with_preset", new String[] { calcName }));
210 for (final WsParamSetI preset : presets)
212 final JMenuItem methodR = new JMenuItem(preset.getName());
213 methodR.setToolTipText(JvSwingUtils.wrapTooltip(
216 + (preset.isModifiable() ? MessageManager
217 .getString("label.user_preset")
219 .getString("label.service_preset"))
220 + "</strong><br/>" + preset.getDescription()));
221 methodR.addActionListener(new ActionListener()
223 public void actionPerformed(ActionEvent e)
225 new SequenceAnnotationWSClient(service, alignFrame, preset,
230 presetlist.add(methodR);
232 wsmenu.add(presetlist);
238 annotservice = new JMenuItem(
239 MessageManager.getString("label.view_documentation"));
240 if (service.docUrl != null)
242 annotservice.addActionListener(new ActionListener()
246 public void actionPerformed(ActionEvent arg0)
248 Desktop.instance.showUrl(service.docUrl);
251 annotservice.setToolTipText(JvSwingUtils.wrapTooltip(true,
252 MessageManager.formatMessage("label.view_service_doc_url",
253 new String[] { service.docUrl, service.docUrl })));
254 wsmenu.add(annotservice);