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.jws1;
23 import java.util.Locale;
24 import jalview.analysis.AlignSeq;
25 import jalview.analysis.SeqsetUtils.SequenceInfo;
26 import jalview.bin.Console;
27 import jalview.datamodel.AlignmentView;
28 import jalview.datamodel.SeqCigar;
29 import jalview.datamodel.SequenceI;
30 import jalview.gui.AlignFrame;
31 import jalview.gui.Desktop;
32 import jalview.gui.JvOptionPane;
33 import jalview.gui.WebserviceInfo;
34 import jalview.util.MessageManager;
36 import java.awt.event.ActionEvent;
37 import java.awt.event.ActionListener;
38 import java.util.Hashtable;
41 import javax.swing.JMenu;
42 import javax.swing.JMenuItem;
44 import ext.vamsas.Jpred;
45 import ext.vamsas.JpredServiceLocator;
46 import ext.vamsas.JpredSoapBindingStub;
47 import ext.vamsas.ServiceHandle;
49 public class JPredClient extends WS1Client
52 * crate a new GUI JPred Job
59 * boolean - true - submit alignment as a sequence profile
65 public JPredClient(ext.vamsas.ServiceHandle sh, String title, boolean msa,
66 AlignmentView alview, AlignFrame parentFrame, boolean viewonly)
69 wsInfo = setWebService(sh);
70 startJPredClient(title, msa, alview, parentFrame, viewonly);
75 * startJPredClient TODO: refine submission to cope with local prediction of
76 * visible regions or multiple single sequence jobs TODO: sequence
77 * representative support - could submit alignment of representatives as msa.
78 * TODO: msa hidden region prediction - submit each chunk for prediction.
79 * concatenate results of each. TODO: single seq prediction - submit each
80 * contig of each sequence for prediction (but must cope with flanking regions
90 * if true then the prediction will be made just on the concatenated
93 private void startJPredClient(String title, boolean msa,
94 jalview.datamodel.AlignmentView alview, AlignFrame parentFrame,
97 AlignmentView input = alview;
100 wsInfo = setWebService();
102 Jpred server = locateWebService();
105 Console.warn("Couldn't find a Jpred webservice to invoke!");
108 SeqCigar[] msf = null;
109 SequenceI seq = null;
111 // original JNetClient behaviour - submit full length of sequence or profile
113 msf = input.getSequences();
114 seq = msf[0].getSeq('-');
118 delMap = alview.getVisibleContigMapFor(seq.gapMap());
120 if (msa && msf.length > 1)
123 String altitle = getPredictionName(WebServiceName) + " on "
124 + (viewonly ? "visible " : "") + seq.getName()
125 + " using alignment from " + title;
127 SequenceI aln[] = new SequenceI[msf.length];
128 for (int i = 0, j = msf.length; i < j; i++)
130 aln[i] = msf[i].getSeq('-');
133 Map<String, SequenceInfo> SequenceInfo =
134 jalview.analysis.SeqsetUtils.uniquify(aln, true);
137 // Remove hidden regions from sequence objects.
138 String seqs[] = alview.getSequenceStrings('-');
139 for (int i = 0, j = msf.length; i < j; i++)
141 aln[i].setSequence(seqs[i]);
143 seq.setSequence(seqs[0]);
145 wsInfo.setProgressText("Job details for "
146 + (viewonly ? "visible " : "") + "MSA based prediction ("
147 + title + ") on sequence :\n>" + seq.getName() + "\n"
148 + AlignSeq.extractGaps("-. ", seq.getSequenceAsString())
150 JPredThread jthread = new JPredThread(wsInfo, altitle, server,
151 SequenceInfo, aln, delMap, alview, parentFrame, WsURL);
152 wsInfo.setthisService(jthread);
157 if (!msa && msf.length > 1)
159 throw new Error(MessageManager.getString(
160 "error.implementation_error_multiple_single_sequence_prediction_jobs_not_supported"));
163 String altitle = getPredictionName(WebServiceName) + " for "
164 + (viewonly ? "visible " : "") + "sequence " + seq.getName()
166 String seqname = seq.getName();
167 SequenceInfo SequenceInfo = jalview.analysis.SeqsetUtils
168 .SeqCharacterHash(seq);
171 // Remove hidden regions from input sequence
172 String seqs[] = alview.getSequenceStrings('-');
173 seq.setSequence(seqs[0]);
175 wsInfo.setProgressText("Job details for prediction on "
176 + (viewonly ? "visible " : "") + "sequence :\n>" + seqname
178 + AlignSeq.extractGaps("-. ", seq.getSequenceAsString())
180 JPredThread jthread = new JPredThread(wsInfo, altitle, server, WsURL,
181 SequenceInfo, seq, delMap, alview, parentFrame);
182 wsInfo.setthisService(jthread);
187 private String getPredictionName(String webServiceName)
189 if (webServiceName.toLowerCase(Locale.ROOT)
190 .indexOf("secondary structure prediction") > -1)
192 return webServiceName;
196 return webServiceName + "secondary structure prediction";
200 public JPredClient(ext.vamsas.ServiceHandle sh, String title,
201 SequenceI seq, AlignFrame parentFrame)
204 wsInfo = setWebService(sh);
205 startJPredClient(title, seq, parentFrame);
208 public JPredClient(ext.vamsas.ServiceHandle sh, String title,
209 SequenceI[] msa, AlignFrame parentFrame)
211 wsInfo = setWebService(sh);
212 startJPredClient(title, msa, parentFrame);
215 public JPredClient(String title, SequenceI[] msf)
217 startJPredClient(title, msf, null);
220 public JPredClient(String title, SequenceI seq)
222 startJPredClient(title, seq, null);
229 // add a class reference to the list
232 private void startJPredClient(String title, SequenceI[] msf,
233 AlignFrame parentFrame)
237 wsInfo = setWebService();
240 SequenceI seq = msf[0];
242 String altitle = "JPred prediction on " + seq.getName()
243 + " using alignment from " + title;
245 wsInfo.setProgressText("Job details for MSA based prediction (" + title
246 + ") on sequence :\n>" + seq.getName() + "\n"
247 + AlignSeq.extractGaps("-. ", seq.getSequenceAsString())
249 SequenceI aln[] = new SequenceI[msf.length];
250 for (int i = 0, j = msf.length; i < j; i++)
252 aln[i] = new jalview.datamodel.Sequence(msf[i]);
255 Map<String, SequenceInfo> SequenceInfo =
256 jalview.analysis.SeqsetUtils.uniquify(aln, true);
258 Jpred server = locateWebService();
264 JPredThread jthread = new JPredThread(wsInfo, altitle, server,
265 SequenceInfo, aln, null, null, parentFrame, WsURL);
266 wsInfo.setthisService(jthread);
270 public void startJPredClient(String title, SequenceI seq,
271 AlignFrame parentFrame)
275 wsInfo = setWebService();
277 wsInfo.setProgressText("Job details for prediction on sequence :\n>"
278 + seq.getName() + "\n"
279 + AlignSeq.extractGaps("-. ", seq.getSequenceAsString())
281 String altitle = "JPred prediction for sequence " + seq.getName()
284 SequenceInfo SequenceInfo = jalview.analysis.SeqsetUtils
285 .SeqCharacterHash(seq);
287 Jpred server = locateWebService();
293 JPredThread jthread = new JPredThread(wsInfo, altitle, server, WsURL,
294 SequenceInfo, seq, null, null, parentFrame);
295 wsInfo.setthisService(jthread);
299 private WebserviceInfo setWebService()
301 WebServiceName = "JNetWS";
302 WebServiceJobTitle = MessageManager
303 .getString("label.jnet_secondary_structure_prediction");
304 WebServiceReference = "\"Cuff J. A and Barton G.J (2000) Application of "
305 + "multiple sequence alignment profiles to improve protein secondary structure prediction, "
306 + "Proteins 40:502-511\".";
307 WsURL = "http://www.compbio.dundee.ac.uk/JalviewWS/services/jpred";
309 WebserviceInfo wsInfo = new WebserviceInfo(WebServiceJobTitle,
310 WebServiceReference, Desktop.FRAME_MAKE_VISIBLE);
315 private ext.vamsas.Jpred locateWebService()
317 ext.vamsas.JpredServiceLocator loc = new JpredServiceLocator(); // Default
318 ext.vamsas.Jpred server = null;
321 server = loc.getjpred(new java.net.URL(WsURL)); // JBPNote will be set
323 ((JpredSoapBindingStub) server).setTimeout(60000); // one minute stub
324 // ((JpredSoapBindingStub)this.server)._setProperty(org.apache.axis.encoding.C,
327 } catch (Exception ex)
329 JvOptionPane.showMessageDialog(Desktop.getDesktopPane(),
330 MessageManager.formatMessage(
331 "label.secondary_structure_prediction_service_couldnt_be_located",
333 { WebServiceName, WsURL }),
334 MessageManager.getString("label.internal_jalview_error"),
335 JvOptionPane.WARNING_MESSAGE);
336 wsInfo.setProgressText(MessageManager.formatMessage(
337 "label.secondary_structure_prediction_service_couldnt_be_located",
339 { WebServiceName, WsURL }) + "\n" + ex.getMessage());
340 wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_SERVERERROR);
348 public void attachWSMenuEntry(JMenu wsmenu, final ServiceHandle sh,
351 final JMenuItem method = new JMenuItem(sh.getName());
352 method.setToolTipText(sh.getEndpointURL());
353 method.addActionListener(new ActionListener()
356 public void actionPerformed(ActionEvent e)
358 AlignmentView msa = af.gatherSeqOrMsaForSecStrPrediction();
359 if (msa.getSequences().length == 1)
361 // Single Sequence prediction
362 new jalview.ws.jws1.JPredClient(sh, af.getTitle(), false, msa, af,
367 if (msa.getSequences().length > 1)
369 // Sequence profile based prediction
370 new jalview.ws.jws1.JPredClient(sh, af.getTitle(), true, msa,