2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
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 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/>.
17 * The Jalview Authors are detailed in the 'AUTHORS' file.
19 package jalview.ws.jws1;
21 import java.awt.event.ActionEvent;
22 import java.awt.event.ActionListener;
28 import jalview.analysis.*;
30 import jalview.datamodel.*;
33 public class JPredClient extends WS1Client
36 * crate a new GUI JPred Job
43 * boolean - true - submit alignment as a sequence profile
49 public JPredClient(ext.vamsas.ServiceHandle sh, String title,
50 boolean msa, AlignmentView alview, AlignFrame parentFrame,
54 wsInfo = setWebService(sh);
55 startJPredClient(title, msa, alview, parentFrame, viewonly);
60 * startJPredClient TODO: refine submission to cope with local prediction of
61 * visible regions or multiple single sequence jobs TODO: sequence
62 * representative support - could submit alignment of representatives as msa.
63 * TODO: msa hidden region prediction - submit each chunk for prediction.
64 * concatenate results of each. TODO: single seq prediction - submit each
65 * contig of each sequence for prediction (but must cope with flanking regions
75 * if true then the prediction will be made just on the concatenated
78 private void startJPredClient(String title, boolean msa,
79 jalview.datamodel.AlignmentView alview, AlignFrame parentFrame,
82 AlignmentView input = alview;
85 wsInfo = setWebService();
87 Jpred server = locateWebService();
90 Cache.log.warn("Couldn't find a Jpred webservice to invoke!");
93 SeqCigar[] msf = null;
96 // original JNetClient behaviour - submit full length of sequence or profile
98 msf = input.getSequences();
99 seq = msf[0].getSeq('-');
103 delMap = alview.getVisibleContigMapFor(seq.gapMap());
105 if (msa && msf.length > 1)
108 String altitle = getPredictionName(WebServiceName) + " on "
109 + (viewonly ? "visible " : "") + seq.getName()
110 + " using alignment from " + title;
112 SequenceI aln[] = new SequenceI[msf.length];
113 for (int i = 0, j = msf.length; i < j; i++)
115 aln[i] = msf[i].getSeq('-');
118 Hashtable SequenceInfo = jalview.analysis.SeqsetUtils.uniquify(aln,
122 // Remove hidden regions from sequence objects.
123 String seqs[] = alview.getSequenceStrings('-');
124 for (int i = 0, j = msf.length; i < j; i++)
126 aln[i].setSequence(seqs[i]);
128 seq.setSequence(seqs[0]);
130 wsInfo.setProgressText("Job details for "
131 + (viewonly ? "visible " : "") + "MSA based prediction ("
132 + title + ") on sequence :\n>" + seq.getName() + "\n"
133 + AlignSeq.extractGaps("-. ", seq.getSequenceAsString())
135 JPredThread jthread = new JPredThread(wsInfo, altitle, server,
136 SequenceInfo, aln, delMap, alview, parentFrame, WsURL);
137 wsInfo.setthisService(jthread);
142 if (!msa && msf.length > 1)
145 "Implementation Error! Multiple single sequence prediction jobs are not yet supported.");
148 String altitle = getPredictionName(WebServiceName) + " for "
149 + (viewonly ? "visible " : "") + "sequence " + seq.getName()
151 String seqname = seq.getName();
152 Hashtable SequenceInfo = jalview.analysis.SeqsetUtils
153 .SeqCharacterHash(seq);
156 // Remove hidden regions from input sequence
157 String seqs[] = alview.getSequenceStrings('-');
158 seq.setSequence(seqs[0]);
160 wsInfo.setProgressText("Job details for prediction on "
161 + (viewonly ? "visible " : "") + "sequence :\n>" + seqname
163 + AlignSeq.extractGaps("-. ", seq.getSequenceAsString())
165 JPredThread jthread = new JPredThread(wsInfo, altitle, server, WsURL,
166 SequenceInfo, seq, delMap, alview, parentFrame);
167 wsInfo.setthisService(jthread);
172 private String getPredictionName(String webServiceName)
174 if (webServiceName.toLowerCase().indexOf(
175 "secondary structure prediction") > -1)
177 return webServiceName;
181 return webServiceName + "secondary structure prediction";
185 public JPredClient(ext.vamsas.ServiceHandle sh, String title,
186 SequenceI seq, AlignFrame parentFrame)
189 wsInfo = setWebService(sh);
190 startJPredClient(title, seq, parentFrame);
193 public JPredClient(ext.vamsas.ServiceHandle sh, String title,
194 SequenceI[] msa, AlignFrame parentFrame)
196 wsInfo = setWebService(sh);
197 startJPredClient(title, msa, parentFrame);
200 public JPredClient(String title, SequenceI[] msf)
202 startJPredClient(title, msf, null);
205 public JPredClient(String title, SequenceI seq)
207 startJPredClient(title, seq, null);
214 // add a class reference to the list
217 private void startJPredClient(String title, SequenceI[] msf,
218 AlignFrame parentFrame)
222 wsInfo = setWebService();
225 SequenceI seq = msf[0];
227 String altitle = "JNet prediction on " + seq.getName()
228 + " using alignment from " + title;
230 wsInfo.setProgressText("Job details for MSA based prediction (" + title
231 + ") on sequence :\n>" + seq.getName() + "\n"
232 + AlignSeq.extractGaps("-. ", seq.getSequenceAsString()) + "\n");
233 SequenceI aln[] = new SequenceI[msf.length];
234 for (int i = 0, j = msf.length; i < j; i++)
236 aln[i] = new jalview.datamodel.Sequence(msf[i]);
239 Hashtable SequenceInfo = jalview.analysis.SeqsetUtils.uniquify(aln,
242 Jpred server = locateWebService();
248 JPredThread jthread = new JPredThread(wsInfo, altitle, server,
249 SequenceInfo, aln, null, null, parentFrame, WsURL);
250 wsInfo.setthisService(jthread);
254 public void startJPredClient(String title, SequenceI seq,
255 AlignFrame parentFrame)
259 wsInfo = setWebService();
261 wsInfo.setProgressText("Job details for prediction on sequence :\n>"
262 + seq.getName() + "\n"
263 + AlignSeq.extractGaps("-. ", seq.getSequenceAsString()) + "\n");
264 String altitle = "JNet prediction for sequence " + seq.getName()
267 Hashtable SequenceInfo = jalview.analysis.SeqsetUtils
268 .SeqCharacterHash(seq);
270 Jpred server = locateWebService();
276 JPredThread jthread = new JPredThread(wsInfo, altitle, server, WsURL,
277 SequenceInfo, seq, null, null, parentFrame);
278 wsInfo.setthisService(jthread);
282 private WebserviceInfo setWebService()
284 WebServiceName = "JNetWS";
285 WebServiceJobTitle = "JNet secondary structure prediction";
286 WebServiceReference = "\"Cuff J. A and Barton G.J (2000) Application of "
287 + "multiple sequence alignment profiles to improve protein secondary structure prediction, "
288 + "Proteins 40:502-511\".";
289 WsURL = "http://www.compbio.dundee.ac.uk/JalviewWS/services/jpred";
291 WebserviceInfo wsInfo = new WebserviceInfo(WebServiceJobTitle,
292 WebServiceReference);
297 private ext.vamsas.Jpred locateWebService()
299 ext.vamsas.JpredServiceLocator loc = new JpredServiceLocator(); // Default
300 ext.vamsas.Jpred server = null;
303 server = loc.getjpred(new java.net.URL(WsURL)); // JBPNote will be set
305 ((JpredSoapBindingStub) server).setTimeout(60000); // one minute stub
306 // ((JpredSoapBindingStub)this.server)._setProperty(org.apache.axis.encoding.C,
309 } catch (Exception ex)
311 JOptionPane.showMessageDialog(Desktop.desktop,
312 "The Secondary Structure Prediction Service named "
313 + WebServiceName + " at " + WsURL
314 + " couldn't be located.", "Internal Jalview Error",
315 JOptionPane.WARNING_MESSAGE);
316 wsInfo.setProgressText("Serious! " + WebServiceName
317 + " Service location failed\nfor URL :" + WsURL + "\n"
319 wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_SERVERERROR);
326 public void attachWSMenuEntry(JMenu wsmenu, final ServiceHandle sh,
329 final JMenuItem method = new JMenuItem(sh.getName());
330 method.setToolTipText(sh.getEndpointURL());
331 method.addActionListener(new ActionListener()
333 public void actionPerformed(ActionEvent e)
335 AlignmentView msa = af.gatherSeqOrMsaForSecStrPrediction();
336 if (msa.getSequences().length == 1)
338 // Single Sequence prediction
339 new jalview.ws.jws1.JPredClient(sh, af.getTitle(), false, msa,
344 if (msa.getSequences().length > 1)
346 // Sequence profile based prediction
347 new jalview.ws.jws1.JPredClient(sh, af.getTitle(), true, msa,