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.analysis.SeqsetUtils;
25 import jalview.bin.Cache;
26 import jalview.datamodel.AlignmentView;
27 import jalview.datamodel.SeqCigar;
28 import jalview.datamodel.SequenceI;
29 import jalview.gui.AlignFrame;
30 import jalview.gui.Desktop;
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;
40 import javax.swing.JOptionPane;
42 import ext.vamsas.Jpred;
43 import ext.vamsas.JpredServiceLocator;
44 import ext.vamsas.JpredSoapBindingStub;
45 import ext.vamsas.ServiceHandle;
47 public class JPredClient extends WS1Client
50 * crate a new GUI JPred Job
57 * boolean - true - submit alignment as a sequence profile
63 public JPredClient(ext.vamsas.ServiceHandle sh, String title,
64 boolean msa, AlignmentView alview, AlignFrame parentFrame,
68 wsInfo = setWebService(sh);
69 startJPredClient(title, msa, alview, parentFrame, viewonly);
74 * startJPredClient TODO: refine submission to cope with local prediction of
75 * visible regions or multiple single sequence jobs TODO: sequence
76 * representative support - could submit alignment of representatives as msa.
77 * TODO: msa hidden region prediction - submit each chunk for prediction.
78 * concatenate results of each. TODO: single seq prediction - submit each
79 * contig of each sequence for prediction (but must cope with flanking regions
89 * if true then the prediction will be made just on the concatenated
92 private void startJPredClient(String title, boolean msa,
93 AlignmentView alview, AlignFrame parentFrame,
96 AlignmentView input = alview;
99 wsInfo = setWebService();
101 Jpred server = locateWebService();
104 Cache.log.warn("Couldn't find a Jpred webservice to invoke!");
107 SeqCigar[] msf = null;
108 SequenceI seq = null;
110 // original JNetClient behaviour - submit full length of sequence or profile
112 msf = input.getSequences();
113 seq = msf[0].getSeq('-');
117 delMap = alview.getVisibleContigMapFor(seq.gapMap());
119 if (msa && msf.length > 1)
122 String altitle = getPredictionName(WebServiceName) + " on "
123 + (viewonly ? "visible " : "") + seq.getName()
124 + " using alignment from " + title;
126 SequenceI aln[] = new SequenceI[msf.length];
127 for (int i = 0, j = msf.length; i < j; i++)
129 aln[i] = msf[i].getSeq('-');
132 Hashtable SequenceInfo = SeqsetUtils.uniquify(aln, true);
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)
157 throw new Error(MessageManager.getString("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 = SeqsetUtils.SeqCharacterHash(seq);
167 // Remove hidden regions from input sequence
168 String seqs[] = alview.getSequenceStrings('-');
169 seq.setSequence(seqs[0]);
171 wsInfo.setProgressText("Job details for prediction on "
172 + (viewonly ? "visible " : "") + "sequence :\n>" + seqname
174 + AlignSeq.extractGaps("-. ", seq.getSequenceAsString())
176 JPredThread jthread = new JPredThread(wsInfo, altitle, server, WsURL,
177 SequenceInfo, seq, delMap, alview, parentFrame);
178 wsInfo.setthisService(jthread);
183 private String getPredictionName(String webServiceName)
185 if (webServiceName.toLowerCase().indexOf(
186 "secondary structure prediction") > -1)
188 return webServiceName;
192 return webServiceName + "secondary structure prediction";
196 public JPredClient(ext.vamsas.ServiceHandle sh, String title,
197 SequenceI seq, AlignFrame parentFrame)
200 wsInfo = setWebService(sh);
201 startJPredClient(title, seq, parentFrame);
204 public JPredClient(ext.vamsas.ServiceHandle sh, String title,
205 SequenceI[] msa, AlignFrame parentFrame)
207 wsInfo = setWebService(sh);
208 startJPredClient(title, msa, parentFrame);
211 public JPredClient(String title, SequenceI[] msf)
213 startJPredClient(title, msf, null);
216 public JPredClient(String title, SequenceI seq)
218 startJPredClient(title, seq, null);
225 // add a class reference to the list
228 private void startJPredClient(String title, SequenceI[] msf,
229 AlignFrame parentFrame)
233 wsInfo = setWebService();
236 SequenceI seq = msf[0];
238 String altitle = "JNet prediction on " + seq.getName()
239 + " using alignment from " + title;
241 wsInfo.setProgressText("Job details for MSA based prediction (" + title
242 + ") on sequence :\n>" + seq.getName() + "\n"
243 + AlignSeq.extractGaps("-. ", seq.getSequenceAsString()) + "\n");
244 SequenceI aln[] = new SequenceI[msf.length];
245 for (int i = 0, j = msf.length; i < j; i++)
247 aln[i] = new jalview.datamodel.Sequence(msf[i]);
250 Hashtable SequenceInfo = SeqsetUtils.uniquify(aln,
253 Jpred server = locateWebService();
259 JPredThread jthread = new JPredThread(wsInfo, altitle, server,
260 SequenceInfo, aln, null, null, parentFrame, WsURL);
261 wsInfo.setthisService(jthread);
265 public void startJPredClient(String title, SequenceI seq,
266 AlignFrame parentFrame)
270 wsInfo = setWebService();
272 wsInfo.setProgressText("Job details for prediction on sequence :\n>"
273 + seq.getName() + "\n"
274 + AlignSeq.extractGaps("-. ", seq.getSequenceAsString()) + "\n");
275 String altitle = "JNet prediction for sequence " + seq.getName()
278 Hashtable SequenceInfo = SeqsetUtils.SeqCharacterHash(seq);
280 Jpred server = locateWebService();
286 JPredThread jthread = new JPredThread(wsInfo, altitle, server, WsURL,
287 SequenceInfo, seq, null, null, parentFrame);
288 wsInfo.setthisService(jthread);
292 private WebserviceInfo setWebService()
294 WebServiceName = "JNetWS";
295 WebServiceJobTitle = MessageManager.getString("label.jnet_secondary_structure_prediction");
296 WebServiceReference = "\"Cuff J. A and Barton G.J (2000) Application of "
297 + "multiple sequence alignment profiles to improve protein secondary structure prediction, "
298 + "Proteins 40:502-511\".";
299 WsURL = "http://www.compbio.dundee.ac.uk/JalviewWS/services/jpred";
301 WebserviceInfo wsInfo = new WebserviceInfo(WebServiceJobTitle,
302 WebServiceReference, true);
307 private ext.vamsas.Jpred locateWebService()
309 ext.vamsas.JpredServiceLocator loc = new JpredServiceLocator(); // Default
310 ext.vamsas.Jpred server = null;
313 server = loc.getjpred(new java.net.URL(WsURL)); // JBPNote will be set
315 ((JpredSoapBindingStub) server).setTimeout(60000); // one minute stub
316 // ((JpredSoapBindingStub)this.server)._setProperty(org.apache.axis.encoding.C,
319 } catch (Exception ex)
321 JOptionPane.showMessageDialog(Desktop.desktop,
322 MessageManager.formatMessage("label.secondary_structure_prediction_service_couldnt_be_located", new String[]{WebServiceName,WsURL}),
323 MessageManager.getString("label.internal_jalview_error"),
324 JOptionPane.WARNING_MESSAGE);
325 wsInfo.setProgressText(MessageManager.formatMessage("label.secondary_structure_prediction_service_couldnt_be_located", new String[]{WebServiceName,WsURL})
328 wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_SERVERERROR);
335 public void attachWSMenuEntry(JMenu wsmenu, final ServiceHandle sh,
338 final JMenuItem method = new JMenuItem(sh.getName());
339 method.setToolTipText(sh.getEndpointURL());
340 method.addActionListener(new ActionListener()
342 public void actionPerformed(ActionEvent e)
344 AlignmentView msa = af.gatherSeqOrMsaForSecStrPrediction();
345 if (msa.getSequences().length == 1)
347 // Single Sequence prediction
348 new jalview.ws.jws1.JPredClient(sh, af.getTitle(), false, msa,
353 if (msa.getSequences().length > 1)
355 // Sequence profile based prediction
356 new jalview.ws.jws1.JPredClient(sh, af.getTitle(), true, msa,