2 * Jalview - A Sequence Alignment Editor and Viewer
3 * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26 import jalview.analysis.*;
28 import jalview.datamodel.*;
29 import jalview.datamodel.AlignmentView;
32 public class JPredClient
36 * crate a new GUI JPred Job
37 * @param sh ServiceHandle
39 * @param msa boolean - true - submit alignment as a sequence profile
40 * @param alview AlignmentView
41 * @param viewonly TODO
43 public JPredClient(ext.vamsas.ServiceHandle sh, String title, boolean msa, AlignmentView alview, AlignFrame parentFrame, boolean viewonly) {
45 wsInfo=setWebService(sh);
46 startJPredClient(title, msa, alview, parentFrame, viewonly);
51 * TODO: refine submission to cope with local prediction of visible regions or multiple single sequence jobs
52 * TODO: sequence representative support - could submit alignment of representatives as msa.
53 * TODO: msa hidden region prediction - submit each chunk for prediction. concatenate results of each.
54 * TODO: single seq prediction - submit each contig of each sequence for prediction (but must cope with flanking regions and short seqs)
57 * @param alview AlignmentView
58 * @param viewonly if true then the prediction will be made just on the concatenated visible regions
60 private void startJPredClient(String title, boolean msa,
61 jalview.datamodel.AlignmentView alview, AlignFrame parentFrame, boolean viewonly)
63 AlignmentView input = alview;
66 wsInfo = setWebService();
68 Jpred server = locateWebService();
71 Cache.log.warn("Couldn't find a Jpred webservice to invoke!");
77 // original JNetClient behaviour - submit full length of sequence or profile
79 msf = input.getSequences();
80 seq = msf[0].getSeq('-');
83 int[] viscontigs = alview.getVisibleContigs();
86 if (viscontigs!=null) {
87 // Construct the delMap - mapping from the positions within the input to Jnet to the contigs in the original sequence
89 delMap = new int[seq.getEnd()-seq.getStart()+1];
90 int gapMap[] = seq.gapMap();
91 for (int contig = 0; contig<viscontigs.length; contig += 2)
94 while (spos<gapMap.length && gapMap[spos]<viscontigs[contig]) {
97 while (spos<gapMap.length && gapMap[spos]<=viscontigs[contig+1]) {
101 int tmap[] = new int[i];
102 System.arraycopy(delMap, 0, tmap, 0, i);
106 if (msa && msf.length > 1)
109 String altitle = "JNet prediction on "+(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('-');
119 Hashtable SequenceInfo = jalview.analysis.SeqsetUtils.uniquify(aln, true);
121 // Remove hidden regions from sequence objects.
122 String seqs[] = alview.getSequenceStrings('-');
123 for (int i = 0, j = msf.length; i < j; i++)
125 aln[i].setSequence(seqs[i]);
127 seq.setSequence(seqs[0]);
129 wsInfo.setProgressText("Job details for "+(viewonly?"visible ":"")+"MSA based prediction (" +
130 title + ") on sequence :\n>" + seq.getName() +
132 AlignSeq.extractGaps("-. ", seq.getSequenceAsString()) +
134 JPredThread jthread = new JPredThread(wsInfo, altitle, server,
135 SequenceInfo, aln, delMap, alview, parentFrame, WsURL);
136 wsInfo.setthisService(jthread);
141 if (!msa && msf.length>1)
142 throw new Error("Implementation Error! Multiple single sequence prediction jobs are not yet supported.");
143 String altitle = "JNet prediction for "+(viewonly?"visible ":"")+"sequence " + seq.getName() +
146 String seqname = seq.getName();
147 Hashtable SequenceInfo = jalview.analysis.SeqsetUtils.SeqCharacterHash(
150 // Remove hidden regions from input sequence
151 String seqs[] = alview.getSequenceStrings('-');
152 seq.setSequence(seqs[0]);
154 wsInfo.setProgressText("Job details for prediction on "+(viewonly?"visible ":"")+"sequence :\n>" +
156 AlignSeq.extractGaps("-. ", seq.getSequenceAsString()) +
158 JPredThread jthread = new JPredThread(wsInfo, altitle, server, WsURL,
159 SequenceInfo, seq, delMap, alview, parentFrame);
160 wsInfo.setthisService(jthread);
164 public JPredClient(ext.vamsas.ServiceHandle sh, String title, SequenceI seq, AlignFrame parentFrame)
167 wsInfo = setWebService(sh);
168 startJPredClient(title, seq, parentFrame);
171 public JPredClient(ext.vamsas.ServiceHandle sh, String title, SequenceI[] msa, AlignFrame parentFrame)
173 wsInfo = setWebService(sh);
174 startJPredClient(title, msa, parentFrame);
177 public JPredClient(String title, SequenceI[] msf)
179 startJPredClient(title, msf, null);
182 public JPredClient(String title, SequenceI seq)
184 startJPredClient(title, seq, null);
187 private void startJPredClient(String title, SequenceI[] msf, AlignFrame parentFrame)
191 wsInfo = setWebService();
194 SequenceI seq = msf[0];
196 String altitle = "JNet prediction on " + seq.getName() +
197 " using alignment from " + title;
199 wsInfo.setProgressText("Job details for MSA based prediction (" +
200 title + ") on sequence :\n>" + seq.getName() + "\n" +
201 AlignSeq.extractGaps("-. ", seq.getSequenceAsString()) +
203 SequenceI aln[] = new SequenceI[msf.length];
204 for (int i = 0, j = msf.length; i < j; i++)
206 aln[i] = new jalview.datamodel.Sequence(msf[i]);
209 Hashtable SequenceInfo = jalview.analysis.SeqsetUtils.uniquify(aln, true);
211 Jpred server = locateWebService();
217 JPredThread jthread = new JPredThread(wsInfo, altitle, server, SequenceInfo, aln,null, null, parentFrame, WsURL);
218 wsInfo.setthisService(jthread);
222 public void startJPredClient(String title, SequenceI seq, AlignFrame parentFrame)
226 wsInfo = setWebService();
228 wsInfo.setProgressText("Job details for prediction on sequence :\n>" +
229 seq.getName() + "\n" +
230 AlignSeq.extractGaps("-. ", seq.getSequenceAsString()) +
232 String altitle = "JNet prediction for sequence " + seq.getName() + " from " +
235 Hashtable SequenceInfo = jalview.analysis.SeqsetUtils.SeqCharacterHash(seq);
237 Jpred server = locateWebService();
243 JPredThread jthread = new JPredThread(wsInfo, altitle, server, WsURL, SequenceInfo, seq,null, null, parentFrame);
244 wsInfo.setthisService(jthread);
248 private WebserviceInfo setWebService()
250 WebServiceName = "JNetWS";
251 WebServiceJobTitle = "JNet secondary structure prediction";
252 WebServiceReference =
253 "\"Cuff J. A and Barton G.J (2000) Application of " +
254 "multiple sequence alignment profiles to improve protein secondary structure prediction, " +
255 "Proteins 40:502-511\".";
256 WsURL = "http://www.compbio.dundee.ac.uk/JalviewWS/services/jpred";
258 WebserviceInfo wsInfo = new WebserviceInfo(WebServiceJobTitle,
259 WebServiceReference);
264 private ext.vamsas.Jpred locateWebService()
266 ext.vamsas.JpredServiceLocator loc = new JpredServiceLocator(); // Default
267 ext.vamsas.Jpred server=null;
270 server = loc.getjpred(new java.net.URL(WsURL)); // JBPNote will be set from properties
271 ( (JpredSoapBindingStub)server).setTimeout(60000); // one minute stub
272 //((JpredSoapBindingStub)this.server)._setProperty(org.apache.axis.encoding.C, Boolean.TRUE);
277 JOptionPane.showMessageDialog(Desktop.desktop,
278 "The Secondary Structure Prediction Service named " +
279 WebServiceName + " at " + WsURL +
280 " couldn't be located.",
281 "Internal Jalview Error",
282 JOptionPane.WARNING_MESSAGE);
283 wsInfo.setProgressText("Serious! " + WebServiceName +
284 " Service location failed\nfor URL :" + WsURL +
287 wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_SERVERERROR);