2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
3 * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
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 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
18 package jalview.ws.jws1;
20 import java.awt.event.ActionEvent;
21 import java.awt.event.ActionListener;
27 import jalview.analysis.*;
29 import jalview.datamodel.*;
32 public class JPredClient extends WS1Client
35 * crate a new GUI JPred Job
42 * boolean - true - submit alignment as a sequence profile
48 public JPredClient(ext.vamsas.ServiceHandle sh, String title,
49 boolean msa, AlignmentView alview, AlignFrame parentFrame,
53 wsInfo = setWebService(sh);
54 startJPredClient(title, msa, alview, parentFrame, viewonly);
59 * startJPredClient TODO: refine submission to cope with local prediction of
60 * visible regions or multiple single sequence jobs TODO: sequence
61 * representative support - could submit alignment of representatives as msa.
62 * TODO: msa hidden region prediction - submit each chunk for prediction.
63 * concatenate results of each. TODO: single seq prediction - submit each
64 * contig of each sequence for prediction (but must cope with flanking regions
74 * if true then the prediction will be made just on the concatenated
77 private void startJPredClient(String title, boolean msa,
78 jalview.datamodel.AlignmentView alview, AlignFrame parentFrame,
81 AlignmentView input = alview;
84 wsInfo = setWebService();
86 Jpred server = locateWebService();
89 Cache.log.warn("Couldn't find a Jpred webservice to invoke!");
92 SeqCigar[] msf = null;
95 // original JNetClient behaviour - submit full length of sequence or profile
97 msf = input.getSequences();
98 seq = msf[0].getSeq('-');
102 delMap = alview.getVisibleContigMapFor(seq.gapMap());
104 if (msa && msf.length > 1)
107 String altitle = getPredictionName(WebServiceName) + " on "
108 + (viewonly ? "visible " : "") + seq.getName()
109 + " using alignment from " + title;
111 SequenceI aln[] = new SequenceI[msf.length];
112 for (int i = 0, j = msf.length; i < j; i++)
114 aln[i] = msf[i].getSeq('-');
117 Hashtable SequenceInfo = jalview.analysis.SeqsetUtils.uniquify(aln,
121 // Remove hidden regions from sequence objects.
122 String seqs[] = alview.getSequenceStrings('-');
123 for (int i = 0, j = msf.length; i < j; i++)
125 aln[i].setSequence(seqs[i]);
127 seq.setSequence(seqs[0]);
129 wsInfo.setProgressText("Job details for "
130 + (viewonly ? "visible " : "") + "MSA based prediction ("
131 + title + ") on sequence :\n>" + seq.getName() + "\n"
132 + AlignSeq.extractGaps("-. ", seq.getSequenceAsString())
134 JPredThread jthread = new JPredThread(wsInfo, altitle, server,
135 SequenceInfo, aln, delMap, alview, parentFrame, WsURL);
136 wsInfo.setthisService(jthread);
141 if (!msa && msf.length > 1)
144 "Implementation Error! Multiple single sequence prediction jobs are not yet supported.");
147 String altitle = getPredictionName(WebServiceName) + " for "
148 + (viewonly ? "visible " : "") + "sequence " + seq.getName()
150 String seqname = seq.getName();
151 Hashtable SequenceInfo = jalview.analysis.SeqsetUtils
152 .SeqCharacterHash(seq);
155 // Remove hidden regions from input sequence
156 String seqs[] = alview.getSequenceStrings('-');
157 seq.setSequence(seqs[0]);
159 wsInfo.setProgressText("Job details for prediction on "
160 + (viewonly ? "visible " : "") + "sequence :\n>" + seqname
162 + AlignSeq.extractGaps("-. ", seq.getSequenceAsString())
164 JPredThread jthread = new JPredThread(wsInfo, altitle, server, WsURL,
165 SequenceInfo, seq, delMap, alview, parentFrame);
166 wsInfo.setthisService(jthread);
171 private String getPredictionName(String webServiceName)
173 if (webServiceName.toLowerCase().indexOf(
174 "secondary structure prediction") > -1)
176 return webServiceName;
180 return webServiceName + "secondary structure prediction";
184 public JPredClient(ext.vamsas.ServiceHandle sh, String title,
185 SequenceI seq, AlignFrame parentFrame)
188 wsInfo = setWebService(sh);
189 startJPredClient(title, seq, parentFrame);
192 public JPredClient(ext.vamsas.ServiceHandle sh, String title,
193 SequenceI[] msa, AlignFrame parentFrame)
195 wsInfo = setWebService(sh);
196 startJPredClient(title, msa, parentFrame);
199 public JPredClient(String title, SequenceI[] msf)
201 startJPredClient(title, msf, null);
204 public JPredClient(String title, SequenceI seq)
206 startJPredClient(title, seq, null);
213 // add a class reference to the list
216 private void startJPredClient(String title, SequenceI[] msf,
217 AlignFrame parentFrame)
221 wsInfo = setWebService();
224 SequenceI seq = msf[0];
226 String altitle = "JNet prediction on " + seq.getName()
227 + " using alignment from " + title;
229 wsInfo.setProgressText("Job details for MSA based prediction (" + title
230 + ") on sequence :\n>" + seq.getName() + "\n"
231 + AlignSeq.extractGaps("-. ", seq.getSequenceAsString()) + "\n");
232 SequenceI aln[] = new SequenceI[msf.length];
233 for (int i = 0, j = msf.length; i < j; i++)
235 aln[i] = new jalview.datamodel.Sequence(msf[i]);
238 Hashtable SequenceInfo = jalview.analysis.SeqsetUtils.uniquify(aln,
241 Jpred server = locateWebService();
247 JPredThread jthread = new JPredThread(wsInfo, altitle, server,
248 SequenceInfo, aln, null, null, parentFrame, WsURL);
249 wsInfo.setthisService(jthread);
253 public void startJPredClient(String title, SequenceI seq,
254 AlignFrame parentFrame)
258 wsInfo = setWebService();
260 wsInfo.setProgressText("Job details for prediction on sequence :\n>"
261 + seq.getName() + "\n"
262 + AlignSeq.extractGaps("-. ", seq.getSequenceAsString()) + "\n");
263 String altitle = "JNet prediction for sequence " + seq.getName()
266 Hashtable SequenceInfo = jalview.analysis.SeqsetUtils
267 .SeqCharacterHash(seq);
269 Jpred server = locateWebService();
275 JPredThread jthread = new JPredThread(wsInfo, altitle, server, WsURL,
276 SequenceInfo, seq, null, null, parentFrame);
277 wsInfo.setthisService(jthread);
281 private WebserviceInfo setWebService()
283 WebServiceName = "JNetWS";
284 WebServiceJobTitle = "JNet secondary structure prediction";
285 WebServiceReference = "\"Cuff J. A and Barton G.J (2000) Application of "
286 + "multiple sequence alignment profiles to improve protein secondary structure prediction, "
287 + "Proteins 40:502-511\".";
288 WsURL = "http://www.compbio.dundee.ac.uk/JalviewWS/services/jpred";
290 WebserviceInfo wsInfo = new WebserviceInfo(WebServiceJobTitle,
291 WebServiceReference);
296 private ext.vamsas.Jpred locateWebService()
298 ext.vamsas.JpredServiceLocator loc = new JpredServiceLocator(); // Default
299 ext.vamsas.Jpred server = null;
302 server = loc.getjpred(new java.net.URL(WsURL)); // JBPNote will be set
304 ((JpredSoapBindingStub) server).setTimeout(60000); // one minute stub
305 // ((JpredSoapBindingStub)this.server)._setProperty(org.apache.axis.encoding.C,
308 } catch (Exception ex)
310 JOptionPane.showMessageDialog(Desktop.desktop,
311 "The Secondary Structure Prediction Service named "
312 + WebServiceName + " at " + WsURL
313 + " couldn't be located.", "Internal Jalview Error",
314 JOptionPane.WARNING_MESSAGE);
315 wsInfo.setProgressText("Serious! " + WebServiceName
316 + " Service location failed\nfor URL :" + WsURL + "\n"
318 wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_SERVERERROR);
325 public void attachWSMenuEntry(JMenu wsmenu, final ServiceHandle sh,
328 final JMenuItem method = new JMenuItem(sh.getName());
329 method.setToolTipText(sh.getEndpointURL());
330 method.addActionListener(new ActionListener()
332 public void actionPerformed(ActionEvent e)
334 AlignmentView msa = af.gatherSeqOrMsaForSecStrPrediction();
335 if (msa.getSequences().length == 1)
337 // Single Sequence prediction
338 new jalview.ws.jws1.JPredClient(sh, af.getTitle(), false, msa,
343 if (msa.getSequences().length > 1)
345 // Sequence profile based prediction
346 new jalview.ws.jws1.JPredClient(sh, af.getTitle(), true, msa,