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