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.api.ServiceWithParameters;
29 import jalview.ws.params.AutoCalcSetting;
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;
36 import java.util.Locale;
39 import javax.swing.JMenu;
40 import javax.swing.JMenuItem;
46 public class SequenceAnnotationWSClient extends Jws2Client
49 * initialise a client so its attachWSMenuEntry method can be called.
51 public SequenceAnnotationWSClient()
53 // TODO Auto-generated constructor stub
56 public SequenceAnnotationWSClient(final ServiceWithParameters sh,
57 AlignFrame alignFrame, WsParamSetI preset, boolean editParams)
59 super(alignFrame, preset, null);
60 initSequenceAnnotationWSClient(sh, alignFrame, preset, editParams);
63 // dan think. Do I need to change this method to run RNAalifold through the
66 private void initSequenceAnnotationWSClient(final ServiceWithParameters sh,
67 AlignFrame alignFrame, final WsParamSetI preset, boolean editParams)
69 // dan changed! dan test. comment out if conditional
70 // if (alignFrame.getViewport().getAlignment().isNucleotide())
72 // JvOptionPane.showMessageDialog(Desktop.desktop, sh.serviceType
73 // + " can only be used\nfor amino acid alignments.",
74 // "Wrong type of sequences!", JvOptionPane.WARNING_MESSAGE);
78 AlignAnalysisUIText aaui = sh.getAlignAnalysisUI();
81 Class clientClass = aaui.getClient();
83 // Build an AACon style client - take alignment, return annotation for
86 List<AlignCalcWorkerI> clnts = alignFrame.getViewport()
88 .getWorkersOfClass(SeqAnnotationServiceCalcWorker.class);
90 SeqAnnotationServiceCalcWorker tmpworker = null;
93 for (AlignCalcWorkerI _worker : clnts)
95 tmpworker = (SeqAnnotationServiceCalcWorker) _worker;
96 if (tmpworker.hasService()
97 && tmpworker.getService().getClass().equals(clientClass))
104 final var worker = tmpworker;
107 processParams(sh, editParams).thenAccept((startJob) -> {
110 final SeqAnnotationServiceCalcWorker worker_;
113 worker_ = new SeqAnnotationServiceCalcWorker(sh, alignFrame, this.preset,
115 } catch (Exception x)
119 MessageManager.getString("error.implementation_error"),
122 alignFrame.getViewport().getCalcManager().registerWorker(worker_);
123 // also starts the worker
124 startSeqAnnotationWorker(sh, alignFrame, preset, editParams);
134 paramset = worker.getArguments();
135 preset_ = worker.getPreset();
141 processParams(sh, editParams, true).thenAccept((startJob) -> {
144 // reinstate worker if it was blacklisted (might have happened due
146 // invalid parameters)
147 alignFrame.getViewport().getCalcManager().enableWorker(worker);
148 worker.updateParameters(this.preset, paramset);
149 startSeqAnnotationWorker(sh, alignFrame, preset_, editParams);
153 if (!processParams(sh, editParams, true).toCompletableFuture().join())
159 if (sh.action.toLowerCase(Locale.ROOT).contains("disorder"))
161 // build IUPred style client. take sequences, returns annotation per
163 processParams(sh, editParams).thenAccept((startJob) -> {
166 alignFrame.getViewport().getCalcManager().startWorker(
167 new SeqAnnotationServiceCalcWorker(sh, alignFrame, preset, paramset));
173 public SequenceAnnotationWSClient(AutoCalcSetting fave,
174 AlignFrame alignFrame, boolean b)
176 super(alignFrame, fave.getPreset(), fave.getArgumentSet());
177 initSequenceAnnotationWSClient(fave.getService(), alignFrame,
178 fave.getPreset(), b);
184 * @see jalview.ws.jws2.Jws2Client#attachWSMenuEntry(javax.swing.JMenu,
185 * jalview.ws.jws2.jabaws2.Jws2Instance, jalview.gui.AlignFrame)
188 public void attachWSMenuEntry(JMenu wsmenu,
189 final ServiceWithParameters service,
190 final AlignFrame alignFrame)
192 if (Jws2ClientFactory.registerAAConWSInstance(wsmenu,
193 service, alignFrame))
195 // Alignment dependent analysis calculation WS gui
198 boolean hasparams = service.hasParameters();
199 String calcName = service.getName();
200 if (calcName.endsWith("WS"))
202 // Remove "WS" suffix
203 calcName = calcName.substring(0, calcName.length() - 2);
206 JMenuItem annotservice = new JMenuItem(MessageManager.formatMessage(
207 "label.calcname_with_default_settings", new String[]
209 annotservice.addActionListener(new ActionListener()
213 public void actionPerformed(ActionEvent e)
215 new SequenceAnnotationWSClient(service, alignFrame,
219 wsmenu.add(annotservice);
222 // only add these menu options if the service has user-modifiable
224 annotservice = new JMenuItem(
225 MessageManager.getString("label.edit_settings_and_run"));
226 annotservice.setToolTipText(MessageManager.getString(
227 "label.view_and_change_parameters_before_running_calculation"));
229 annotservice.addActionListener(new ActionListener()
232 public void actionPerformed(ActionEvent e)
234 new SequenceAnnotationWSClient(service, alignFrame,
238 wsmenu.add(annotservice);
239 List<WsParamSetI> presets = service.getParamStore().getPresets();
240 if (presets != null && presets.size() > 0)
242 JMenu presetlist = new JMenu(MessageManager
243 .formatMessage("label.run_with_preset", new String[]
246 for (final WsParamSetI preset : presets)
248 final JMenuItem methodR = new JMenuItem(preset.getName());
249 methodR.setToolTipText(JvSwingUtils.wrapTooltip(true, "<strong>"
250 + (preset.isModifiable()
251 ? MessageManager.getString("label.user_preset")
253 .getString("label.service_preset"))
254 + "</strong><br/>" + preset.getDescription()));
255 methodR.addActionListener(new ActionListener()
258 public void actionPerformed(ActionEvent e)
260 new SequenceAnnotationWSClient(service,
266 presetlist.add(methodR);
268 wsmenu.add(presetlist);
274 annotservice = new JMenuItem(
275 MessageManager.getString("label.view_documentation"));
276 if (service != null && service.hasDocumentationUrl())
278 annotservice.addActionListener(new ActionListener()
282 public void actionPerformed(ActionEvent arg0)
284 Desktop.getInstance().showUrl(service.getDocumentationUrl());
287 annotservice.setToolTipText(
288 JvSwingUtils.wrapTooltip(true, MessageManager.formatMessage(
289 "label.view_service_doc_url", new String[]
290 { service.getDocumentationUrl(),
291 service.getDocumentationUrl() })));
292 wsmenu.add(annotservice);