- public void updateParameters(final WsParamSetI newpreset,
- final List<Argument> newarguments)
- {
- if (false) // || calcMan.isWorking(this))
- {
- new Thread(new Runnable()
- {
- @Override
- public void run()
- {
-
- try
- {
- Thread.sleep(200);
- } catch (InterruptedException x)
- {
- }
- ;
- updateParameters(newpreset, newarguments);
- }
- }).start();
- }
- else
- {
- preset = newpreset;
- arguments = newarguments;
- calcMan.startWorker(this);
- }
- }
-
- public List<Option> getJabaArguments()
- {
- List<Option> newargs = new ArrayList<Option>();
- if (preset != null && preset instanceof JabaWsParamSet)
- {
- newargs.addAll(((JabaWsParamSet) preset).getjabaArguments());
- }
- if (arguments != null && arguments.size() > 0)
- {
- for (Argument rg : arguments)
- {
- if (Option.class.isAssignableFrom(rg.getClass()))
- {
- newargs.add((Option) rg);
- }
- }
- }
- return newargs;
- }
-
- @Override
- public void run()
- {
- if (aaservice == null)
- {
- return;
- }
- long progressId = -1;
-
- String rslt = "JOB NOT DEFINED";
-
- try
- {
- if (checkDone())
- {
- return;
- }
- List<compbio.data.sequence.FastaSequence> seqs = getInputSequences(alignViewport
- .getAlignment());
-
- if (seqs == null)
- {
- calcMan.workerComplete(this);
- return;
- }
-
- AlignmentAnnotation[] aa = alignViewport.getAlignment()
- .getAlignmentAnnotation();
- if (guiProgress != null)
- {
- guiProgress.setProgressBar("JABA " + getServiceActionText(),
- progressId = System.currentTimeMillis());
- }
- if (preset == null && arguments==null)
- {
- rslt = aaservice.analize(seqs);
- }
- else
- {
- try
- {
- rslt = aaservice.customAnalize(seqs, getJabaArguments());
- } catch (WrongParameterException x)
- {
- throw new JobSubmissionException(
- "Invalid paremeter set. Check Jalview implementation.", x);
-
- }
- }
- boolean finished = false;
- long rpos = 0;
- do
- {
- JobStatus status = aaservice.getJobStatus(rslt);
- if (status.equals(JobStatus.FINISHED))
- {
- finished = true;
- }
- if (calcMan.isPending(this) && this instanceof AAConsClient)
- {
- finished = true;
- // cancel this job and yield to the new job
- try
- {
- if (aaservice.cancelJob(rslt))
- {
- System.err.println("Cancelled AACon job: " + rslt);
- }
- else
- {
- System.err.println("FAILED TO CANCELL AACon job: " + rslt);
- }
-
- } catch (Exception x)
- {
-
- }
-
- return;
- }
- long cpos;
- ChunkHolder stats;
- do
- {
- cpos = rpos;
- try
- {
- stats = aaservice.pullExecStatistics(rslt, rpos);
- } catch (Exception x)
- {
-
- if (x.getMessage().contains(
- "Position in a file could not be negative!"))
- {
- // squash index out of bounds exception- seems to happen for
- // disorder predictors which don't (apparently) produce any
- // progress information and JABA server throws an exception
- // because progress length is -1.
- stats = null;
- }
- else
- {
- throw x;
- }
- }
- if (stats != null)
- {
- System.out.print(stats.getChunk());
- rpos = stats.getNextPosition();
- }
- } while (stats != null && rpos > cpos);
-
- if (!finished && status.equals(JobStatus.FAILED))
- {
- try
- {
- Thread.sleep(200);
- } catch (InterruptedException x)
- {
- }
- ;
- }
-
- } while (!finished);
- try
- {
- Thread.sleep(200);
- } catch (InterruptedException x)
- {
- }
- ;
- scoremanager = aaservice.getAnnotation(rslt);
- if (scoremanager != null)
- {
- updateResultAnnotation(true);
- }
- } catch (JobSubmissionException x)
- {
-
- System.err.println("submission error:");
- x.printStackTrace();
- calcMan.workerCannotRun(this);
- } catch (ResultNotAvailableException x)
- {
- System.err.println("collection error:\nJob ID: " + rslt);
- x.printStackTrace();
- calcMan.workerCannotRun(this);
-
- } catch (OutOfMemoryError error)
- {
- calcMan.workerCannotRun(this);
-
- // consensus = null;
- // hconsensus = null;
- ap.raiseOOMWarning(getServiceActionText(), error);
- } catch (Exception x)
- {
- calcMan.workerCannotRun(this);
-
- // consensus = null;
- // hconsensus = null;
- System.err
- .println("Blacklisting worker due to unexpected exception:");
- x.printStackTrace();
- } finally
- {
-
- calcMan.workerComplete(this);
- if (ap != null)
- {
- calcMan.workerComplete(this);
- if (guiProgress != null && progressId!=-1)
- {
- guiProgress.setProgressBar("", progressId);
- }
- ap.paintAlignment(true);
- }
- }
-
- }
-
- @Override
- public void updateAnnotation()