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