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)
148 "Implementation Error! Multiple single sequence prediction jobs are not yet supported.");
151 String altitle = getPredictionName(WebServiceName) + " for "
152 + (viewonly ? "visible " : "") + "sequence " + seq.getName()
154 String seqname = seq.getName();
155 Hashtable SequenceInfo = jalview.analysis.SeqsetUtils
156 .SeqCharacterHash(seq);
159 // Remove hidden regions from input sequence
160 String seqs[] = alview.getSequenceStrings('-');
161 seq.setSequence(seqs[0]);
163 wsInfo.setProgressText("Job details for prediction on "
164 + (viewonly ? "visible " : "") + "sequence :\n>" + seqname
166 + AlignSeq.extractGaps("-. ", seq.getSequenceAsString())
168 JPredThread jthread = new JPredThread(wsInfo, altitle, server, WsURL,
169 SequenceInfo, seq, delMap, alview, parentFrame);
170 wsInfo.setthisService(jthread);
175 private String getPredictionName(String webServiceName)
177 if (webServiceName.toLowerCase().indexOf(
178 "secondary structure prediction") > -1)
180 return webServiceName;
184 return webServiceName + "secondary structure prediction";
188 public JPredClient(ext.vamsas.ServiceHandle sh, String title,
189 SequenceI seq, AlignFrame parentFrame)
192 wsInfo = setWebService(sh);
193 startJPredClient(title, seq, parentFrame);
196 public JPredClient(ext.vamsas.ServiceHandle sh, String title,
197 SequenceI[] msa, AlignFrame parentFrame)
199 wsInfo = setWebService(sh);
200 startJPredClient(title, msa, parentFrame);
203 public JPredClient(String title, SequenceI[] msf)
205 startJPredClient(title, msf, null);
208 public JPredClient(String title, SequenceI seq)
210 startJPredClient(title, seq, null);
217 // add a class reference to the list
220 private void startJPredClient(String title, SequenceI[] msf,
221 AlignFrame parentFrame)
225 wsInfo = setWebService();
228 SequenceI seq = msf[0];
230 String altitle = "JNet prediction on " + seq.getName()
231 + " using alignment from " + title;
233 wsInfo.setProgressText("Job details for MSA based prediction (" + title
234 + ") on sequence :\n>" + seq.getName() + "\n"
235 + AlignSeq.extractGaps("-. ", seq.getSequenceAsString()) + "\n");
236 SequenceI aln[] = new SequenceI[msf.length];
237 for (int i = 0, j = msf.length; i < j; i++)
239 aln[i] = new jalview.datamodel.Sequence(msf[i]);
242 Hashtable SequenceInfo = jalview.analysis.SeqsetUtils.uniquify(aln,
245 Jpred server = locateWebService();
251 JPredThread jthread = new JPredThread(wsInfo, altitle, server,
252 SequenceInfo, aln, null, null, parentFrame, WsURL);
253 wsInfo.setthisService(jthread);
257 public void startJPredClient(String title, SequenceI seq,
258 AlignFrame parentFrame)
262 wsInfo = setWebService();
264 wsInfo.setProgressText("Job details for prediction on sequence :\n>"
265 + seq.getName() + "\n"
266 + AlignSeq.extractGaps("-. ", seq.getSequenceAsString()) + "\n");
267 String altitle = "JNet prediction for sequence " + seq.getName()
270 Hashtable SequenceInfo = jalview.analysis.SeqsetUtils
271 .SeqCharacterHash(seq);
273 Jpred server = locateWebService();
279 JPredThread jthread = new JPredThread(wsInfo, altitle, server, WsURL,
280 SequenceInfo, seq, null, null, parentFrame);
281 wsInfo.setthisService(jthread);
285 private WebserviceInfo setWebService()
287 WebServiceName = "JNetWS";
288 WebServiceJobTitle = "JNet secondary structure prediction";
289 WebServiceReference = "\"Cuff J. A and Barton G.J (2000) Application of "
290 + "multiple sequence alignment profiles to improve protein secondary structure prediction, "
291 + "Proteins 40:502-511\".";
292 WsURL = "http://www.compbio.dundee.ac.uk/JalviewWS/services/jpred";
294 WebserviceInfo wsInfo = new WebserviceInfo(WebServiceJobTitle,
295 WebServiceReference);
300 private ext.vamsas.Jpred locateWebService()
302 ext.vamsas.JpredServiceLocator loc = new JpredServiceLocator(); // Default
303 ext.vamsas.Jpred server = null;
306 server = loc.getjpred(new java.net.URL(WsURL)); // JBPNote will be set
308 ((JpredSoapBindingStub) server).setTimeout(60000); // one minute stub
309 // ((JpredSoapBindingStub)this.server)._setProperty(org.apache.axis.encoding.C,
312 } catch (Exception ex)
314 JOptionPane.showMessageDialog(Desktop.desktop,
315 MessageManager.formatMessage("label.secondary_structure_prediction_service_couldnt_be_located", new String[]{WebServiceName,WsURL}),
316 MessageManager.getString("label.internal_jalview_error"),
317 JOptionPane.WARNING_MESSAGE);
318 wsInfo.setProgressText(MessageManager.formatMessage("label.secondary_structure_prediction_service_couldnt_be_located", new String[]{WebServiceName,WsURL})
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,