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.WebserviceInfo;
31 import jalview.util.MessageManager;
33 import java.awt.event.ActionEvent;
34 import java.awt.event.ActionListener;
35 import java.util.Hashtable;
37 import javax.swing.JMenu;
38 import javax.swing.JMenuItem;
39 import javax.swing.JOptionPane;
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,
63 boolean msa, AlignmentView alview, AlignFrame parentFrame,
67 wsInfo = setWebService(sh);
68 startJPredClient(title, msa, alview, parentFrame, viewonly);
73 * startJPredClient TODO: refine submission to cope with local prediction of
74 * visible regions or multiple single sequence jobs TODO: sequence
75 * representative support - could submit alignment of representatives as msa.
76 * TODO: msa hidden region prediction - submit each chunk for prediction.
77 * concatenate results of each. TODO: single seq prediction - submit each
78 * contig of each sequence for prediction (but must cope with flanking regions
88 * if true then the prediction will be made just on the concatenated
91 private void startJPredClient(String title, boolean msa,
92 jalview.datamodel.AlignmentView alview, AlignFrame parentFrame,
95 AlignmentView input = alview;
98 wsInfo = setWebService();
100 Jpred server = locateWebService();
103 Cache.log.warn("Couldn't find a Jpred webservice to invoke!");
106 SeqCigar[] msf = null;
107 SequenceI seq = null;
109 // original JNetClient behaviour - submit full length of sequence or profile
111 msf = input.getSequences();
112 seq = msf[0].getSeq('-');
116 delMap = alview.getVisibleContigMapFor(seq.gapMap());
118 if (msa && msf.length > 1)
121 String altitle = getPredictionName(WebServiceName) + " on "
122 + (viewonly ? "visible " : "") + seq.getName()
123 + " using alignment from " + title;
125 SequenceI aln[] = new SequenceI[msf.length];
126 for (int i = 0, j = msf.length; i < j; i++)
128 aln[i] = msf[i].getSeq('-');
131 Hashtable SequenceInfo = jalview.analysis.SeqsetUtils.uniquify(aln,
135 // Remove hidden regions from sequence objects.
136 String seqs[] = alview.getSequenceStrings('-');
137 for (int i = 0, j = msf.length; i < j; i++)
139 aln[i].setSequence(seqs[i]);
141 seq.setSequence(seqs[0]);
143 wsInfo.setProgressText("Job details for "
144 + (viewonly ? "visible " : "") + "MSA based prediction ("
145 + title + ") on sequence :\n>" + seq.getName() + "\n"
146 + AlignSeq.extractGaps("-. ", seq.getSequenceAsString())
148 JPredThread jthread = new JPredThread(wsInfo, altitle, server,
149 SequenceInfo, aln, delMap, alview, parentFrame, WsURL);
150 wsInfo.setthisService(jthread);
155 if (!msa && msf.length > 1)
159 .getString("error.implementation_error_multiple_single_sequence_prediction_jobs_not_supported"));
162 String altitle = getPredictionName(WebServiceName) + " for "
163 + (viewonly ? "visible " : "") + "sequence " + seq.getName()
165 String seqname = seq.getName();
166 Hashtable SequenceInfo = jalview.analysis.SeqsetUtils
167 .SeqCharacterHash(seq);
170 // Remove hidden regions from input sequence
171 String seqs[] = alview.getSequenceStrings('-');
172 seq.setSequence(seqs[0]);
174 wsInfo.setProgressText("Job details for prediction on "
175 + (viewonly ? "visible " : "") + "sequence :\n>" + seqname
177 + AlignSeq.extractGaps("-. ", seq.getSequenceAsString())
179 JPredThread jthread = new JPredThread(wsInfo, altitle, server, WsURL,
180 SequenceInfo, seq, delMap, alview, parentFrame);
181 wsInfo.setthisService(jthread);
186 private String getPredictionName(String webServiceName)
188 if (webServiceName.toLowerCase().indexOf(
189 "secondary structure prediction") > -1)
191 return webServiceName;
195 return webServiceName + "secondary structure prediction";
199 public JPredClient(ext.vamsas.ServiceHandle sh, String title,
200 SequenceI seq, AlignFrame parentFrame)
203 wsInfo = setWebService(sh);
204 startJPredClient(title, seq, parentFrame);
207 public JPredClient(ext.vamsas.ServiceHandle sh, String title,
208 SequenceI[] msa, AlignFrame parentFrame)
210 wsInfo = setWebService(sh);
211 startJPredClient(title, msa, parentFrame);
214 public JPredClient(String title, SequenceI[] msf)
216 startJPredClient(title, msf, null);
219 public JPredClient(String title, SequenceI seq)
221 startJPredClient(title, seq, null);
228 // add a class reference to the list
231 private void startJPredClient(String title, SequenceI[] msf,
232 AlignFrame parentFrame)
236 wsInfo = setWebService();
239 SequenceI seq = msf[0];
241 String altitle = "JNet prediction on " + seq.getName()
242 + " using alignment from " + title;
244 wsInfo.setProgressText("Job details for MSA based prediction (" + title
245 + ") on sequence :\n>" + seq.getName() + "\n"
246 + AlignSeq.extractGaps("-. ", seq.getSequenceAsString()) + "\n");
247 SequenceI aln[] = new SequenceI[msf.length];
248 for (int i = 0, j = msf.length; i < j; i++)
250 aln[i] = new jalview.datamodel.Sequence(msf[i]);
253 Hashtable SequenceInfo = jalview.analysis.SeqsetUtils.uniquify(aln,
256 Jpred server = locateWebService();
262 JPredThread jthread = new JPredThread(wsInfo, altitle, server,
263 SequenceInfo, aln, null, null, parentFrame, WsURL);
264 wsInfo.setthisService(jthread);
268 public void startJPredClient(String title, SequenceI seq,
269 AlignFrame parentFrame)
273 wsInfo = setWebService();
275 wsInfo.setProgressText("Job details for prediction on sequence :\n>"
276 + seq.getName() + "\n"
277 + AlignSeq.extractGaps("-. ", seq.getSequenceAsString()) + "\n");
278 String altitle = "JNet 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)
331 "label.secondary_structure_prediction_service_couldnt_be_located",
332 new String[] { WebServiceName, WsURL }),
334 .getString("label.internal_jalview_error"),
335 JOptionPane.WARNING_MESSAGE);
336 wsInfo.setProgressText(MessageManager
338 "label.secondary_structure_prediction_service_couldnt_be_located",
339 new String[] { WebServiceName, WsURL })
340 + "\n" + ex.getMessage());
341 wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_SERVERERROR);
348 public void attachWSMenuEntry(JMenu wsmenu, final ServiceHandle sh,
351 final JMenuItem method = new JMenuItem(sh.getName());
352 method.setToolTipText(sh.getEndpointURL());
353 method.addActionListener(new ActionListener()
355 public void actionPerformed(ActionEvent e)
357 AlignmentView msa = af.gatherSeqOrMsaForSecStrPrediction();
358 if (msa.getSequences().length == 1)
360 // Single Sequence prediction
361 new jalview.ws.jws1.JPredClient(sh, af.getTitle(), false, msa,
366 if (msa.getSequences().length > 1)
368 // Sequence profile based prediction
369 new jalview.ws.jws1.JPredClient(sh, af.getTitle(), true, msa,