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 jalview.bin.Console; |
24 |
|
import jalview.datamodel.AlignmentI; |
25 |
|
import jalview.datamodel.AlignmentView; |
26 |
|
import jalview.gui.AlignFrame; |
27 |
|
import jalview.gui.Desktop; |
28 |
|
import jalview.gui.JvOptionPane; |
29 |
|
import jalview.gui.WebserviceInfo; |
30 |
|
import jalview.util.MessageManager; |
31 |
|
|
32 |
|
import java.awt.Component; |
33 |
|
import java.awt.event.ActionEvent; |
34 |
|
import java.awt.event.ActionListener; |
35 |
|
import java.util.Enumeration; |
36 |
|
import java.util.Hashtable; |
37 |
|
import java.util.StringTokenizer; |
38 |
|
import java.util.Vector; |
39 |
|
|
40 |
|
import javax.swing.JMenu; |
41 |
|
import javax.swing.JMenuItem; |
42 |
|
|
43 |
|
import ext.vamsas.SeqSearchServiceLocator; |
44 |
|
import ext.vamsas.SeqSearchServiceSoapBindingStub; |
45 |
|
import ext.vamsas.ServiceHandle; |
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
@author |
51 |
|
@version |
52 |
|
|
|
|
| 3% |
Uncovered Elements: 131 (135) |
Complexity: 36 |
Complexity Density: 0.42 |
|
53 |
|
public class SeqSearchWSClient extends WS1Client |
54 |
|
{ |
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
ext.vamsas.SeqSearchI server; |
59 |
|
|
60 |
|
AlignFrame alignFrame; |
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
@param |
67 |
|
|
68 |
|
@param |
69 |
|
|
70 |
|
@param |
71 |
|
|
72 |
|
@param |
73 |
|
|
74 |
|
@param |
75 |
|
|
76 |
|
|
77 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 3 |
Complexity Density: 0.33 |
|
78 |
0 |
public SeqSearchWSClient(ext.vamsas.ServiceHandle sh, String altitle,... |
79 |
|
jalview.datamodel.AlignmentView msa, String db, |
80 |
|
AlignmentI seqdataset, AlignFrame _alignFrame) |
81 |
|
{ |
82 |
0 |
super(); |
83 |
0 |
alignFrame = _alignFrame; |
84 |
|
|
85 |
|
|
86 |
0 |
if (!sh.getAbstractName().equals(this.getServiceActionKey())) |
87 |
|
{ |
88 |
0 |
JvOptionPane.showMessageDialog(Desktop.desktop, |
89 |
|
MessageManager.formatMessage( |
90 |
|
"label.service_called_is_not_seq_search_service", |
91 |
|
new String[] |
92 |
|
{ sh.getName() }), |
93 |
|
MessageManager.getString("label.internal_jalview_error"), |
94 |
|
JvOptionPane.WARNING_MESSAGE); |
95 |
|
|
96 |
0 |
return; |
97 |
|
} |
98 |
|
|
99 |
0 |
if ((wsInfo = setWebService(sh)) == null) |
100 |
|
{ |
101 |
0 |
JvOptionPane.showMessageDialog(Desktop.desktop, |
102 |
|
MessageManager.formatMessage( |
103 |
|
"label.seq_search_service_is_unknown", new String[] |
104 |
|
{ sh.getName() }), |
105 |
|
MessageManager.getString("label.internal_jalview_error"), |
106 |
|
JvOptionPane.WARNING_MESSAGE); |
107 |
|
|
108 |
0 |
return; |
109 |
|
} |
110 |
0 |
startSeqSearchClient(altitle, msa, db, seqdataset); |
111 |
|
|
112 |
|
} |
113 |
|
|
114 |
|
|
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
@param |
119 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
120 |
0 |
public SeqSearchWSClient(ServiceHandle sh)... |
121 |
|
{ |
122 |
0 |
setWebService(sh, true); |
123 |
|
} |
124 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
125 |
6 |
public SeqSearchWSClient()... |
126 |
|
{ |
127 |
|
|
128 |
6 |
super(); |
129 |
|
|
130 |
|
} |
131 |
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 8 |
Complexity Density: 0.89 |
|
132 |
0 |
private void startSeqSearchClient(String altitle, AlignmentView msa,... |
133 |
|
String db, AlignmentI seqdataset) |
134 |
|
{ |
135 |
0 |
if (!locateWebService()) |
136 |
|
{ |
137 |
0 |
return; |
138 |
|
} |
139 |
0 |
String visdb = (db == null || db == "") ? "default" : db; |
140 |
|
|
141 |
|
|
142 |
0 |
boolean profileSearch = msa.getSequences().length > 2 ? true : false; |
143 |
|
|
144 |
0 |
wsInfo.setProgressText("Searching " + visdb |
145 |
0 |
+ (!profileSearch |
146 |
|
? " with sequence " |
147 |
|
+ msa.getSequences()[0].getRefSeq().getName() |
148 |
|
: " with profile") |
149 |
|
+ " from " + altitle + "\nJob details\n"); |
150 |
|
|
151 |
0 |
String jobtitle = WebServiceName |
152 |
0 |
+ ((WebServiceName.indexOf("earch") > -1) ? " " : " search ") |
153 |
|
+ " of " + visdb |
154 |
0 |
+ (!profileSearch |
155 |
|
? " with sequence " |
156 |
|
+ msa.getSequences()[0].getRefSeq().getName() |
157 |
|
: " with profile") |
158 |
|
+ " from " + altitle; |
159 |
0 |
SeqSearchWSThread ssthread = new SeqSearchWSThread(server, WsURL, |
160 |
|
wsInfo, alignFrame, WebServiceName, jobtitle, msa, db, |
161 |
|
seqdataset); |
162 |
0 |
wsInfo.setthisService(ssthread); |
163 |
0 |
ssthread.start(); |
164 |
|
} |
165 |
|
|
166 |
|
|
167 |
|
|
168 |
|
|
169 |
|
@return |
170 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 2 |
Complexity Density: 0.2 |
|
171 |
0 |
private boolean locateWebService()... |
172 |
|
{ |
173 |
|
|
174 |
|
|
175 |
0 |
SeqSearchServiceLocator loc = new SeqSearchServiceLocator(); |
176 |
|
|
177 |
0 |
try |
178 |
|
{ |
179 |
0 |
this.server = loc.getSeqSearchService(new java.net.URL(WsURL)); |
180 |
0 |
((SeqSearchServiceSoapBindingStub) this.server).setTimeout(60000); |
181 |
|
|
182 |
|
|
183 |
|
} catch (Exception ex) |
184 |
|
{ |
185 |
0 |
wsInfo.setProgressText("Serious! " + WebServiceName |
186 |
|
+ " Service location failed\nfor URL :" + WsURL + "\n" |
187 |
|
+ ex.getMessage()); |
188 |
0 |
wsInfo.setStatus(WebserviceInfo.ERROR); |
189 |
0 |
ex.printStackTrace(); |
190 |
|
|
191 |
0 |
return false; |
192 |
|
} |
193 |
|
|
194 |
0 |
loc.getEngine().setOption("axis", "1"); |
195 |
|
|
196 |
0 |
return true; |
197 |
|
} |
198 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
199 |
0 |
protected String getServiceActionKey()... |
200 |
|
{ |
201 |
0 |
return "SeqSearch"; |
202 |
|
} |
203 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
204 |
0 |
protected String getServiceActionDescription()... |
205 |
|
{ |
206 |
0 |
return "Sequence Database Search"; |
207 |
|
} |
208 |
|
|
209 |
|
|
210 |
|
private static Hashtable dbParamsForEndpoint; |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
211 |
6 |
static... |
212 |
|
{ |
213 |
6 |
dbParamsForEndpoint = new Hashtable(); |
214 |
|
} |
215 |
|
|
|
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 5 |
Complexity Density: 0.36 |
|
216 |
0 |
public String[] getSupportedDatabases() throws Exception... |
217 |
|
{ |
218 |
|
|
219 |
|
|
220 |
0 |
if (dbParamsForEndpoint.containsKey(WsURL)) |
221 |
|
{ |
222 |
0 |
return (String[]) dbParamsForEndpoint.get(WsURL); |
223 |
|
} |
224 |
0 |
if (!locateWebService()) |
225 |
|
{ |
226 |
0 |
throw new Exception(MessageManager.formatMessage( |
227 |
|
"exception.cannot_contact_service_endpoint_at", new String[] |
228 |
|
{ WsURL })); |
229 |
|
} |
230 |
0 |
String database = server.getDatabase(); |
231 |
0 |
if (database == null) |
232 |
|
{ |
233 |
0 |
dbParamsForEndpoint.put(WsURL, new String[] {}); |
234 |
0 |
return null; |
235 |
|
} |
236 |
0 |
StringTokenizer en = new StringTokenizer(database.trim(), ",| "); |
237 |
0 |
String[] dbs = new String[en.countTokens()]; |
238 |
0 |
for (int i = 0; i < dbs.length; i++) |
239 |
|
{ |
240 |
0 |
dbs[i++] = en.nextToken().trim(); |
241 |
|
} |
242 |
0 |
dbParamsForEndpoint.put(WsURL, dbs); |
243 |
0 |
return dbs; |
244 |
|
} |
245 |
|
|
|
|
| 0% |
Uncovered Elements: 48 (48) |
Complexity: 11 |
Complexity Density: 0.32 |
|
246 |
0 |
@Override... |
247 |
|
public void attachWSMenuEntry(JMenu wsmenu, final ServiceHandle sh, |
248 |
|
final AlignFrame af) |
249 |
|
{ |
250 |
|
|
251 |
0 |
Hashtable dbsrchs = new Hashtable(); |
252 |
0 |
Vector newdbsrch = new Vector(); |
253 |
0 |
Component entries[] = wsmenu.getComponents(); |
254 |
0 |
for (int i = 0; entries != null && i < entries.length; i++) |
255 |
|
{ |
256 |
0 |
if (entries[i] instanceof JMenu) |
257 |
|
{ |
258 |
0 |
dbsrchs.put(entries[i].getName(), entries[i]); |
259 |
|
} |
260 |
|
} |
261 |
0 |
JMenu defmenu = (JMenu) dbsrchs.get("Default Database"); |
262 |
0 |
if (defmenu == null) |
263 |
|
{ |
264 |
0 |
dbsrchs.put("Default Database", |
265 |
|
defmenu = new JMenu("Default Database")); |
266 |
0 |
newdbsrch.addElement(defmenu); |
267 |
|
} |
268 |
|
|
269 |
0 |
String dbs[] = null; |
270 |
0 |
try |
271 |
|
{ |
272 |
0 |
dbs = new jalview.ws.jws1.SeqSearchWSClient(sh) |
273 |
|
.getSupportedDatabases(); |
274 |
|
} catch (Exception e) |
275 |
|
{ |
276 |
0 |
Console.warn( |
277 |
|
"Database list request failed, so disabling SeqSearch Service client " |
278 |
|
+ sh.getName() + " at " + sh.getEndpointURL(), |
279 |
|
e); |
280 |
0 |
return; |
281 |
|
} |
282 |
0 |
JMenuItem method; |
283 |
|
|
284 |
0 |
defmenu.add(method = new JMenuItem(sh.getName())); |
285 |
0 |
method.setToolTipText(sh.getEndpointURL()); |
286 |
0 |
method.addActionListener(new ActionListener() |
287 |
|
{ |
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
288 |
0 |
@Override... |
289 |
|
public void actionPerformed(ActionEvent e) |
290 |
|
{ |
291 |
|
|
292 |
|
|
293 |
0 |
AlignmentView msa = af.gatherSeqOrMsaForSecStrPrediction(); |
294 |
0 |
new jalview.ws.jws1.SeqSearchWSClient(sh, af.getTitle(), msa, null, |
295 |
|
af.getViewport().getAlignment().getDataset(), af); |
296 |
|
} |
297 |
|
}); |
298 |
|
|
299 |
0 |
for (int db = 0; dbs != null && db < dbs.length; db++) |
300 |
|
{ |
301 |
0 |
JMenu dbmenu = (JMenu) dbsrchs.get(dbs[db]); |
302 |
0 |
if (dbmenu == null) |
303 |
|
{ |
304 |
0 |
dbsrchs.put(dbs[db], dbmenu = new JMenu(dbs[db])); |
305 |
0 |
newdbsrch.addElement(dbmenu); |
306 |
|
} |
307 |
|
|
308 |
0 |
dbmenu.add(method = new JMenuItem(sh.getName())); |
309 |
0 |
method.setToolTipText(sh.getEndpointURL()); |
310 |
0 |
final String searchdb = dbs[db]; |
311 |
0 |
method.addActionListener(new ActionListener() |
312 |
|
{ |
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
313 |
0 |
@Override... |
314 |
|
public void actionPerformed(ActionEvent e) |
315 |
|
{ |
316 |
0 |
AlignmentView msa = af.gatherSeqOrMsaForSecStrPrediction(); |
317 |
0 |
new jalview.ws.jws1.SeqSearchWSClient(sh, af.getTitle(), msa, |
318 |
|
searchdb, af.getViewport().getAlignment().getDataset(), |
319 |
|
af); |
320 |
|
} |
321 |
|
}); |
322 |
|
} |
323 |
|
|
324 |
0 |
Enumeration e = newdbsrch.elements(); |
325 |
0 |
while (e.hasMoreElements()) |
326 |
|
{ |
327 |
0 |
Object el = e.nextElement(); |
328 |
0 |
if (el instanceof JMenu) |
329 |
|
{ |
330 |
0 |
wsmenu.add((JMenu) el); |
331 |
|
} |
332 |
|
else |
333 |
|
{ |
334 |
0 |
wsmenu.add((JMenuItem) el); |
335 |
|
} |
336 |
|
} |
337 |
|
|
338 |
|
} |
339 |
|
} |