1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.ws.rest; |
22 |
|
|
23 |
|
import java.util.Locale; |
24 |
|
|
25 |
|
import jalview.bin.Console; |
26 |
|
import jalview.datamodel.Alignment; |
27 |
|
import jalview.datamodel.AlignmentAnnotation; |
28 |
|
import jalview.datamodel.AlignmentI; |
29 |
|
import jalview.datamodel.AlignmentOrder; |
30 |
|
import jalview.datamodel.Annotation; |
31 |
|
import jalview.datamodel.HiddenColumns; |
32 |
|
import jalview.datamodel.SequenceGroup; |
33 |
|
import jalview.datamodel.SequenceI; |
34 |
|
import jalview.gui.AlignFrame; |
35 |
|
import jalview.gui.Desktop; |
36 |
|
import jalview.gui.PaintRefresher; |
37 |
|
import jalview.gui.WebserviceInfo; |
38 |
|
import jalview.io.NewickFile; |
39 |
|
import jalview.io.packed.JalviewDataset; |
40 |
|
import jalview.io.packed.JalviewDataset.AlignmentSet; |
41 |
|
import jalview.util.MessageManager; |
42 |
|
import jalview.ws.AWSThread; |
43 |
|
import jalview.ws.AWsJob; |
44 |
|
|
45 |
|
import java.awt.event.ActionEvent; |
46 |
|
import java.awt.event.ActionListener; |
47 |
|
import java.io.IOException; |
48 |
|
import java.util.ArrayList; |
49 |
|
import java.util.Hashtable; |
50 |
|
import java.util.List; |
51 |
|
import java.util.Map.Entry; |
52 |
|
|
53 |
|
import org.apache.axis.transport.http.HTTPConstants; |
54 |
|
import org.apache.http.Header; |
55 |
|
import org.apache.http.HttpEntity; |
56 |
|
import org.apache.http.HttpResponse; |
57 |
|
import org.apache.http.client.ClientProtocolException; |
58 |
|
import org.apache.http.client.methods.HttpGet; |
59 |
|
import org.apache.http.client.methods.HttpPost; |
60 |
|
import org.apache.http.client.methods.HttpRequestBase; |
61 |
|
import org.apache.http.entity.mime.HttpMultipartMode; |
62 |
|
import org.apache.http.entity.mime.MultipartEntity; |
63 |
|
import org.apache.http.impl.client.DefaultHttpClient; |
64 |
|
import org.apache.http.protocol.BasicHttpContext; |
65 |
|
import org.apache.http.protocol.HttpContext; |
66 |
|
import org.apache.http.util.EntityUtils; |
67 |
|
|
|
|
| 0% |
Uncovered Elements: 605 (605) |
Complexity: 143 |
Complexity Density: 0.36 |
|
68 |
|
public class RestJobThread extends AWSThread |
69 |
|
{ |
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
70 |
|
enum Stage |
71 |
|
{ |
72 |
|
SUBMIT, POLL |
73 |
|
} |
74 |
|
|
75 |
|
protected RestClient restClient; |
76 |
|
|
|
|
| 0% |
Uncovered Elements: 25 (25) |
Complexity: 7 |
Complexity Density: 0.47 |
|
77 |
0 |
public RestJobThread(RestClient restClient)... |
78 |
|
{ |
79 |
0 |
super(restClient.af, null, restClient._input, |
80 |
|
restClient.service.postUrl); |
81 |
0 |
this.restClient = restClient; |
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
|
91 |
0 |
if (!restClient.service.isHseparable()) |
92 |
|
{ |
93 |
0 |
jobs = new RestJob[1]; |
94 |
0 |
jobs[0] = new RestJob(0, this, |
95 |
|
restClient._input.getVisibleAlignment( |
96 |
|
restClient.service.getGapCharacter()), |
97 |
|
restClient._input.getVisibleContigs()); |
98 |
|
|
99 |
|
|
100 |
|
|
101 |
|
} |
102 |
|
else |
103 |
|
{ |
104 |
0 |
int[] viscontig = restClient._input.getVisibleContigs(); |
105 |
0 |
AlignmentI[] viscontigals = restClient._input |
106 |
|
.getVisibleContigAlignments( |
107 |
|
restClient.service.getGapCharacter()); |
108 |
0 |
if (viscontigals != null && viscontigals.length > 0) |
109 |
|
{ |
110 |
0 |
jobs = new RestJob[viscontigals.length]; |
111 |
0 |
for (int j = 0; j < jobs.length; j++) |
112 |
|
{ |
113 |
0 |
int[] visc = new int[] { viscontig[j * 2], viscontig[j * 2 + 1] }; |
114 |
0 |
if (j != 0) |
115 |
|
{ |
116 |
0 |
jobs[j] = new RestJob(j, this, viscontigals[j], visc); |
117 |
|
} |
118 |
|
else |
119 |
|
{ |
120 |
0 |
jobs[j] = new RestJob(0, this, viscontigals[j], visc); |
121 |
|
} |
122 |
|
} |
123 |
|
} |
124 |
|
} |
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
0 |
if (!restClient.service.isHseparable()) |
133 |
|
{ |
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
|
139 |
|
|
140 |
|
} |
141 |
|
else |
142 |
|
{ |
143 |
|
|
144 |
|
|
145 |
|
} |
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
} |
150 |
|
|
151 |
|
|
152 |
|
|
153 |
|
|
154 |
|
@param |
155 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
156 |
0 |
public void setWebServiceInfo(WebserviceInfo webserviceInfo)... |
157 |
|
{ |
158 |
0 |
wsInfo = webserviceInfo; |
159 |
0 |
for (int j = 0; j < jobs.length; j++) |
160 |
|
{ |
161 |
0 |
wsInfo.addJobPane(); |
162 |
|
|
163 |
0 |
if (jobs.length > 1) |
164 |
|
{ |
165 |
0 |
wsInfo.setProgressName("region " + jobs[j].getJobnum(), |
166 |
|
jobs[j].getJobnum()); |
167 |
|
} |
168 |
|
else |
169 |
|
{ |
170 |
0 |
wsInfo.setProgressText(jobs[j].getJobnum(), OutputHeader); |
171 |
|
} |
172 |
|
} |
173 |
|
} |
174 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
175 |
0 |
private String getStage(Stage stg)... |
176 |
|
{ |
177 |
0 |
if (stg == Stage.SUBMIT) |
178 |
|
{ |
179 |
0 |
return "submitting "; |
180 |
|
} |
181 |
0 |
if (stg == Stage.POLL) |
182 |
|
{ |
183 |
0 |
return "checking status of "; |
184 |
|
} |
185 |
|
|
186 |
0 |
return (" being confused about "); |
187 |
|
} |
188 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
189 |
0 |
private void doPoll(RestJob rj) throws Exception... |
190 |
|
{ |
191 |
0 |
String postUrl = rj.getPollUrl(); |
192 |
0 |
doHttpReq(Stage.POLL, rj, postUrl); |
193 |
|
} |
194 |
|
|
195 |
|
|
196 |
|
|
197 |
|
|
198 |
|
@throws |
199 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
200 |
0 |
public void doPost(RestJob rj) throws Exception... |
201 |
|
{ |
202 |
0 |
String postUrl = rj.getPostUrl(); |
203 |
0 |
doHttpReq(Stage.SUBMIT, rj, postUrl); |
204 |
0 |
wsInfo.invalidate(); |
205 |
|
} |
206 |
|
|
207 |
|
|
208 |
|
|
209 |
|
|
210 |
|
|
211 |
|
@param |
212 |
|
@param |
213 |
|
|
214 |
|
@param |
215 |
|
|
216 |
|
@throws |
217 |
|
|
|
|
| 0% |
Uncovered Elements: 74 (74) |
Complexity: 15 |
Complexity Density: 0.23 |
|
218 |
0 |
protected void doHttpReq(Stage stg, RestJob rj, String postUrl)... |
219 |
|
throws Exception |
220 |
|
{ |
221 |
0 |
StringBuffer respText = new StringBuffer(); |
222 |
|
|
223 |
|
|
224 |
0 |
HttpRequestBase request = null; |
225 |
0 |
String messages = ""; |
226 |
0 |
if (stg == Stage.SUBMIT) |
227 |
|
{ |
228 |
|
|
229 |
|
|
230 |
|
|
231 |
0 |
HttpPost htpost = new HttpPost(postUrl); |
232 |
0 |
MultipartEntity postentity = new MultipartEntity( |
233 |
|
HttpMultipartMode.STRICT); |
234 |
0 |
for (Entry<String, InputType> input : rj.getInputParams()) |
235 |
|
{ |
236 |
0 |
if (input.getValue().validFor(rj)) |
237 |
|
{ |
238 |
0 |
postentity.addPart(input.getKey(), |
239 |
|
input.getValue().formatForInput(rj)); |
240 |
|
} |
241 |
|
else |
242 |
|
{ |
243 |
0 |
messages += "Skipped an input (" + input.getKey() |
244 |
|
+ ") - Couldn't generate it from available data."; |
245 |
|
} |
246 |
|
} |
247 |
0 |
htpost.setEntity(postentity); |
248 |
0 |
request = htpost; |
249 |
|
} |
250 |
|
else |
251 |
|
{ |
252 |
0 |
request = new HttpGet(postUrl); |
253 |
|
} |
254 |
0 |
if (request != null) |
255 |
|
{ |
256 |
0 |
DefaultHttpClient httpclient = new DefaultHttpClient(); |
257 |
|
|
258 |
0 |
HttpContext localContext = new BasicHttpContext(); |
259 |
0 |
HttpResponse response = null; |
260 |
0 |
try |
261 |
|
{ |
262 |
0 |
response = httpclient.execute(request); |
263 |
|
} catch (ClientProtocolException he) |
264 |
|
{ |
265 |
0 |
rj.statMessage = "Web Protocol Exception when " + getStage(stg) |
266 |
|
+ "Job. <br>Problematic url was <a href=\"" |
267 |
|
+ request.getURI() + "\">" + request.getURI() |
268 |
|
+ "</a><br>See Console output for details."; |
269 |
0 |
rj.setAllowedServerExceptions(0); |
270 |
0 |
rj.error = true; |
271 |
0 |
Console.fatal("Unexpected REST Job " + getStage(stg) |
272 |
|
+ "exception for URL " + rj.rsd.postUrl); |
273 |
0 |
throw (he); |
274 |
|
} catch (IOException e) |
275 |
|
{ |
276 |
0 |
rj.statMessage = "IO Exception when " + getStage(stg) |
277 |
|
+ "Job. <br>Problematic url was <a href=\"" |
278 |
|
+ request.getURI() + "\">" + request.getURI() |
279 |
|
+ "</a><br>See Console output for details."; |
280 |
0 |
Console.warn("IO Exception for REST Job " + getStage(stg) |
281 |
|
+ "exception for URL " + rj.rsd.postUrl); |
282 |
|
|
283 |
0 |
throw (e); |
284 |
|
} |
285 |
0 |
switch (response.getStatusLine().getStatusCode()) |
286 |
|
{ |
287 |
0 |
case 200: |
288 |
0 |
rj.running = false; |
289 |
0 |
Console.debug("Processing result set."); |
290 |
0 |
processResultSet(rj, response, request); |
291 |
0 |
break; |
292 |
0 |
case 202: |
293 |
0 |
rj.statMessage = "<br>Job submitted successfully. Results available at this URL:\n" |
294 |
|
+ "<a href=" + rj.getJobId() + "\">" + rj.getJobId() |
295 |
|
+ "</a><br>"; |
296 |
0 |
rj.running = true; |
297 |
0 |
break; |
298 |
0 |
case 302: |
299 |
0 |
Header[] loc; |
300 |
0 |
if (!rj.isSubmitted() |
301 |
|
&& (loc = response |
302 |
|
.getHeaders(HTTPConstants.HEADER_LOCATION)) != null |
303 |
|
&& loc.length > 0) |
304 |
|
{ |
305 |
0 |
if (loc.length > 1) |
306 |
|
{ |
307 |
0 |
Console.warn("Ignoring additional " + (loc.length - 1) |
308 |
|
+ " location(s) provided in response header ( next one is '" |
309 |
|
+ loc[1].getValue() + "' )"); |
310 |
|
} |
311 |
0 |
rj.setJobId(loc[0].getValue()); |
312 |
0 |
rj.setSubmitted(true); |
313 |
|
} |
314 |
0 |
completeStatus(rj, response); |
315 |
0 |
break; |
316 |
0 |
case 500: |
317 |
|
|
318 |
0 |
rj.setSubmitted(true); |
319 |
0 |
rj.setAllowedServerExceptions(0); |
320 |
0 |
rj.setSubjobComplete(true); |
321 |
0 |
rj.error = true; |
322 |
0 |
rj.running = false; |
323 |
0 |
completeStatus(rj, response, |
324 |
|
"" + getStage(stg) + "failed. Reason below:\n"); |
325 |
0 |
break; |
326 |
0 |
default: |
327 |
|
|
328 |
|
|
329 |
0 |
Console.warn("Unhandled response status when " + getStage(stg) |
330 |
|
+ "for " + postUrl + ": " + response.getStatusLine()); |
331 |
0 |
rj.error = true; |
332 |
0 |
rj.setAllowedServerExceptions(0); |
333 |
0 |
rj.setSubjobComplete(true); |
334 |
0 |
rj.setSubmitted(true); |
335 |
0 |
try |
336 |
|
{ |
337 |
0 |
completeStatus(rj, response, "" + getStage(stg) |
338 |
|
+ " resulted in an unexpected server response.<br/>Url concerned was <a href=\"" |
339 |
|
+ request.getURI() + "\">" + request.getURI() |
340 |
|
+ "</a><br/>Filtered response content below:<br/>"); |
341 |
|
} catch (IOException e) |
342 |
|
{ |
343 |
0 |
Console.debug("IOException when consuming unhandled response", e); |
344 |
|
} |
345 |
0 |
; |
346 |
|
} |
347 |
|
} |
348 |
|
} |
349 |
|
|
350 |
|
|
351 |
|
|
352 |
|
|
353 |
|
@param |
354 |
|
@param |
355 |
|
@param |
356 |
|
|
357 |
|
|
358 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.33 |
|
359 |
0 |
private void processResultSet(RestJob rj, HttpResponse con,... |
360 |
|
HttpRequestBase req) |
361 |
|
{ |
362 |
0 |
if (rj.statMessage == null) |
363 |
|
{ |
364 |
0 |
rj.statMessage = ""; |
365 |
|
} |
366 |
0 |
rj.statMessage += "Job Complete.\n"; |
367 |
0 |
try |
368 |
|
{ |
369 |
0 |
rj.resSet = new HttpResultSet(rj, con, req); |
370 |
0 |
rj.gotresult = true; |
371 |
|
} catch (IOException e) |
372 |
|
{ |
373 |
0 |
rj.statMessage += "Couldn't parse results. Failed."; |
374 |
0 |
rj.error = true; |
375 |
0 |
rj.gotresult = false; |
376 |
|
} |
377 |
|
} |
378 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
379 |
0 |
private void completeStatus(RestJob rj, HttpResponse con)... |
380 |
|
throws IOException |
381 |
|
{ |
382 |
0 |
completeStatus(rj, con, null); |
383 |
|
|
384 |
|
} |
385 |
|
|
|
|
| 0% |
Uncovered Elements: 27 (27) |
Complexity: 7 |
Complexity Density: 0.37 |
|
386 |
0 |
private void completeStatus(RestJob rj, HttpResponse con, String prefix)... |
387 |
|
throws IOException |
388 |
|
{ |
389 |
0 |
StringBuffer sb = new StringBuffer(); |
390 |
0 |
if (prefix != null) |
391 |
|
{ |
392 |
0 |
sb.append(prefix); |
393 |
|
} |
394 |
0 |
; |
395 |
0 |
if (rj.statMessage != null && rj.statMessage.length() > 0) |
396 |
|
{ |
397 |
0 |
sb.append(rj.statMessage); |
398 |
|
} |
399 |
0 |
HttpEntity en = con.getEntity(); |
400 |
|
|
401 |
|
|
402 |
|
|
403 |
0 |
String f; |
404 |
0 |
StringBuffer content = new StringBuffer(f = EntityUtils.toString(en)); |
405 |
0 |
f = f.toLowerCase(Locale.ROOT); |
406 |
0 |
int body = f.indexOf("<body"); |
407 |
0 |
if (body > -1) |
408 |
|
{ |
409 |
0 |
content.delete(0, f.indexOf(">", body) + 1); |
410 |
|
} |
411 |
0 |
if (body > -1 && sb.length() > 0) |
412 |
|
{ |
413 |
0 |
sb.append("\n"); |
414 |
0 |
content.insert(0, sb); |
415 |
0 |
sb = null; |
416 |
|
} |
417 |
0 |
f = null; |
418 |
0 |
rj.statMessage = content.toString(); |
419 |
|
} |
420 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
421 |
0 |
@Override... |
422 |
|
public void pollJob(AWsJob job) throws Exception |
423 |
|
{ |
424 |
0 |
assert (job instanceof RestJob); |
425 |
0 |
jalview.bin.Console.errPrintln("Debug RestJob: Polling Job"); |
426 |
0 |
doPoll((RestJob) job); |
427 |
|
} |
428 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 4 |
Complexity Density: 0.4 |
|
429 |
0 |
@Override... |
430 |
|
public void StartJob(AWsJob job) |
431 |
|
{ |
432 |
0 |
assert (job instanceof RestJob); |
433 |
0 |
try |
434 |
|
{ |
435 |
0 |
jalview.bin.Console.errPrintln("Debug RestJob: Posting Job"); |
436 |
0 |
doPost((RestJob) job); |
437 |
|
} catch (NoValidInputDataException erex) |
438 |
|
{ |
439 |
0 |
job.setSubjobComplete(true); |
440 |
0 |
job.setSubmitted(true); |
441 |
0 |
((RestJob) job).statMessage = "<br>It looks like there was a problem with the data sent to the service :<br>" |
442 |
|
+ erex.getMessage() + "\n"; |
443 |
0 |
((RestJob) job).error = true; |
444 |
|
|
445 |
|
} catch (Exception ex) |
446 |
|
{ |
447 |
0 |
job.setSubjobComplete(true); |
448 |
0 |
job.setAllowedServerExceptions(-1); |
449 |
0 |
Console.error("Exception when trying to start Rest Job.", ex); |
450 |
|
} |
451 |
|
} |
452 |
|
|
|
|
| 0% |
Uncovered Elements: 31 (31) |
Complexity: 8 |
Complexity Density: 0.32 |
|
453 |
0 |
@Override... |
454 |
|
public void parseResult() |
455 |
|
{ |
456 |
|
|
457 |
|
|
458 |
0 |
Console.warn("Rest job result parser is currently INCOMPLETE!"); |
459 |
0 |
int validres = 0; |
460 |
0 |
for (RestJob rj : (RestJob[]) jobs) |
461 |
|
{ |
462 |
0 |
if (rj.hasResponse() && rj.resSet != null && rj.resSet.isValid()) |
463 |
|
{ |
464 |
0 |
String ln = null; |
465 |
0 |
try |
466 |
|
{ |
467 |
0 |
Console.debug("Parsing data for job " + rj.getJobId()); |
468 |
0 |
rj.parseResultSet(); |
469 |
0 |
if (rj.hasResults()) |
470 |
|
{ |
471 |
0 |
validres++; |
472 |
|
} |
473 |
0 |
Console.debug("Finished parsing data for job " + rj.getJobId()); |
474 |
|
|
475 |
|
} catch (Error ex) |
476 |
|
{ |
477 |
0 |
Console.warn( |
478 |
|
"Failed to finish parsing data for job " + rj.getJobId()); |
479 |
0 |
ex.printStackTrace(); |
480 |
|
} catch (Exception ex) |
481 |
|
{ |
482 |
0 |
Console.warn( |
483 |
|
"Failed to finish parsing data for job " + rj.getJobId()); |
484 |
0 |
ex.printStackTrace(); |
485 |
|
} finally |
486 |
|
{ |
487 |
0 |
rj.error = true; |
488 |
0 |
rj.statMessage = "Error whilst parsing data for this job.<br>URL for job response is :<a href=\"" |
489 |
|
+ rj.resSet.getUrl() + "\">" + rj.resSet.getUrl() |
490 |
|
+ "</a><br>"; |
491 |
|
} |
492 |
|
} |
493 |
|
} |
494 |
0 |
if (validres > 0) |
495 |
|
{ |
496 |
|
|
497 |
|
|
498 |
|
|
499 |
|
|
500 |
|
|
501 |
|
|
502 |
|
|
503 |
|
|
504 |
0 |
if (true) |
505 |
|
{ |
506 |
|
|
507 |
0 |
wsInfo.setViewResultsImmediatly(true); |
508 |
|
} |
509 |
|
else |
510 |
|
{ |
511 |
|
|
512 |
|
} |
513 |
|
|
514 |
|
|
515 |
|
|
516 |
|
|
517 |
0 |
wsInfo.showResultsNewFrame.addActionListener(new ActionListener() |
518 |
|
{ |
519 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
520 |
0 |
@Override... |
521 |
|
public void actionPerformed(ActionEvent e) |
522 |
|
{ |
523 |
0 |
realiseResults(false); |
524 |
|
} |
525 |
|
|
526 |
|
}); |
527 |
0 |
wsInfo.mergeResults.addActionListener(new ActionListener() |
528 |
|
{ |
529 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
530 |
0 |
@Override... |
531 |
|
public void actionPerformed(ActionEvent e) |
532 |
|
{ |
533 |
0 |
realiseResults(true); |
534 |
|
} |
535 |
|
|
536 |
|
}); |
537 |
|
|
538 |
0 |
wsInfo.setResultsReady(); |
539 |
|
} |
540 |
|
else |
541 |
|
{ |
542 |
|
|
543 |
0 |
wsInfo.setStatus(wsInfo.STATE_STOPPED_ERROR); |
544 |
0 |
wsInfo.setFinishedNoResults(); |
545 |
|
} |
546 |
|
} |
547 |
|
|
548 |
|
|
549 |
|
|
550 |
|
|
551 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
552 |
|
private enum AddDataTo |
553 |
|
{ |
554 |
|
|
555 |
|
|
556 |
|
|
557 |
|
currentView, |
558 |
|
|
559 |
|
|
560 |
|
|
561 |
|
newView, |
562 |
|
|
563 |
|
|
564 |
|
|
565 |
|
|
566 |
|
newAlignment |
567 |
|
}; |
568 |
|
|
|
|
| 0% |
Uncovered Elements: 280 (280) |
Complexity: 57 |
Complexity Density: 0.31 |
|
569 |
0 |
public void realiseResults(boolean merge)... |
570 |
|
{ |
571 |
|
|
572 |
|
|
573 |
|
|
574 |
|
|
575 |
|
|
576 |
|
|
577 |
|
|
578 |
|
|
579 |
0 |
ArrayList<jalview.gui.AlignmentPanel> destPanels = new ArrayList<jalview.gui.AlignmentPanel>(); |
580 |
|
|
581 |
|
|
582 |
|
|
583 |
|
|
584 |
0 |
ArrayList<AddDataTo> resultDest = new ArrayList<AddDataTo>(); |
585 |
|
|
586 |
|
|
587 |
|
|
588 |
0 |
boolean newAlignment = false; |
589 |
|
|
590 |
|
|
591 |
|
|
592 |
0 |
char gapCharacter = restClient.av.getGapCharacter(); |
593 |
|
|
594 |
|
|
595 |
|
|
596 |
|
|
597 |
|
|
598 |
|
|
599 |
0 |
boolean hsepjobs = restClient.service.isHseparable(); |
600 |
0 |
boolean vsepjobs = restClient.service.isVseparable(); |
601 |
|
|
602 |
0 |
int numAlSets = 0, als = 0; |
603 |
0 |
List<AlignmentI> destAls = new ArrayList<AlignmentI>(); |
604 |
0 |
List<jalview.datamodel.HiddenColumns> destColsel = new ArrayList<jalview.datamodel.HiddenColumns>(); |
605 |
0 |
List<List<NewickFile>> trees = new ArrayList<List<NewickFile>>(); |
606 |
|
|
607 |
0 |
do |
608 |
|
{ |
609 |
|
|
610 |
|
|
611 |
|
|
612 |
|
|
613 |
|
|
614 |
|
|
615 |
|
|
616 |
|
|
617 |
|
|
618 |
0 |
int[][] ordermap = new int[jobs.length][]; |
619 |
0 |
SequenceI[][] rseqs = new SequenceI[jobs.length][]; |
620 |
0 |
AlignmentOrder[] orders = new AlignmentOrder[jobs.length]; |
621 |
0 |
AlignmentAnnotation[][] alan = new AlignmentAnnotation[jobs.length][]; |
622 |
0 |
SequenceGroup[][] sgrp = new SequenceGroup[jobs.length][]; |
623 |
|
|
624 |
0 |
for (int j = 0; j < jobs.length; j++) |
625 |
|
{ |
626 |
0 |
RestJob rj = (RestJob) jobs[j]; |
627 |
0 |
if (rj.hasResults()) |
628 |
|
{ |
629 |
0 |
JalviewDataset rset = rj.context; |
630 |
0 |
if (rset.hasAlignments()) |
631 |
|
{ |
632 |
0 |
if (numAlSets < rset.getAl().size()) |
633 |
|
{ |
634 |
0 |
numAlSets = rset.getAl().size(); |
635 |
|
} |
636 |
0 |
if (als < rset.getAl().size() |
637 |
|
&& rset.getAl().get(als).isModified()) |
638 |
|
{ |
639 |
|
|
640 |
|
|
641 |
|
|
642 |
|
|
643 |
|
|
644 |
0 |
AlignmentSet alset = rset.getAl().get(als); |
645 |
0 |
alan[j] = alset.al.getAlignmentAnnotation(); |
646 |
0 |
if (alset.al.getGroups() != null) |
647 |
|
{ |
648 |
0 |
sgrp[j] = new SequenceGroup[alset.al.getGroups().size()]; |
649 |
0 |
alset.al.getGroups().toArray(sgrp[j]); |
650 |
|
} |
651 |
|
else |
652 |
|
{ |
653 |
0 |
sgrp[j] = null; |
654 |
|
} |
655 |
0 |
orders[j] = new AlignmentOrder(alset.al); |
656 |
0 |
rseqs[j] = alset.al.getSequencesArray(); |
657 |
0 |
ordermap[j] = rj.getOrderMap(); |
658 |
|
|
659 |
|
|
660 |
|
|
661 |
|
|
662 |
0 |
if (alset.trees != null) |
663 |
|
{ |
664 |
0 |
trees.add(new ArrayList<NewickFile>(alset.trees)); |
665 |
|
} |
666 |
|
else |
667 |
|
{ |
668 |
0 |
trees.add(new ArrayList<NewickFile>()); |
669 |
|
} |
670 |
|
} |
671 |
|
} |
672 |
|
} |
673 |
|
} |
674 |
|
|
675 |
0 |
int nvertsep = 0, nvertseps = 1; |
676 |
0 |
if (vsepjobs) |
677 |
|
{ |
678 |
|
|
679 |
|
|
680 |
|
|
681 |
|
|
682 |
|
|
683 |
|
|
684 |
|
|
685 |
|
|
686 |
|
} |
687 |
|
|
688 |
|
|
689 |
|
|
690 |
0 |
int vrestjob = 0; |
691 |
|
|
692 |
0 |
ArrayList<SequenceGroup> visgrps = new ArrayList<SequenceGroup>(); |
693 |
0 |
Hashtable<String, SequenceGroup> groupNames = new Hashtable<String, SequenceGroup>(); |
694 |
0 |
ArrayList<AlignmentAnnotation> visAlAn = null; |
695 |
0 |
for (nvertsep = 0; nvertsep < nvertseps; nvertsep++) |
696 |
|
{ |
697 |
|
|
698 |
|
|
699 |
|
{ |
700 |
|
|
701 |
|
|
702 |
|
|
703 |
|
|
704 |
|
|
705 |
0 |
int nrj = vrestjob; |
706 |
|
|
707 |
0 |
RestJob rj = (RestJob) jobs[nrj]; |
708 |
0 |
int contigs[] = input.getVisibleContigs(); |
709 |
0 |
AlignmentI destAl = null; |
710 |
0 |
jalview.datamodel.HiddenColumns destHCs = null; |
711 |
|
|
712 |
0 |
if (als == 0 && rj.isInputContextModified()) |
713 |
|
{ |
714 |
|
|
715 |
|
|
716 |
|
|
717 |
0 |
if (destAls.size() > als) |
718 |
|
{ |
719 |
0 |
destAl = destAls.get(als); |
720 |
|
} |
721 |
|
else |
722 |
|
{ |
723 |
0 |
if (!restClient.isAlignmentModified() && merge) |
724 |
|
{ |
725 |
0 |
destAl = restClient.av.getAlignment(); |
726 |
0 |
destHCs = restClient.av.getAlignment().getHiddenColumns(); |
727 |
0 |
resultDest.add(restClient.isShowResultsInNewView() |
728 |
|
? AddDataTo.newView |
729 |
|
: AddDataTo.currentView); |
730 |
0 |
destPanels.add(restClient.recoverAlignPanelForView()); |
731 |
|
} |
732 |
|
else |
733 |
|
{ |
734 |
0 |
newAlignment = true; |
735 |
|
|
736 |
0 |
Object[] idat = input |
737 |
|
.getAlignmentAndHiddenColumns(gapCharacter); |
738 |
0 |
destAl = new Alignment((SequenceI[]) idat[0]); |
739 |
0 |
destHCs = (HiddenColumns) idat[1]; |
740 |
0 |
resultDest.add(AddDataTo.newAlignment); |
741 |
|
|
742 |
|
|
743 |
|
} |
744 |
0 |
destAls.add(destAl); |
745 |
0 |
destColsel.add(destHCs); |
746 |
|
} |
747 |
|
} |
748 |
|
else |
749 |
|
{ |
750 |
|
|
751 |
|
|
752 |
0 |
if (destAls.size() > als) |
753 |
|
{ |
754 |
0 |
if (!vsepjobs) |
755 |
|
{ |
756 |
|
|
757 |
|
|
758 |
0 |
Console.warn( |
759 |
|
"dealing with multiple alignment products returned by non-vertically separable service."); |
760 |
|
} |
761 |
|
|
762 |
|
|
763 |
0 |
destAl = destAls.get(als); |
764 |
0 |
destHCs = destColsel.get(als); |
765 |
|
} |
766 |
|
else |
767 |
|
{ |
768 |
0 |
Object[] newview; |
769 |
|
|
770 |
0 |
if (!hsepjobs) |
771 |
|
{ |
772 |
|
|
773 |
|
|
774 |
|
|
775 |
0 |
SequenceI[][] nsq = splitSeqsOnVisibleContigs(rseqs[nrj], |
776 |
|
contigs, gapCharacter); |
777 |
0 |
AlignmentOrder alo[] = new AlignmentOrder[nsq.length]; |
778 |
0 |
for (int no = 0; no < alo.length; no++) |
779 |
|
{ |
780 |
0 |
alo[no] = new AlignmentOrder(orders[nrj].getOrder()); |
781 |
|
} |
782 |
0 |
newview = input.getUpdatedView(nsq, orders, gapCharacter); |
783 |
|
} |
784 |
|
else |
785 |
|
{ |
786 |
|
|
787 |
|
|
788 |
|
|
789 |
|
|
790 |
0 |
newview = input.getUpdatedView(rseqs, orders, gapCharacter); |
791 |
|
} |
792 |
0 |
destAl = new Alignment((SequenceI[]) newview[0]); |
793 |
0 |
destHCs = (HiddenColumns) newview[1]; |
794 |
0 |
newAlignment = true; |
795 |
|
|
796 |
|
|
797 |
0 |
destAls.add(destAl); |
798 |
0 |
destColsel.add(destHCs); |
799 |
0 |
resultDest.add(AddDataTo.newAlignment); |
800 |
0 |
throw new Error( |
801 |
|
MessageManager.getString("error.implementation_error") |
802 |
|
+ "TODO: "); |
803 |
|
} |
804 |
|
} |
805 |
|
|
806 |
|
|
807 |
|
|
808 |
0 |
int initnrj = nrj; |
809 |
|
|
810 |
0 |
for (int ncnt = 0; ncnt < contigs.length; ncnt += 2) |
811 |
|
{ |
812 |
0 |
if (!hsepjobs) |
813 |
|
{ |
814 |
|
|
815 |
|
|
816 |
|
} |
817 |
|
else |
818 |
|
{ |
819 |
|
|
820 |
|
|
821 |
0 |
if (ncnt > 0) |
822 |
|
{ |
823 |
0 |
nrj++; |
824 |
|
} |
825 |
|
|
826 |
|
|
827 |
|
|
828 |
|
|
829 |
|
} |
830 |
0 |
if (sgrp[nrj] != null) |
831 |
|
{ |
832 |
0 |
for (SequenceGroup sg : sgrp[nrj]) |
833 |
|
{ |
834 |
0 |
boolean recovered = false; |
835 |
0 |
SequenceGroup exsg = null; |
836 |
0 |
if (sg.getName() != null) |
837 |
|
{ |
838 |
0 |
exsg = groupNames.get(sg.getName()); |
839 |
|
} |
840 |
0 |
if (exsg == null) |
841 |
|
{ |
842 |
0 |
exsg = new SequenceGroup(sg); |
843 |
0 |
groupNames.put(exsg.getName(), exsg); |
844 |
0 |
visgrps.add(exsg); |
845 |
0 |
exsg.setStartRes(sg.getStartRes() + contigs[ncnt]); |
846 |
0 |
exsg.setEndRes(sg.getEndRes() + contigs[ncnt]); |
847 |
|
} |
848 |
|
else |
849 |
|
{ |
850 |
0 |
recovered = true; |
851 |
|
} |
852 |
|
|
853 |
|
|
854 |
|
|
855 |
|
|
856 |
|
|
857 |
|
{ |
858 |
0 |
for (SequenceI oseq : sg.getSequences(null)) |
859 |
|
{ |
860 |
0 |
SequenceI nseq = getNewSeq(oseq, rseqs[nrj], |
861 |
|
ordermap[nrj], destAl); |
862 |
0 |
if (nseq != null) |
863 |
|
{ |
864 |
0 |
if (!recovered) |
865 |
|
{ |
866 |
0 |
exsg.deleteSequence(oseq, false); |
867 |
|
} |
868 |
0 |
exsg.addSequence(nseq, false); |
869 |
|
} |
870 |
|
else |
871 |
|
{ |
872 |
0 |
Console.warn( |
873 |
|
"Couldn't resolve original sequence for new sequence."); |
874 |
|
} |
875 |
|
} |
876 |
0 |
if (sg.hasSeqrep()) |
877 |
|
{ |
878 |
0 |
if (exsg.getSeqrep() == sg.getSeqrep()) |
879 |
|
{ |
880 |
|
|
881 |
0 |
SequenceI oseq = sg.getSeqrep(); |
882 |
0 |
SequenceI nseq = getNewSeq(oseq, rseqs[nrj], |
883 |
|
ordermap[nrj], destAl); |
884 |
0 |
if (nseq != null) |
885 |
|
{ |
886 |
0 |
exsg.setSeqrep(nseq); |
887 |
|
} |
888 |
|
} |
889 |
|
} |
890 |
|
} |
891 |
0 |
if (recovered) |
892 |
|
{ |
893 |
|
|
894 |
|
|
895 |
0 |
int start = sg.getStartRes() + contigs[ncnt], |
896 |
|
end = sg.getEndRes() + contigs[ncnt]; |
897 |
0 |
if (start < exsg.getStartRes()) |
898 |
|
{ |
899 |
0 |
exsg.setStartRes(start); |
900 |
|
} |
901 |
0 |
if (end > exsg.getEndRes()) |
902 |
|
{ |
903 |
0 |
exsg.setEndRes(end); |
904 |
|
} |
905 |
|
} |
906 |
|
} |
907 |
|
} |
908 |
|
} |
909 |
|
|
910 |
0 |
nrj = initnrj; |
911 |
|
|
912 |
0 |
for (int ncnt = 0; ncnt < contigs.length; ncnt += 2) |
913 |
|
{ |
914 |
0 |
if (!hsepjobs) |
915 |
|
{ |
916 |
|
|
917 |
|
|
918 |
|
} |
919 |
|
else |
920 |
|
{ |
921 |
|
|
922 |
|
|
923 |
0 |
if (ncnt > 0) |
924 |
|
{ |
925 |
0 |
nrj++; |
926 |
|
} |
927 |
|
} |
928 |
|
|
929 |
|
|
930 |
0 |
if (alan[nrj] != null) |
931 |
|
{ |
932 |
0 |
for (int an = 0; an < alan[nrj].length; an++) |
933 |
|
{ |
934 |
0 |
SequenceI sqass = null; |
935 |
0 |
SequenceGroup grass = null; |
936 |
0 |
if (alan[nrj][an].sequenceRef != null) |
937 |
|
{ |
938 |
|
|
939 |
|
|
940 |
0 |
sqass = getNewSeq(alan[nrj][an].sequenceRef, rseqs[nrj], |
941 |
|
ordermap[nrj], destAl); |
942 |
|
} |
943 |
0 |
if (alan[nrj][an].groupRef != null) |
944 |
|
{ |
945 |
|
|
946 |
|
|
947 |
0 |
grass = groupNames.get(alan[nrj][an].groupRef.getName()); |
948 |
0 |
if (grass == null) |
949 |
|
{ |
950 |
0 |
Console.error( |
951 |
|
"Couldn't relocate group referemce for group " |
952 |
|
+ alan[nrj][an].groupRef.getName()); |
953 |
|
} |
954 |
|
} |
955 |
0 |
if (visAlAn == null) |
956 |
|
{ |
957 |
0 |
visAlAn = new ArrayList<AlignmentAnnotation>(); |
958 |
|
} |
959 |
0 |
AlignmentAnnotation visan = null; |
960 |
0 |
for (AlignmentAnnotation v : visAlAn) |
961 |
|
{ |
962 |
0 |
if (v.label != null |
963 |
|
&& v.label.equals(alan[nrj][an].label)) |
964 |
|
{ |
965 |
0 |
visan = v; |
966 |
|
} |
967 |
|
} |
968 |
0 |
if (visan == null) |
969 |
|
{ |
970 |
0 |
visan = new AlignmentAnnotation(alan[nrj][an]); |
971 |
|
|
972 |
0 |
visan.annotations = new Annotation[input.getWidth()]; |
973 |
0 |
visan.groupRef = grass; |
974 |
0 |
visan.sequenceRef = sqass; |
975 |
0 |
visAlAn.add(visan); |
976 |
|
} |
977 |
0 |
if (contigs[ncnt] |
978 |
|
+ alan[nrj][an].annotations.length > visan.annotations.length) |
979 |
|
{ |
980 |
|
|
981 |
0 |
Annotation[] newannv = new Annotation[contigs[ncnt] |
982 |
|
+ alan[nrj][an].annotations.length]; |
983 |
0 |
System.arraycopy(visan.annotations, 0, newannv, 0, |
984 |
|
visan.annotations.length); |
985 |
0 |
visan.annotations = newannv; |
986 |
|
} |
987 |
|
|
988 |
0 |
System.arraycopy(alan[nrj][an].annotations, 0, |
989 |
|
visan.annotations, contigs[ncnt], |
990 |
|
alan[nrj][an].annotations.length); |
991 |
|
|
992 |
|
} |
993 |
|
} |
994 |
|
|
995 |
0 |
if (trees.get(nrj).size() > 0) |
996 |
|
{ |
997 |
0 |
for (NewickFile nf : trees.get(nrj)) |
998 |
|
{ |
999 |
|
|
1000 |
|
|
1001 |
0 |
Console.error( |
1002 |
|
"Tree recovery from restjob not yet implemented."); |
1003 |
|
} |
1004 |
|
} |
1005 |
|
} |
1006 |
|
} |
1007 |
|
} |
1008 |
0 |
if (visAlAn != null) |
1009 |
|
{ |
1010 |
0 |
for (AlignmentAnnotation v : visAlAn) |
1011 |
|
{ |
1012 |
0 |
destAls.get(als).addAnnotation(v); |
1013 |
|
} |
1014 |
|
} |
1015 |
0 |
if (visgrps != null) |
1016 |
|
{ |
1017 |
0 |
for (SequenceGroup sg : visgrps) |
1018 |
|
{ |
1019 |
0 |
destAls.get(als).addGroup(sg); |
1020 |
|
} |
1021 |
|
} |
1022 |
0 |
} while (++als < numAlSets); |
1023 |
|
|
1024 |
|
|
1025 |
|
|
1026 |
|
|
1027 |
|
|
1028 |
0 |
AlignFrame destaf = restClient.recoverAlignFrameForView(); |
1029 |
|
|
1030 |
|
|
1031 |
|
|
1032 |
0 |
jalview.gui.AlignmentPanel destPanel = restClient |
1033 |
|
.recoverAlignPanelForView(); |
1034 |
0 |
als = 0; |
1035 |
0 |
for (AddDataTo action : resultDest) |
1036 |
|
{ |
1037 |
0 |
AlignmentI destal; |
1038 |
0 |
HiddenColumns destcs; |
1039 |
0 |
String alTitle = MessageManager |
1040 |
|
.formatMessage("label.webservice_job_title_on", new String[] |
1041 |
|
{ restClient.service.details.Action, |
1042 |
|
restClient.service.details.Name, restClient.viewTitle }); |
1043 |
0 |
switch (action) |
1044 |
|
{ |
1045 |
0 |
case newAlignment: |
1046 |
0 |
destal = destAls.get(als); |
1047 |
0 |
destcs = destColsel.get(als); |
1048 |
0 |
destaf = new AlignFrame(destal, destcs, AlignFrame.DEFAULT_WIDTH, |
1049 |
|
AlignFrame.DEFAULT_HEIGHT); |
1050 |
0 |
PaintRefresher.Refresh(destaf, |
1051 |
|
destaf.getViewport().getSequenceSetId()); |
1052 |
|
|
1053 |
|
|
1054 |
|
|
1055 |
|
|
1056 |
|
|
1057 |
|
|
1058 |
|
|
1059 |
|
|
1060 |
|
|
1061 |
|
|
1062 |
|
|
1063 |
|
|
1064 |
|
|
1065 |
|
|
1066 |
|
|
1067 |
|
|
1068 |
|
|
1069 |
|
|
1070 |
|
|
1071 |
|
|
1072 |
|
|
1073 |
0 |
Desktop.addInternalFrame(destaf, alTitle, AlignFrame.DEFAULT_WIDTH, |
1074 |
|
AlignFrame.DEFAULT_HEIGHT); |
1075 |
|
|
1076 |
0 |
break; |
1077 |
0 |
case newView: |
1078 |
|
|
1079 |
0 |
break; |
1080 |
0 |
case currentView: |
1081 |
0 |
break; |
1082 |
|
} |
1083 |
|
} |
1084 |
0 |
if (!newAlignment) |
1085 |
|
{ |
1086 |
0 |
if (restClient.isShowResultsInNewView()) |
1087 |
|
{ |
1088 |
|
|
1089 |
|
} |
1090 |
|
} |
1091 |
|
else |
1092 |
|
{ |
1093 |
|
|
1094 |
|
} |
1095 |
|
|
1096 |
|
|
1097 |
|
|
1098 |
|
|
1099 |
|
|
1100 |
|
|
1101 |
|
|
1102 |
|
|
1103 |
|
|
1104 |
|
|
1105 |
|
|
1106 |
|
|
1107 |
|
|
1108 |
|
|
1109 |
|
|
1110 |
|
|
1111 |
|
|
1112 |
|
|
1113 |
|
|
1114 |
|
|
1115 |
|
|
1116 |
|
|
1117 |
|
|
1118 |
|
|
1119 |
|
|
1120 |
|
|
1121 |
|
|
1122 |
|
|
1123 |
|
|
1124 |
|
|
1125 |
|
|
1126 |
|
|
1127 |
|
|
1128 |
|
|
1129 |
|
|
1130 |
|
|
1131 |
|
|
1132 |
|
|
1133 |
|
|
1134 |
|
|
1135 |
|
|
1136 |
|
|
1137 |
|
|
1138 |
|
|
1139 |
|
|
1140 |
|
|
1141 |
|
} |
1142 |
|
|
1143 |
|
|
1144 |
|
|
1145 |
|
|
1146 |
|
|
1147 |
|
@param |
1148 |
|
@param |
1149 |
|
@param |
1150 |
|
|
1151 |
|
@return |
1152 |
|
|
|
|
| 0% |
Uncovered Elements: 52 (52) |
Complexity: 13 |
Complexity Density: 0.43 |
|
1153 |
0 |
private SequenceI[][] splitSeqsOnVisibleContigs(SequenceI[] sequenceIs,... |
1154 |
|
int[] contigs, char gapChar) |
1155 |
|
{ |
1156 |
0 |
int nvc = contigs == null ? 1 : contigs.length / 2; |
1157 |
0 |
SequenceI[][] blocks = new SequenceI[nvc][]; |
1158 |
0 |
if (contigs == null) |
1159 |
|
{ |
1160 |
0 |
blocks[0] = new SequenceI[sequenceIs.length]; |
1161 |
0 |
System.arraycopy(sequenceIs, 0, blocks[0], 0, sequenceIs.length); |
1162 |
|
} |
1163 |
|
else |
1164 |
|
{ |
1165 |
|
|
1166 |
|
|
1167 |
0 |
char[] gapset = null; |
1168 |
0 |
int start = 0, width = 0; |
1169 |
0 |
for (int c = 0; c < nvc; c++) |
1170 |
|
{ |
1171 |
0 |
width = contigs[c * 2 + 1] - contigs[c * 2] + 1; |
1172 |
0 |
for (int s = 0; s < sequenceIs.length; s++) |
1173 |
|
{ |
1174 |
0 |
int end = sequenceIs[s].getLength(); |
1175 |
0 |
if (start < end) |
1176 |
|
{ |
1177 |
0 |
if (start + width < end) |
1178 |
|
{ |
1179 |
0 |
blocks[c][s] = sequenceIs[s].getSubSequence(start, |
1180 |
|
start + width); |
1181 |
|
} |
1182 |
|
else |
1183 |
|
{ |
1184 |
0 |
blocks[c][s] = sequenceIs[s].getSubSequence(start, end); |
1185 |
0 |
String sq = blocks[c][s].getSequenceAsString(); |
1186 |
0 |
for (int n = start + width; n > end; n--) |
1187 |
|
{ |
1188 |
0 |
sq += gapChar; |
1189 |
|
} |
1190 |
|
} |
1191 |
|
} |
1192 |
|
else |
1193 |
|
{ |
1194 |
0 |
if (gapset == null || gapset.length < width) |
1195 |
|
{ |
1196 |
0 |
char ng[] = new char[width]; |
1197 |
0 |
int gs = 0; |
1198 |
0 |
if (gapset != null) |
1199 |
|
{ |
1200 |
0 |
System.arraycopy(gapset, 0, ng, 0, gs = gapset.length); |
1201 |
|
} |
1202 |
0 |
while (gs < ng.length) |
1203 |
|
{ |
1204 |
0 |
ng[gs++] = gapChar; |
1205 |
|
} |
1206 |
|
} |
1207 |
0 |
blocks[c][s] = sequenceIs[s].getSubSequence(end, end); |
1208 |
0 |
blocks[c][s].setSequence(gapset.toString().substring(0, width)); |
1209 |
|
} |
1210 |
|
} |
1211 |
0 |
if (c > 0) |
1212 |
|
{ |
1213 |
|
|
1214 |
0 |
start += contigs[c * 2 + 1] - contigs[c * 2]; |
1215 |
|
} |
1216 |
|
} |
1217 |
|
} |
1218 |
0 |
return blocks; |
1219 |
|
} |
1220 |
|
|
1221 |
|
|
1222 |
|
|
1223 |
|
|
1224 |
|
|
1225 |
|
@param |
1226 |
|
@param |
1227 |
|
@param |
1228 |
|
@param |
1229 |
|
@return |
1230 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 5 |
Complexity Density: 0.83 |
|
1231 |
0 |
private SequenceI getNewSeq(SequenceI oseq, SequenceI[] sequenceIs,... |
1232 |
|
int[] is, AlignmentI destAl) |
1233 |
|
{ |
1234 |
0 |
int p = 0; |
1235 |
0 |
while (p < sequenceIs.length && sequenceIs[p] != oseq) |
1236 |
|
{ |
1237 |
0 |
p++; |
1238 |
|
} |
1239 |
0 |
if (p < sequenceIs.length && p < destAl.getHeight()) |
1240 |
|
{ |
1241 |
0 |
return destAl.getSequenceAt(is[p]); |
1242 |
|
} |
1243 |
0 |
return null; |
1244 |
|
} |
1245 |
|
|
1246 |
|
|
1247 |
|
|
1248 |
|
@return |
1249 |
|
|
|
|
| 0% |
Uncovered Elements: 26 (26) |
Complexity: 7 |
Complexity Density: 0.44 |
|
1250 |
0 |
public boolean isValid()... |
1251 |
|
{ |
1252 |
0 |
ArrayList<String> _warnings = new ArrayList<String>(); |
1253 |
0 |
boolean validt = true; |
1254 |
0 |
if (jobs != null) |
1255 |
|
{ |
1256 |
0 |
for (RestJob rj : (RestJob[]) jobs) |
1257 |
|
{ |
1258 |
0 |
if (!rj.hasValidInput()) |
1259 |
|
{ |
1260 |
|
|
1261 |
0 |
jalview.bin.Console.errPrintln("Job " + rj.getJobnum() |
1262 |
|
+ " has invalid input. ( " + rj.getStatus() + ")"); |
1263 |
0 |
if (rj.hasStatus() && !_warnings.contains(rj.getStatus())) |
1264 |
|
{ |
1265 |
0 |
_warnings.add(rj.getStatus()); |
1266 |
|
} |
1267 |
0 |
validt = false; |
1268 |
|
} |
1269 |
|
} |
1270 |
|
} |
1271 |
0 |
if (!validt) |
1272 |
|
{ |
1273 |
0 |
warnings = ""; |
1274 |
0 |
for (String st : _warnings) |
1275 |
|
{ |
1276 |
0 |
if (warnings.length() > 0) |
1277 |
|
{ |
1278 |
0 |
warnings += "\n"; |
1279 |
|
} |
1280 |
0 |
warnings += st; |
1281 |
|
|
1282 |
|
} |
1283 |
|
} |
1284 |
0 |
return validt; |
1285 |
|
} |
1286 |
|
|
1287 |
|
protected String warnings; |
1288 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1289 |
0 |
public boolean hasWarnings()... |
1290 |
|
{ |
1291 |
|
|
1292 |
0 |
return warnings != null && warnings.length() > 0; |
1293 |
|
} |
1294 |
|
|
1295 |
|
|
1296 |
|
|
1297 |
|
|
1298 |
|
@return |
1299 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 3 |
|
1300 |
0 |
public String getWarnings()... |
1301 |
|
{ |
1302 |
0 |
return isValid() ? "Job can be started. No warnings." |
1303 |
0 |
: hasWarnings() ? warnings : ""; |
1304 |
|
} |
1305 |
|
|
1306 |
|
} |