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