2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 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.awt.event.ActionEvent;
24 import java.awt.event.ActionListener;
30 import jalview.analysis.*;
32 import jalview.datamodel.*;
35 public class JPredClient extends WS1Client
38 * crate a new GUI JPred Job
45 * boolean - true - submit alignment as a sequence profile
51 public JPredClient(ext.vamsas.ServiceHandle sh, String title,
52 boolean msa, AlignmentView alview, AlignFrame parentFrame,
56 wsInfo = setWebService(sh);
57 startJPredClient(title, msa, alview, parentFrame, viewonly);
62 * startJPredClient TODO: refine submission to cope with local prediction of
63 * visible regions or multiple single sequence jobs TODO: sequence
64 * representative support - could submit alignment of representatives as msa.
65 * TODO: msa hidden region prediction - submit each chunk for prediction.
66 * concatenate results of each. TODO: single seq prediction - submit each
67 * contig of each sequence for prediction (but must cope with flanking regions
77 * if true then the prediction will be made just on the concatenated
80 private void startJPredClient(String title, boolean msa,
81 jalview.datamodel.AlignmentView alview, AlignFrame parentFrame,
84 AlignmentView input = alview;
87 wsInfo = setWebService();
89 Jpred server = locateWebService();
92 Cache.log.warn("Couldn't find a Jpred webservice to invoke!");
95 SeqCigar[] msf = null;
98 // original JNetClient behaviour - submit full length of sequence or profile
100 msf = input.getSequences();
101 seq = msf[0].getSeq('-');
105 delMap = alview.getVisibleContigMapFor(seq.gapMap());
107 if (msa && msf.length > 1)
110 String altitle = getPredictionName(WebServiceName) + " on "
111 + (viewonly ? "visible " : "") + seq.getName()
112 + " using alignment from " + title;
114 SequenceI aln[] = new SequenceI[msf.length];
115 for (int i = 0, j = msf.length; i < j; i++)
117 aln[i] = msf[i].getSeq('-');
120 Hashtable SequenceInfo = jalview.analysis.SeqsetUtils.uniquify(aln,
124 // Remove hidden regions from sequence objects.
125 String seqs[] = alview.getSequenceStrings('-');
126 for (int i = 0, j = msf.length; i < j; i++)
128 aln[i].setSequence(seqs[i]);
130 seq.setSequence(seqs[0]);
132 wsInfo.setProgressText("Job details for "
133 + (viewonly ? "visible " : "") + "MSA based prediction ("
134 + title + ") on sequence :\n>" + seq.getName() + "\n"
135 + AlignSeq.extractGaps("-. ", seq.getSequenceAsString())
137 JPredThread jthread = new JPredThread(wsInfo, altitle, server,
138 SequenceInfo, aln, delMap, alview, parentFrame, WsURL);
139 wsInfo.setthisService(jthread);
144 if (!msa && msf.length > 1)
147 "Implementation Error! Multiple single sequence prediction jobs are not yet supported.");
150 String altitle = getPredictionName(WebServiceName) + " for "
151 + (viewonly ? "visible " : "") + "sequence " + seq.getName()
153 String seqname = seq.getName();
154 Hashtable SequenceInfo = jalview.analysis.SeqsetUtils
155 .SeqCharacterHash(seq);
158 // Remove hidden regions from input sequence
159 String seqs[] = alview.getSequenceStrings('-');
160 seq.setSequence(seqs[0]);
162 wsInfo.setProgressText("Job details for prediction on "
163 + (viewonly ? "visible " : "") + "sequence :\n>" + seqname
165 + AlignSeq.extractGaps("-. ", seq.getSequenceAsString())
167 JPredThread jthread = new JPredThread(wsInfo, altitle, server, WsURL,
168 SequenceInfo, seq, delMap, alview, parentFrame);
169 wsInfo.setthisService(jthread);
174 private String getPredictionName(String webServiceName)
176 if (webServiceName.toLowerCase().indexOf(
177 "secondary structure prediction") > -1)
179 return webServiceName;
183 return webServiceName + "secondary structure prediction";
187 public JPredClient(ext.vamsas.ServiceHandle sh, String title,
188 SequenceI seq, AlignFrame parentFrame)
191 wsInfo = setWebService(sh);
192 startJPredClient(title, seq, parentFrame);
195 public JPredClient(ext.vamsas.ServiceHandle sh, String title,
196 SequenceI[] msa, AlignFrame parentFrame)
198 wsInfo = setWebService(sh);
199 startJPredClient(title, msa, parentFrame);
202 public JPredClient(String title, SequenceI[] msf)
204 startJPredClient(title, msf, null);
207 public JPredClient(String title, SequenceI seq)
209 startJPredClient(title, seq, null);
216 // add a class reference to the list
219 private void startJPredClient(String title, SequenceI[] msf,
220 AlignFrame parentFrame)
224 wsInfo = setWebService();
227 SequenceI seq = msf[0];
229 String altitle = "JNet prediction on " + seq.getName()
230 + " using alignment from " + title;
232 wsInfo.setProgressText("Job details for MSA based prediction (" + title
233 + ") on sequence :\n>" + seq.getName() + "\n"
234 + AlignSeq.extractGaps("-. ", seq.getSequenceAsString()) + "\n");
235 SequenceI aln[] = new SequenceI[msf.length];
236 for (int i = 0, j = msf.length; i < j; i++)
238 aln[i] = new jalview.datamodel.Sequence(msf[i]);
241 Hashtable SequenceInfo = jalview.analysis.SeqsetUtils.uniquify(aln,
244 Jpred server = locateWebService();
250 JPredThread jthread = new JPredThread(wsInfo, altitle, server,
251 SequenceInfo, aln, null, null, parentFrame, WsURL);
252 wsInfo.setthisService(jthread);
256 public void startJPredClient(String title, SequenceI seq,
257 AlignFrame parentFrame)
261 wsInfo = setWebService();
263 wsInfo.setProgressText("Job details for prediction on sequence :\n>"
264 + seq.getName() + "\n"
265 + AlignSeq.extractGaps("-. ", seq.getSequenceAsString()) + "\n");
266 String altitle = "JNet prediction for sequence " + seq.getName()
269 Hashtable SequenceInfo = jalview.analysis.SeqsetUtils
270 .SeqCharacterHash(seq);
272 Jpred server = locateWebService();
278 JPredThread jthread = new JPredThread(wsInfo, altitle, server, WsURL,
279 SequenceInfo, seq, null, null, parentFrame);
280 wsInfo.setthisService(jthread);
284 private WebserviceInfo setWebService()
286 WebServiceName = "JNetWS";
287 WebServiceJobTitle = "JNet secondary structure prediction";
288 WebServiceReference = "\"Cuff J. A and Barton G.J (2000) Application of "
289 + "multiple sequence alignment profiles to improve protein secondary structure prediction, "
290 + "Proteins 40:502-511\".";
291 WsURL = "http://www.compbio.dundee.ac.uk/JalviewWS/services/jpred";
293 WebserviceInfo wsInfo = new WebserviceInfo(WebServiceJobTitle,
294 WebServiceReference);
299 private ext.vamsas.Jpred locateWebService()
301 ext.vamsas.JpredServiceLocator loc = new JpredServiceLocator(); // Default
302 ext.vamsas.Jpred server = null;
305 server = loc.getjpred(new java.net.URL(WsURL)); // JBPNote will be set
307 ((JpredSoapBindingStub) server).setTimeout(60000); // one minute stub
308 // ((JpredSoapBindingStub)this.server)._setProperty(org.apache.axis.encoding.C,
311 } catch (Exception ex)
313 JOptionPane.showMessageDialog(Desktop.desktop,
314 "The Secondary Structure Prediction Service named "
315 + WebServiceName + " at " + WsURL
316 + " couldn't be located.", "Internal Jalview Error",
317 JOptionPane.WARNING_MESSAGE);
318 wsInfo.setProgressText("Serious! " + WebServiceName
319 + " Service location failed\nfor URL :" + WsURL + "\n"
321 wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_SERVERERROR);
328 public void attachWSMenuEntry(JMenu wsmenu, final ServiceHandle sh,
331 final JMenuItem method = new JMenuItem(sh.getName());
332 method.setToolTipText(sh.getEndpointURL());
333 method.addActionListener(new ActionListener()
335 public void actionPerformed(ActionEvent e)
337 AlignmentView msa = af.gatherSeqOrMsaForSecStrPrediction();
338 if (msa.getSequences().length == 1)
340 // Single Sequence prediction
341 new jalview.ws.jws1.JPredClient(sh, af.getTitle(), false, msa,
346 if (msa.getSequences().length > 1)
348 // Sequence profile based prediction
349 new jalview.ws.jws1.JPredClient(sh, af.getTitle(), true, msa,