1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.ws.jws1; |
22 |
|
|
23 |
|
import java.util.Locale; |
24 |
|
|
25 |
|
import jalview.analysis.AlignSeq; |
26 |
|
import jalview.bin.Console; |
27 |
|
import jalview.datamodel.AlignmentView; |
28 |
|
import jalview.datamodel.SeqCigar; |
29 |
|
import jalview.datamodel.SequenceI; |
30 |
|
import jalview.gui.AlignFrame; |
31 |
|
import jalview.gui.Desktop; |
32 |
|
import jalview.gui.JvOptionPane; |
33 |
|
import jalview.gui.WebserviceInfo; |
34 |
|
import jalview.util.MessageManager; |
35 |
|
|
36 |
|
import java.awt.event.ActionEvent; |
37 |
|
import java.awt.event.ActionListener; |
38 |
|
import java.util.Hashtable; |
39 |
|
|
40 |
|
import javax.swing.JMenu; |
41 |
|
import javax.swing.JMenuItem; |
42 |
|
|
43 |
|
import ext.vamsas.Jpred; |
44 |
|
import ext.vamsas.JpredServiceLocator; |
45 |
|
import ext.vamsas.JpredSoapBindingStub; |
46 |
|
import ext.vamsas.ServiceHandle; |
47 |
|
|
|
|
| 4.3% |
Uncovered Elements: 154 (161) |
Complexity: 38 |
Complexity Density: 0.36 |
|
48 |
|
public class JPredClient extends WS1Client |
49 |
|
{ |
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
@param |
54 |
|
|
55 |
|
@param |
56 |
|
|
57 |
|
@param |
58 |
|
|
59 |
|
@param |
60 |
|
|
61 |
|
@param |
62 |
|
|
63 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
64 |
0 |
public JPredClient(ext.vamsas.ServiceHandle sh, String title, boolean msa,... |
65 |
|
AlignmentView alview, AlignFrame parentFrame, boolean viewonly) |
66 |
|
{ |
67 |
0 |
super(); |
68 |
0 |
wsInfo = setWebService(sh); |
69 |
0 |
startJPredClient(title, msa, alview, parentFrame, viewonly); |
70 |
|
|
71 |
|
} |
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
@param |
83 |
|
|
84 |
|
@param |
85 |
|
|
86 |
|
@param |
87 |
|
|
88 |
|
@param |
89 |
|
|
90 |
|
|
91 |
|
|
|
|
| 0% |
Uncovered Elements: 67 (67) |
Complexity: 16 |
Complexity Density: 0.39 |
|
92 |
0 |
private void startJPredClient(String title, boolean msa,... |
93 |
|
jalview.datamodel.AlignmentView alview, AlignFrame parentFrame, |
94 |
|
boolean viewonly) |
95 |
|
{ |
96 |
0 |
AlignmentView input = alview; |
97 |
0 |
if (wsInfo == null) |
98 |
|
{ |
99 |
0 |
wsInfo = setWebService(); |
100 |
|
} |
101 |
0 |
Jpred server = locateWebService(); |
102 |
0 |
if (server == null) |
103 |
|
{ |
104 |
0 |
Console.warn("Couldn't find a Jpred webservice to invoke!"); |
105 |
0 |
return; |
106 |
|
} |
107 |
0 |
SeqCigar[] msf = null; |
108 |
0 |
SequenceI seq = null; |
109 |
0 |
int[] delMap = null; |
110 |
|
|
111 |
|
|
112 |
0 |
msf = input.getSequences(); |
113 |
0 |
seq = msf[0].getSeq('-'); |
114 |
|
|
115 |
0 |
if (viewonly) |
116 |
|
{ |
117 |
0 |
delMap = alview.getVisibleContigMapFor(seq.gapMap()); |
118 |
|
} |
119 |
0 |
if (msa && msf.length > 1) |
120 |
|
{ |
121 |
|
|
122 |
0 |
String altitle = getPredictionName(WebServiceName) + " on " |
123 |
0 |
+ (viewonly ? "visible " : "") + seq.getName() |
124 |
|
+ " using alignment from " + title; |
125 |
|
|
126 |
0 |
SequenceI aln[] = new SequenceI[msf.length]; |
127 |
0 |
for (int i = 0, j = msf.length; i < j; i++) |
128 |
|
{ |
129 |
0 |
aln[i] = msf[i].getSeq('-'); |
130 |
|
} |
131 |
|
|
132 |
0 |
Hashtable SequenceInfo = jalview.analysis.SeqsetUtils.uniquify(aln, |
133 |
|
true); |
134 |
0 |
if (viewonly) |
135 |
|
{ |
136 |
|
|
137 |
0 |
String seqs[] = alview.getSequenceStrings('-'); |
138 |
0 |
for (int i = 0, j = msf.length; i < j; i++) |
139 |
|
{ |
140 |
0 |
aln[i].setSequence(seqs[i]); |
141 |
|
} |
142 |
0 |
seq.setSequence(seqs[0]); |
143 |
|
} |
144 |
0 |
wsInfo.setProgressText("Job details for " |
145 |
0 |
+ (viewonly ? "visible " : "") + "MSA based prediction (" |
146 |
|
+ title + ") on sequence :\n>" + seq.getName() + "\n" |
147 |
|
+ AlignSeq.extractGaps("-. ", seq.getSequenceAsString()) |
148 |
|
+ "\n"); |
149 |
0 |
JPredThread jthread = new JPredThread(wsInfo, altitle, server, |
150 |
|
SequenceInfo, aln, delMap, alview, parentFrame, WsURL); |
151 |
0 |
wsInfo.setthisService(jthread); |
152 |
0 |
jthread.start(); |
153 |
|
} |
154 |
|
else |
155 |
|
{ |
156 |
0 |
if (!msa && msf.length > 1) |
157 |
|
{ |
158 |
0 |
throw new Error(MessageManager.getString( |
159 |
|
"error.implementation_error_multiple_single_sequence_prediction_jobs_not_supported")); |
160 |
|
} |
161 |
|
|
162 |
0 |
String altitle = getPredictionName(WebServiceName) + " for " |
163 |
0 |
+ (viewonly ? "visible " : "") + "sequence " + seq.getName() |
164 |
|
+ " from " + title; |
165 |
0 |
String seqname = seq.getName(); |
166 |
0 |
Hashtable SequenceInfo = jalview.analysis.SeqsetUtils |
167 |
|
.SeqCharacterHash(seq); |
168 |
0 |
if (viewonly) |
169 |
|
{ |
170 |
|
|
171 |
0 |
String seqs[] = alview.getSequenceStrings('-'); |
172 |
0 |
seq.setSequence(seqs[0]); |
173 |
|
} |
174 |
0 |
wsInfo.setProgressText("Job details for prediction on " |
175 |
0 |
+ (viewonly ? "visible " : "") + "sequence :\n>" + seqname |
176 |
|
+ "\n" |
177 |
|
+ AlignSeq.extractGaps("-. ", seq.getSequenceAsString()) |
178 |
|
+ "\n"); |
179 |
0 |
JPredThread jthread = new JPredThread(wsInfo, altitle, server, WsURL, |
180 |
|
SequenceInfo, seq, delMap, alview, parentFrame); |
181 |
0 |
wsInfo.setthisService(jthread); |
182 |
0 |
jthread.start(); |
183 |
|
} |
184 |
|
} |
185 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
186 |
0 |
private String getPredictionName(String webServiceName)... |
187 |
|
{ |
188 |
0 |
if (webServiceName.toLowerCase(Locale.ROOT) |
189 |
|
.indexOf("secondary structure prediction") > -1) |
190 |
|
{ |
191 |
0 |
return webServiceName; |
192 |
|
} |
193 |
|
else |
194 |
|
{ |
195 |
0 |
return webServiceName + "secondary structure prediction"; |
196 |
|
} |
197 |
|
} |
198 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
199 |
0 |
public JPredClient(ext.vamsas.ServiceHandle sh, String title,... |
200 |
|
SequenceI seq, AlignFrame parentFrame) |
201 |
|
{ |
202 |
0 |
super(); |
203 |
0 |
wsInfo = setWebService(sh); |
204 |
0 |
startJPredClient(title, seq, parentFrame); |
205 |
|
} |
206 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
207 |
0 |
public JPredClient(ext.vamsas.ServiceHandle sh, String title,... |
208 |
|
SequenceI[] msa, AlignFrame parentFrame) |
209 |
|
{ |
210 |
0 |
wsInfo = setWebService(sh); |
211 |
0 |
startJPredClient(title, msa, parentFrame); |
212 |
|
} |
213 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
214 |
0 |
public JPredClient(String title, SequenceI[] msf)... |
215 |
|
{ |
216 |
0 |
startJPredClient(title, msf, null); |
217 |
|
} |
218 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
219 |
0 |
public JPredClient(String title, SequenceI seq)... |
220 |
|
{ |
221 |
0 |
startJPredClient(title, seq, null); |
222 |
|
} |
223 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
224 |
6 |
public JPredClient()... |
225 |
|
{ |
226 |
|
|
227 |
6 |
super(); |
228 |
|
|
229 |
|
} |
230 |
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 4 |
Complexity Density: 0.27 |
|
231 |
0 |
private void startJPredClient(String title, SequenceI[] msf,... |
232 |
|
AlignFrame parentFrame) |
233 |
|
{ |
234 |
0 |
if (wsInfo == null) |
235 |
|
{ |
236 |
0 |
wsInfo = setWebService(); |
237 |
|
} |
238 |
|
|
239 |
0 |
SequenceI seq = msf[0]; |
240 |
|
|
241 |
0 |
String altitle = "JPred prediction on " + seq.getName() |
242 |
|
+ " using alignment from " + title; |
243 |
|
|
244 |
0 |
wsInfo.setProgressText("Job details for MSA based prediction (" + title |
245 |
|
+ ") on sequence :\n>" + seq.getName() + "\n" |
246 |
|
+ AlignSeq.extractGaps("-. ", seq.getSequenceAsString()) |
247 |
|
+ "\n"); |
248 |
0 |
SequenceI aln[] = new SequenceI[msf.length]; |
249 |
0 |
for (int i = 0, j = msf.length; i < j; i++) |
250 |
|
{ |
251 |
0 |
aln[i] = new jalview.datamodel.Sequence(msf[i]); |
252 |
|
} |
253 |
|
|
254 |
0 |
Hashtable SequenceInfo = jalview.analysis.SeqsetUtils.uniquify(aln, |
255 |
|
true); |
256 |
|
|
257 |
0 |
Jpred server = locateWebService(); |
258 |
0 |
if (server == null) |
259 |
|
{ |
260 |
0 |
return; |
261 |
|
} |
262 |
|
|
263 |
0 |
JPredThread jthread = new JPredThread(wsInfo, altitle, server, |
264 |
|
SequenceInfo, aln, null, null, parentFrame, WsURL); |
265 |
0 |
wsInfo.setthisService(jthread); |
266 |
0 |
jthread.start(); |
267 |
|
} |
268 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 3 |
Complexity Density: 0.27 |
|
269 |
0 |
public void startJPredClient(String title, SequenceI seq,... |
270 |
|
AlignFrame parentFrame) |
271 |
|
{ |
272 |
0 |
if (wsInfo == null) |
273 |
|
{ |
274 |
0 |
wsInfo = setWebService(); |
275 |
|
} |
276 |
0 |
wsInfo.setProgressText("Job details for prediction on sequence :\n>" |
277 |
|
+ seq.getName() + "\n" |
278 |
|
+ AlignSeq.extractGaps("-. ", seq.getSequenceAsString()) |
279 |
|
+ "\n"); |
280 |
0 |
String altitle = "JPred prediction for sequence " + seq.getName() |
281 |
|
+ " from " + title; |
282 |
|
|
283 |
0 |
Hashtable SequenceInfo = jalview.analysis.SeqsetUtils |
284 |
|
.SeqCharacterHash(seq); |
285 |
|
|
286 |
0 |
Jpred server = locateWebService(); |
287 |
0 |
if (server == null) |
288 |
|
{ |
289 |
0 |
return; |
290 |
|
} |
291 |
|
|
292 |
0 |
JPredThread jthread = new JPredThread(wsInfo, altitle, server, WsURL, |
293 |
|
SequenceInfo, seq, null, null, parentFrame); |
294 |
0 |
wsInfo.setthisService(jthread); |
295 |
0 |
jthread.start(); |
296 |
|
} |
297 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
298 |
0 |
private WebserviceInfo setWebService()... |
299 |
|
{ |
300 |
0 |
WebServiceName = "JNetWS"; |
301 |
0 |
WebServiceJobTitle = MessageManager |
302 |
|
.getString("label.jnet_secondary_structure_prediction"); |
303 |
0 |
WebServiceReference = "\"Cuff J. A and Barton G.J (2000) Application of " |
304 |
|
+ "multiple sequence alignment profiles to improve protein secondary structure prediction, " |
305 |
|
+ "Proteins 40:502-511\"."; |
306 |
0 |
WsURL = "http://www.compbio.dundee.ac.uk/JalviewWS/services/jpred"; |
307 |
|
|
308 |
0 |
WebserviceInfo wsInfo = new WebserviceInfo(WebServiceJobTitle, |
309 |
|
WebServiceReference, true); |
310 |
|
|
311 |
0 |
return wsInfo; |
312 |
|
} |
313 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.22 |
|
314 |
0 |
private ext.vamsas.Jpred locateWebService()... |
315 |
|
{ |
316 |
0 |
ext.vamsas.JpredServiceLocator loc = new JpredServiceLocator(); |
317 |
0 |
ext.vamsas.Jpred server = null; |
318 |
0 |
try |
319 |
|
{ |
320 |
0 |
server = loc.getjpred(new java.net.URL(WsURL)); |
321 |
|
|
322 |
0 |
((JpredSoapBindingStub) server).setTimeout(60000); |
323 |
|
|
324 |
|
|
325 |
|
|
326 |
|
} catch (Exception ex) |
327 |
|
{ |
328 |
0 |
JvOptionPane.showMessageDialog(Desktop.desktop, |
329 |
|
MessageManager.formatMessage( |
330 |
|
"label.secondary_structure_prediction_service_couldnt_be_located", |
331 |
|
new String[] |
332 |
|
{ WebServiceName, WsURL }), |
333 |
|
MessageManager.getString("label.internal_jalview_error"), |
334 |
|
JvOptionPane.WARNING_MESSAGE); |
335 |
0 |
wsInfo.setProgressText(MessageManager.formatMessage( |
336 |
|
"label.secondary_structure_prediction_service_couldnt_be_located", |
337 |
|
new String[] |
338 |
|
{ WebServiceName, WsURL }) + "\n" + ex.getMessage()); |
339 |
0 |
wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_SERVERERROR); |
340 |
|
|
341 |
|
} |
342 |
|
|
343 |
0 |
return server; |
344 |
|
} |
345 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
346 |
2864 |
@Override... |
347 |
|
public void attachWSMenuEntry(JMenu wsmenu, final ServiceHandle sh, |
348 |
|
final AlignFrame af) |
349 |
|
{ |
350 |
2864 |
final JMenuItem method = new JMenuItem(sh.getName()); |
351 |
2864 |
method.setToolTipText(sh.getEndpointURL()); |
352 |
2864 |
method.addActionListener(new ActionListener() |
353 |
|
{ |
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
354 |
0 |
@Override... |
355 |
|
public void actionPerformed(ActionEvent e) |
356 |
|
{ |
357 |
0 |
AlignmentView msa = af.gatherSeqOrMsaForSecStrPrediction(); |
358 |
0 |
if (msa.getSequences().length == 1) |
359 |
|
{ |
360 |
|
|
361 |
0 |
new jalview.ws.jws1.JPredClient(sh, af.getTitle(), false, msa, af, |
362 |
|
true); |
363 |
|
} |
364 |
|
else |
365 |
|
{ |
366 |
0 |
if (msa.getSequences().length > 1) |
367 |
|
{ |
368 |
|
|
369 |
0 |
new jalview.ws.jws1.JPredClient(sh, af.getTitle(), true, msa, |
370 |
|
af, true); |
371 |
|
} |
372 |
|
} |
373 |
|
} |
374 |
|
}); |
375 |
2864 |
wsmenu.add(method); |
376 |
|
} |
377 |
|
} |