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.*;
34 import jalview.util.MessageManager;
36 public class JPredClient extends WS1Client
39 * crate a new GUI JPred Job
46 * boolean - true - submit alignment as a sequence profile
52 public JPredClient(ext.vamsas.ServiceHandle sh, String title,
53 boolean msa, AlignmentView alview, AlignFrame parentFrame,
57 wsInfo = setWebService(sh);
58 startJPredClient(title, msa, alview, parentFrame, viewonly);
63 * startJPredClient TODO: refine submission to cope with local prediction of
64 * visible regions or multiple single sequence jobs TODO: sequence
65 * representative support - could submit alignment of representatives as msa.
66 * TODO: msa hidden region prediction - submit each chunk for prediction.
67 * concatenate results of each. TODO: single seq prediction - submit each
68 * contig of each sequence for prediction (but must cope with flanking regions
78 * if true then the prediction will be made just on the concatenated
81 private void startJPredClient(String title, boolean msa,
82 jalview.datamodel.AlignmentView alview, AlignFrame parentFrame,
85 AlignmentView input = alview;
88 wsInfo = setWebService();
90 Jpred server = locateWebService();
93 Cache.log.warn("Couldn't find a Jpred webservice to invoke!");
96 SeqCigar[] msf = null;
99 // original JNetClient behaviour - submit full length of sequence or profile
101 msf = input.getSequences();
102 seq = msf[0].getSeq('-');
106 delMap = alview.getVisibleContigMapFor(seq.gapMap());
108 if (msa && msf.length > 1)
111 String altitle = getPredictionName(WebServiceName) + " on "
112 + (viewonly ? "visible " : "") + seq.getName()
113 + " using alignment from " + title;
115 SequenceI aln[] = new SequenceI[msf.length];
116 for (int i = 0, j = msf.length; i < j; i++)
118 aln[i] = msf[i].getSeq('-');
121 Hashtable SequenceInfo = jalview.analysis.SeqsetUtils.uniquify(aln,
125 // Remove hidden regions from sequence objects.
126 String seqs[] = alview.getSequenceStrings('-');
127 for (int i = 0, j = msf.length; i < j; i++)
129 aln[i].setSequence(seqs[i]);
131 seq.setSequence(seqs[0]);
133 wsInfo.setProgressText("Job details for "
134 + (viewonly ? "visible " : "") + "MSA based prediction ("
135 + title + ") on sequence :\n>" + seq.getName() + "\n"
136 + AlignSeq.extractGaps("-. ", seq.getSequenceAsString())
138 JPredThread jthread = new JPredThread(wsInfo, altitle, server,
139 SequenceInfo, aln, delMap, alview, parentFrame, WsURL);
140 wsInfo.setthisService(jthread);
145 if (!msa && msf.length > 1)
147 throw new Error(MessageManager.getString("error.implementation_error_multiple_single_sequence_prediction_jobs_not_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 = MessageManager.getString("label.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 MessageManager.formatMessage("label.secondary_structure_prediction_service_couldnt_be_located", new String[]{WebServiceName,WsURL}),
315 MessageManager.getString("label.internal_jalview_error"),
316 JOptionPane.WARNING_MESSAGE);
317 wsInfo.setProgressText(MessageManager.formatMessage("label.secondary_structure_prediction_service_couldnt_be_located", new String[]{WebServiceName,WsURL})
320 wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_SERVERERROR);
327 public void attachWSMenuEntry(JMenu wsmenu, final ServiceHandle sh,
330 final JMenuItem method = new JMenuItem(sh.getName());
331 method.setToolTipText(sh.getEndpointURL());
332 method.addActionListener(new ActionListener()
334 public void actionPerformed(ActionEvent e)
336 AlignmentView msa = af.gatherSeqOrMsaForSecStrPrediction();
337 if (msa.getSequences().length == 1)
339 // Single Sequence prediction
340 new jalview.ws.jws1.JPredClient(sh, af.getTitle(), false, msa,
345 if (msa.getSequences().length > 1)
347 // Sequence profile based prediction
348 new jalview.ws.jws1.JPredClient(sh, af.getTitle(), true, msa,