4 package jalview.ws.jws2;
6 import java.awt.event.ActionEvent;
7 import java.awt.event.ActionListener;
10 import javax.swing.JMenu;
11 import javax.swing.JMenuItem;
12 import javax.swing.JOptionPane;
14 import compbio.metadata.Argument;
16 import jalview.api.AlignCalcWorkerI;
17 import jalview.datamodel.AlignmentView;
18 import jalview.gui.AlignFrame;
19 import jalview.gui.Desktop;
20 import jalview.gui.JalviewDialog;
21 import jalview.gui.JvSwingUtils;
22 import jalview.ws.jws2.jabaws2.Jws2Instance;
23 import jalview.ws.params.WsParamSetI;
29 public class SequenceAnnotationWSClient extends Jws2Client
33 * initialise a client so its attachWSMenuEntry method can be called.
35 public SequenceAnnotationWSClient()
37 // TODO Auto-generated constructor stub
40 public SequenceAnnotationWSClient(final Jws2Instance sh,
41 AlignFrame alignFrame, WsParamSetI preset, boolean editParams)
43 super(alignFrame, preset, null);
44 if (alignFrame.getViewport().getAlignment().isNucleotide())
49 sh.serviceType+" can only be used\nfor amino acid alignments.",
50 "Wrong type of sequences!",
51 JOptionPane.WARNING_MESSAGE);
55 if (sh.action.toLowerCase().contains("conservation"))
57 // Build an AACons style client - take alignment, return annotation for columns
59 List<AlignCalcWorkerI> clnts = alignFrame.getViewport()
61 .getRegisteredWorkersOfClass(AAConsClient.class);
62 if (clnts == null || clnts.size() == 0)
64 if (!processParams(sh, editParams))
72 new AAConsClient(sh, alignFrame, preset, paramset));
76 AAConsClient worker = (AAConsClient) clnts.get(0);
79 paramset = worker.getArguments();
80 preset = worker.getPreset();
83 if (!processParams(sh, editParams, true))
85 // reinstate worker if it was blacklisted (might have happened due to
86 // invalid parameters)
87 alignFrame.getViewport().getCalcManager().workerMayRun(worker);
88 worker.updateParameters(preset, paramset);
92 if (sh.action.toLowerCase().contains("disorder"))
94 // build IUPred style client. take sequences, returns annotation per sequence.
95 if (!processParams(sh, editParams))
104 new AADisorderClient(sh, alignFrame, preset, paramset));
112 * @see jalview.ws.jws2.Jws2Client#attachWSMenuEntry(javax.swing.JMenu,
113 * jalview.ws.jws2.jabaws2.Jws2Instance, jalview.gui.AlignFrame)
115 public void attachWSMenuEntry(JMenu wsmenu, final Jws2Instance service,
116 final AlignFrame alignFrame)
118 boolean hasparams = service.hasParameters();
119 // Assume name ends in WS
120 String calcName = service.serviceType.substring(0,service.serviceType.length()-2);
122 JMenuItem aacons = new JMenuItem(calcName + " Defaults");
123 aacons.addActionListener(new ActionListener()
127 public void actionPerformed(ActionEvent e)
129 new SequenceAnnotationWSClient(service, alignFrame, null, false);
135 // only add these menu options if the service has user-modifiable
137 aacons = new JMenuItem("Edit settings and run ...");
138 aacons.setToolTipText("View and change parameters before running calculation");
140 aacons.addActionListener(new ActionListener()
142 public void actionPerformed(ActionEvent e)
144 new SequenceAnnotationWSClient(service, alignFrame, null, true);
148 List<WsParamSetI> presets = service.getParamStore().getPresets();
149 if (presets != null && presets.size() > 0)
151 JMenu presetlist = new JMenu("Run " + calcName + "with preset");
153 for (final WsParamSetI preset : presets)
155 final JMenuItem methodR = new JMenuItem(preset.getName());
156 methodR.setToolTipText("<html><p>"
157 + JvSwingUtils.wrapTooltip("<strong>"
158 + (preset.isModifiable() ? "User Preset"
159 : "Service Preset") + "</strong><br/>"
160 + preset.getDescription() + "</p>") + "</html>");
161 methodR.addActionListener(new ActionListener()
163 public void actionPerformed(ActionEvent e)
165 new SequenceAnnotationWSClient(service, alignFrame, preset,
170 presetlist.add(methodR);
172 wsmenu.add(presetlist);