2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ 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 jalview.analysis.AlignSeq;
24 import jalview.bin.Cache;
25 import jalview.datamodel.AlignmentView;
26 import jalview.datamodel.SeqCigar;
27 import jalview.datamodel.SequenceI;
28 import jalview.gui.AlignFrame;
29 import jalview.gui.Desktop;
30 import jalview.gui.JvOptionPane;
31 import jalview.gui.WebserviceInfo;
32 import jalview.util.MessageManager;
34 import java.awt.event.ActionEvent;
35 import java.awt.event.ActionListener;
36 import java.util.Hashtable;
38 import javax.swing.JMenu;
39 import javax.swing.JMenuItem;
41 import ext.vamsas.Jpred;
42 import ext.vamsas.JpredServiceLocator;
43 import ext.vamsas.JpredSoapBindingStub;
44 import ext.vamsas.ServiceHandle;
46 public class JPredClient extends WS1Client
49 * crate a new GUI JPred Job
56 * boolean - true - submit alignment as a sequence profile
62 public JPredClient(ext.vamsas.ServiceHandle sh, String title, boolean msa,
63 AlignmentView alview, AlignFrame parentFrame, boolean viewonly)
66 wsInfo = setWebService(sh);
67 startJPredClient(title, msa, alview, parentFrame, viewonly);
72 * startJPredClient TODO: refine submission to cope with local prediction of
73 * visible regions or multiple single sequence jobs TODO: sequence
74 * representative support - could submit alignment of representatives as msa.
75 * TODO: msa hidden region prediction - submit each chunk for prediction.
76 * concatenate results of each. TODO: single seq prediction - submit each
77 * contig of each sequence for prediction (but must cope with flanking regions
87 * if true then the prediction will be made just on the concatenated
90 private void startJPredClient(String title, boolean msa,
91 jalview.datamodel.AlignmentView alview, AlignFrame parentFrame,
94 AlignmentView input = alview;
97 wsInfo = setWebService();
99 Jpred server = locateWebService();
102 Cache.log.warn("Couldn't find a Jpred webservice to invoke!");
105 SeqCigar[] msf = null;
106 SequenceI seq = null;
108 // original JNetClient behaviour - submit full length of sequence or profile
110 msf = input.getSequences();
111 seq = msf[0].getSeq('-');
115 delMap = alview.getVisibleContigMapFor(seq.gapMap());
117 if (msa && msf.length > 1)
120 String altitle = getPredictionName(WebServiceName) + " on "
121 + (viewonly ? "visible " : "") + seq.getName()
122 + " using alignment from " + title;
124 SequenceI aln[] = new SequenceI[msf.length];
125 for (int i = 0, j = msf.length; i < j; i++)
127 aln[i] = msf[i].getSeq('-');
130 Hashtable SequenceInfo = jalview.analysis.SeqsetUtils.uniquify(aln,
134 // Remove hidden regions from sequence objects.
135 String seqs[] = alview.getSequenceStrings('-');
136 for (int i = 0, j = msf.length; i < j; i++)
138 aln[i].setSequence(seqs[i]);
140 seq.setSequence(seqs[0]);
142 wsInfo.setProgressText("Job details for "
143 + (viewonly ? "visible " : "") + "MSA based prediction ("
144 + title + ") on sequence :\n>" + seq.getName() + "\n"
145 + AlignSeq.extractGaps("-. ", seq.getSequenceAsString())
147 JPredThread jthread = new JPredThread(wsInfo, altitle, server,
148 SequenceInfo, aln, delMap, alview, parentFrame, WsURL);
149 wsInfo.setthisService(jthread);
154 if (!msa && msf.length > 1)
156 throw new Error(MessageManager.getString(
157 "error.implementation_error_multiple_single_sequence_prediction_jobs_not_supported"));
160 String altitle = getPredictionName(WebServiceName) + " for "
161 + (viewonly ? "visible " : "") + "sequence " + seq.getName()
163 String seqname = seq.getName();
164 Hashtable SequenceInfo = jalview.analysis.SeqsetUtils
165 .SeqCharacterHash(seq);
168 // Remove hidden regions from input sequence
169 String seqs[] = alview.getSequenceStrings('-');
170 seq.setSequence(seqs[0]);
172 wsInfo.setProgressText("Job details for prediction on "
173 + (viewonly ? "visible " : "") + "sequence :\n>" + seqname
175 + AlignSeq.extractGaps("-. ", seq.getSequenceAsString())
177 JPredThread jthread = new JPredThread(wsInfo, altitle, server, WsURL,
178 SequenceInfo, seq, delMap, alview, parentFrame);
179 wsInfo.setthisService(jthread);
184 private String getPredictionName(String webServiceName)
186 if (webServiceName.toLowerCase()
187 .indexOf("secondary structure prediction") > -1)
189 return webServiceName;
193 return webServiceName + "secondary structure prediction";
197 public JPredClient(ext.vamsas.ServiceHandle sh, String title,
198 SequenceI seq, AlignFrame parentFrame)
201 wsInfo = setWebService(sh);
202 startJPredClient(title, seq, parentFrame);
205 public JPredClient(ext.vamsas.ServiceHandle sh, String title,
206 SequenceI[] msa, AlignFrame parentFrame)
208 wsInfo = setWebService(sh);
209 startJPredClient(title, msa, parentFrame);
212 public JPredClient(String title, SequenceI[] msf)
214 startJPredClient(title, msf, null);
217 public JPredClient(String title, SequenceI seq)
219 startJPredClient(title, seq, null);
226 // add a class reference to the list
229 private void startJPredClient(String title, SequenceI[] msf,
230 AlignFrame parentFrame)
234 wsInfo = setWebService();
237 SequenceI seq = msf[0];
239 String altitle = "JPred prediction on " + seq.getName()
240 + " using alignment from " + title;
242 wsInfo.setProgressText("Job details for MSA based prediction (" + title
243 + ") on sequence :\n>" + seq.getName() + "\n"
244 + AlignSeq.extractGaps("-. ", seq.getSequenceAsString())
246 SequenceI aln[] = new SequenceI[msf.length];
247 for (int i = 0, j = msf.length; i < j; i++)
249 aln[i] = new jalview.datamodel.Sequence(msf[i]);
252 Hashtable SequenceInfo = jalview.analysis.SeqsetUtils.uniquify(aln,
255 Jpred server = locateWebService();
261 JPredThread jthread = new JPredThread(wsInfo, altitle, server,
262 SequenceInfo, aln, null, null, parentFrame, WsURL);
263 wsInfo.setthisService(jthread);
267 public void startJPredClient(String title, SequenceI seq,
268 AlignFrame parentFrame)
272 wsInfo = setWebService();
274 wsInfo.setProgressText("Job details for prediction on sequence :\n>"
275 + seq.getName() + "\n"
276 + AlignSeq.extractGaps("-. ", seq.getSequenceAsString())
278 String altitle = "JPred prediction for sequence " + seq.getName()
281 Hashtable SequenceInfo = jalview.analysis.SeqsetUtils
282 .SeqCharacterHash(seq);
284 Jpred server = locateWebService();
290 JPredThread jthread = new JPredThread(wsInfo, altitle, server, WsURL,
291 SequenceInfo, seq, null, null, parentFrame);
292 wsInfo.setthisService(jthread);
296 private WebserviceInfo setWebService()
298 WebServiceName = "JNetWS";
299 WebServiceJobTitle = MessageManager
300 .getString("label.jnet_secondary_structure_prediction");
301 WebServiceReference = "\"Cuff J. A and Barton G.J (2000) Application of "
302 + "multiple sequence alignment profiles to improve protein secondary structure prediction, "
303 + "Proteins 40:502-511\".";
304 WsURL = "http://www.compbio.dundee.ac.uk/JalviewWS/services/jpred";
306 WebserviceInfo wsInfo = new WebserviceInfo(WebServiceJobTitle,
307 WebServiceReference, true);
312 private ext.vamsas.Jpred locateWebService()
314 ext.vamsas.JpredServiceLocator loc = new JpredServiceLocator(); // Default
315 ext.vamsas.Jpred server = null;
318 server = loc.getjpred(new java.net.URL(WsURL)); // JBPNote will be set
320 ((JpredSoapBindingStub) server).setTimeout(60000); // one minute stub
321 // ((JpredSoapBindingStub)this.server)._setProperty(org.apache.axis.encoding.C,
324 } catch (Exception ex)
326 JvOptionPane.showMessageDialog(Desktop.desktop,
327 MessageManager.formatMessage(
328 "label.secondary_structure_prediction_service_couldnt_be_located",
330 { WebServiceName, WsURL }),
331 MessageManager.getString("label.internal_jalview_error"),
332 JvOptionPane.WARNING_MESSAGE);
333 wsInfo.setProgressText(MessageManager.formatMessage(
334 "label.secondary_structure_prediction_service_couldnt_be_located",
336 { WebServiceName, WsURL }) + "\n" + ex.getMessage());
337 wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_SERVERERROR);
345 public void attachWSMenuEntry(JMenu wsmenu, final ServiceHandle sh,
348 final JMenuItem method = new JMenuItem(sh.getName());
349 method.setToolTipText(sh.getEndpointURL());
350 method.addActionListener(new ActionListener()
353 public void actionPerformed(ActionEvent e)
355 AlignmentView msa = af.gatherSeqOrMsaForSecStrPrediction();
356 if (msa.getSequences().length == 1)
358 // Single Sequence prediction
359 new jalview.ws.jws1.JPredClient(sh, af.getTitle(), false, msa, af,
364 if (msa.getSequences().length > 1)
366 // Sequence profile based prediction
367 new jalview.ws.jws1.JPredClient(sh, af.getTitle(), true, msa,