First patch for * JAL-493
[jalview.git] / src / jalview / ws / AWSThread.java
similarity index 52%
rename from src/jalview/ws/WSThread.java
rename to src/jalview/ws/AWSThread.java
index 65c1c96..1de2c01 100644 (file)
-/*\r
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5)\r
- * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle\r
- * \r
- * This file is part of Jalview.\r
- * \r
- * Jalview is free software: you can redistribute it and/or\r
- * modify it under the terms of the GNU General Public License \r
- * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\r
- * \r
- * Jalview is distributed in the hope that it will be useful, but \r
- * WITHOUT ANY WARRANTY; without even the implied warranty \r
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR \r
- * PURPOSE.  See the GNU General Public License for more details.\r
- * \r
- * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.\r
- */\r
-package jalview.ws;\r
-\r
-import javax.swing.*;\r
-\r
-import jalview.bin.*;\r
-import jalview.datamodel.*;\r
-import jalview.gui.*;\r
-import jalview.gui.FeatureRenderer.FeatureRendererSettings;\r
-\r
-public abstract class WSThread extends Thread\r
-{\r
-  /**\r
-   * Generic properties for Web Service Client threads.\r
-   */\r
-  /**\r
-   * view that this job was associated with\r
-   */\r
-  AlignmentI currentView = null;\r
-\r
-  /**\r
-   * feature settings from view that job was associated with\r
-   */\r
-  FeatureRendererSettings featureSettings = null;\r
-\r
-  /**\r
-   * metadata about this web service\r
-   */\r
-  WebserviceInfo wsInfo = null;\r
-\r
-  /**\r
-   * original input data for this job\r
-   */\r
-  AlignmentView input = null;\r
-\r
-  /**\r
-   * dataset sequence relationships to be propagated onto new results\r
-   */\r
-  AlignedCodonFrame[] codonframe = null;\r
-\r
-  /**\r
-   * are there jobs still running in this thread.\r
-   */\r
-  boolean jobComplete = false;\r
-\r
-  abstract class WSJob\r
-  {\r
-    /**\r
-     * Generic properties for an individual job within a Web Service Client\r
-     * thread\r
-     */\r
-    int jobnum = 0; // WebServiceInfo pane for this job\r
-\r
-    String jobId; // ws job ticket\r
-\r
-    /**\r
-     * has job been cancelled\r
-     */\r
-    boolean cancelled = false;\r
-\r
-    /**\r
-     * number of exceptions left before job dies\r
-     */\r
-    int allowedServerExceptions = 3;\r
-\r
-    /**\r
-     * has job been submitted\r
-     */\r
-    boolean submitted = false;\r
-\r
-    /**\r
-     * are all sub-jobs complete\r
-     */\r
-    boolean subjobComplete = false;\r
-\r
-    /**\r
-     * \r
-     * @return true if job has completed and valid results are available\r
-     */\r
-    abstract boolean hasResults();\r
-\r
-    /**\r
-     * \r
-     * @return boolean true if job can be submitted.\r
-     */\r
-    abstract boolean hasValidInput();\r
-\r
-    /**\r
-     * The last result object returned by the service.\r
-     */\r
-    vamsas.objects.simple.Result result;\r
-  }\r
-\r
-  class JobStateSummary\r
-  {\r
-    /**\r
-     * number of jobs running\r
-     */\r
-    int running = 0;\r
-\r
-    /**\r
-     * number of jobs queued\r
-     */\r
-    int queuing = 0;\r
-\r
-    /**\r
-     * number of jobs finished\r
-     */\r
-    int finished = 0;\r
-\r
-    /**\r
-     * number of jobs failed\r
-     */\r
-    int error = 0;\r
-\r
-    /**\r
-     * number of jobs stopped due to server error\r
-     */\r
-    int serror = 0;\r
-\r
-    /**\r
-     * number of jobs cancelled\r
-     */\r
-    int cancelled = 0;\r
-\r
-    /**\r
-     * number of jobs finished with results\r
-     */\r
-    int results = 0;\r
-\r
-    /**\r
-     * processes WSJob and updates job status counters and WebService status\r
-     * displays\r
-     * \r
-     * @param wsInfo\r
-     * @param OutputHeader\r
-     * @param j\r
-     */\r
-    void updateJobPanelState(WebserviceInfo wsInfo, String OutputHeader,\r
-            WSJob j)\r
-    {\r
-      if (j.result != null)\r
-      {\r
-        String progheader = "";\r
-        // Parse state of job[j]\r
-        if (j.result.isRunning())\r
-        {\r
-          running++;\r
-          wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_RUNNING);\r
-        }\r
-        else if (j.result.isQueued())\r
-        {\r
-          queuing++;\r
-          wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_QUEUING);\r
-        }\r
-        else if (j.result.isFinished())\r
-        {\r
-          finished++;\r
-          j.subjobComplete = true;\r
-          if (j.hasResults())\r
-          {\r
-            results++;\r
-          }\r
-          wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_STOPPED_OK);\r
-        }\r
-        else if (j.result.isFailed())\r
-        {\r
-          progheader += "Job failed.\n";\r
-          j.subjobComplete = true;\r
-          wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_STOPPED_ERROR);\r
-          error++;\r
-        }\r
-        else if (j.result.isServerError())\r
-        {\r
-          serror++;\r
-          j.subjobComplete = true;\r
-          wsInfo.setStatus(j.jobnum,\r
-                  WebserviceInfo.STATE_STOPPED_SERVERERROR);\r
-        }\r
-        else if (j.result.isBroken() || j.result.isFailed())\r
-        {\r
-          error++;\r
-          j.subjobComplete = true;\r
-          wsInfo.setStatus(j.jobnum, WebserviceInfo.STATE_STOPPED_ERROR);\r
-        }\r
-        // and pass on any sub-job messages to the user\r
-        wsInfo.setProgressText(j.jobnum, OutputHeader);\r
-        wsInfo.appendProgressText(j.jobnum, progheader);\r
-        if (j.result.getStatus() != null)\r
-        {\r
-          wsInfo.appendProgressText(j.jobnum, j.result.getStatus());\r
-        }\r
-      }\r
-      else\r
-      {\r
-        if (j.submitted && j.subjobComplete)\r
-        {\r
-          if (j.allowedServerExceptions == 0)\r
-          {\r
-            serror++;\r
-          }\r
-          else if (j.result == null)\r
-          {\r
-            error++;\r
-          }\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-  /**\r
-   * one or more jobs being managed by this thread.\r
-   */\r
-  WSJob jobs[] = null;\r
-\r
-  /**\r
-   * full name of service\r
-   */\r
-  String WebServiceName = null;\r
-\r
-  String OutputHeader;\r
-\r
-  String WsUrl = null;\r
-\r
-  /**\r
-   * query web service for status of job. on return, job.result must not be null\r
-   * - if it is then it will be assumed that the job status query timed out and\r
-   * a server exception will be logged.\r
-   * \r
-   * @param job\r
-   * @throws Exception\r
-   *           will be logged as a server exception for this job\r
-   */\r
-  abstract void pollJob(WSJob job) throws Exception;\r
-\r
-  public void run()\r
-  {\r
-    JobStateSummary jstate = null;\r
-    if (jobs == null)\r
-    {\r
-      jobComplete = true;\r
-    }\r
-    while (!jobComplete)\r
-    {\r
-      jstate = new JobStateSummary();\r
-      for (int j = 0; j < jobs.length; j++)\r
-      {\r
-\r
-        if (!jobs[j].submitted && jobs[j].hasValidInput())\r
-        {\r
-          StartJob(jobs[j]);\r
-        }\r
-\r
-        if (jobs[j].submitted && !jobs[j].subjobComplete)\r
-        {\r
-          try\r
-          {\r
-            pollJob(jobs[j]);\r
-            if (jobs[j].result == null)\r
-            {\r
-              throw (new Exception(\r
-                      "Timed out when communicating with server\nTry again later.\n"));\r
-            }\r
-            jalview.bin.Cache.log.debug("Job " + j + " Result state "\r
-                    + jobs[j].result.getState() + "(ServerError="\r
-                    + jobs[j].result.isServerError() + ")");\r
-          } catch (Exception ex)\r
-          {\r
-            // Deal with Transaction exceptions\r
-            wsInfo.appendProgressText(jobs[j].jobnum, "\n" + WebServiceName\r
-                    + " Server exception!\n" + ex.getMessage());\r
-            Cache.log.warn(WebServiceName + " job(" + jobs[j].jobnum\r
-                    + ") Server exception: " + ex.getMessage());\r
-\r
-            if (jobs[j].allowedServerExceptions > 0)\r
-            {\r
-              jobs[j].allowedServerExceptions--;\r
-              Cache.log.debug("Sleeping after a server exception.");\r
-              try\r
-              {\r
-                Thread.sleep(5000);\r
-              } catch (InterruptedException ex1)\r
-              {\r
-              }\r
-            }\r
-            else\r
-            {\r
-              Cache.log.warn("Dropping job " + j + " " + jobs[j].jobId);\r
-              jobs[j].subjobComplete = true;\r
-              wsInfo.setStatus(jobs[j].jobnum,\r
-                      WebserviceInfo.STATE_STOPPED_SERVERERROR);\r
-            }\r
-          } catch (OutOfMemoryError er)\r
-          {\r
-            jobComplete = true;\r
-            jobs[j].subjobComplete = true;\r
-            jobs[j].result = null; // may contain out of date result object\r
-            wsInfo.setStatus(jobs[j].jobnum,\r
-                    WebserviceInfo.STATE_STOPPED_ERROR);\r
-            Cache.log.error("Out of memory when retrieving Job " + j\r
-                    + " id:" + WsUrl + "/" + jobs[j].jobId, er);\r
-            new jalview.gui.OOMWarning("retrieving result for "\r
-                    + WebServiceName, er);\r
-            System.gc();\r
-          }\r
-        }\r
-        jstate.updateJobPanelState(wsInfo, OutputHeader, jobs[j]);\r
-      }\r
-      // Decide on overall state based on collected jobs[] states\r
-      if (jstate.running > 0)\r
-      {\r
-        wsInfo.setStatus(WebserviceInfo.STATE_RUNNING);\r
-      }\r
-      else if (jstate.queuing > 0)\r
-      {\r
-        wsInfo.setStatus(WebserviceInfo.STATE_QUEUING);\r
-      }\r
-      else\r
-      {\r
-        jobComplete = true;\r
-        if (jstate.finished > 0)\r
-        {\r
-          wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_OK);\r
-        }\r
-        else if (jstate.error > 0)\r
-        {\r
-          wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_ERROR);\r
-        }\r
-        else if (jstate.serror > 0)\r
-        {\r
-          wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_SERVERERROR);\r
-        }\r
-      }\r
-      if (!jobComplete)\r
-      {\r
-        try\r
-        {\r
-          Thread.sleep(5000);\r
-        } catch (InterruptedException e)\r
-        {\r
-          Cache.log\r
-                  .debug("Interrupted sleep waiting for next job poll.", e);\r
-        }\r
-        // System.out.println("I'm alive "+alTitle);\r
-      }\r
-    }\r
-    if (jobComplete && jobs != null)\r
-    {\r
-      parseResult(); // tidy up and make results available to user\r
-    }\r
-    else\r
-    {\r
-      Cache.log\r
-              .debug("WebServiceJob poll loop finished with no jobs created.");\r
-      wsInfo.setFinishedNoResults();\r
-    }\r
-  }\r
-\r
-  /**\r
-   * submit job to web service\r
-   * \r
-   * @param job\r
-   */\r
-  abstract void StartJob(WSJob job);\r
-\r
-  /**\r
-   * process the set of WSJob objects into a set of results, and tidy up.\r
-   */\r
-  abstract void parseResult();\r
-\r
-  /**\r
-   * helper function to conserve dataset references to sequence objects returned\r
-   * from web services 1. Propagates AlCodonFrame data from\r
-   * <code>codonframe</code> to <code>al</code>\r
-   * \r
-   * @param al\r
-   */\r
-  protected void propagateDatasetMappings(Alignment al)\r
-  {\r
-    if (codonframe != null)\r
-    {\r
-      SequenceI[] alignment = al.getSequencesArray();\r
-      for (int sq = 0; sq < alignment.length; sq++)\r
-      {\r
-        for (int i = 0; i < codonframe.length; i++)\r
-        {\r
-          if (codonframe[i] != null\r
-                  && codonframe[i].involvesSequence(alignment[sq]))\r
-          {\r
-            al.addCodonFrame(codonframe[i]);\r
-            codonframe[i] = null;\r
-            break;\r
-          }\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-  /**\r
-   * \r
-   * @param alignFrame\r
-   *          reference for copying mappings across\r
-   * @param wsInfo\r
-   *          gui attachment point\r
-   * @param input\r
-   *          input data for the calculation\r
-   * @param webServiceName\r
-   *          name of service\r
-   * @param wsUrl\r
-   *          url of the service being invoked\r
-   */\r
-  public WSThread(AlignFrame alignFrame, WebserviceInfo wsinfo,\r
-          AlignmentView input, String webServiceName, String wsUrl)\r
-  {\r
-    this(alignFrame, wsinfo, input, wsUrl);\r
-    WebServiceName = webServiceName;\r
-  }\r
-\r
-  char defGapChar = '-';\r
-\r
-  /**\r
-   * \r
-   * @return gap character to use for any alignment generation\r
-   */\r
-  public char getGapChar()\r
-  {\r
-    return defGapChar;\r
-  }\r
-\r
-  /**\r
-   * \r
-   * @param alframe\r
-   *          - reference for copying mappings and display styles across\r
-   * @param wsinfo2\r
-   *          - gui attachment point\r
-   * @param alview\r
-   *          - input data for the calculation\r
-   * @param wsurl2\r
-   *          - url of the service being invoked\r
-   */\r
-  public WSThread(AlignFrame alframe, WebserviceInfo wsinfo2,\r
-          AlignmentView alview, String wsurl2)\r
-  {\r
-    super();\r
-    // this.alignFrame = alframe;\r
-    currentView = alframe.getCurrentView().getAlignment();\r
-    featureSettings = alframe.getFeatureRenderer().getSettings();\r
-    defGapChar = alframe.getViewport().getGapCharacter();\r
-    this.wsInfo = wsinfo2;\r
-    this.input = alview;\r
-    WsUrl = wsurl2;\r
-    if (alframe != null)\r
-    {\r
-      AlignedCodonFrame[] cf = alframe.getViewport().getAlignment()\r
-              .getCodonFrames();\r
-      if (cf != null)\r
-      {\r
-        codonframe = new AlignedCodonFrame[cf.length];\r
-        System.arraycopy(cf, 0, codonframe, 0, cf.length);\r
-      }\r
-    }\r
-  }\r
-}\r
+package jalview.ws;
+
+import jalview.bin.Cache;
+import jalview.datamodel.AlignedCodonFrame;
+import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.AlignmentView;
+import jalview.datamodel.SequenceI;
+import jalview.gui.AlignFrame;
+import jalview.gui.WebserviceInfo;
+import jalview.gui.FeatureRenderer.FeatureRendererSettings;
+
+public abstract class AWSThread extends Thread
+{
+
+  /**
+   * view that this job was associated with
+   */
+  protected AlignmentI currentView = null;
+  /**
+   * feature settings from view that job was associated with
+   */
+  protected FeatureRendererSettings featureSettings = null;
+  /**
+   * metadata about this web service
+   */
+  protected WebserviceInfo wsInfo = null;
+  /**
+   * original input data for this job
+   */
+  protected AlignmentView input = null;
+  /**
+   * dataset sequence relationships to be propagated onto new results
+   */
+  protected AlignedCodonFrame[] codonframe = null;
+  /**
+   * are there jobs still running in this thread.
+   */
+  protected boolean jobComplete = false;
+  /**
+   * one or more jobs being managed by this thread.
+   */
+  protected AWsJob jobs[] = null;
+  /**
+   * full name of service
+   */
+  protected String WebServiceName = null;
+  protected char defGapChar = '-';
+  /**
+   * header prepended to all output from job
+   */
+  protected String OutputHeader;
+
+  /**
+   * only used when reporting a web service out of memory error - the job ID will be concatenated to the URL
+   */
+  protected String WsUrl = null;
+
+  /**
+   * generic web service job/subjob poll loop 
+   */
+  public void run()
+  {
+    JobStateSummary jstate = null;
+    if (jobs == null)
+    {
+      jobComplete = true;
+    }
+    while (!jobComplete)
+    {
+      jstate = new JobStateSummary();
+      for (int j = 0; j < jobs.length; j++)
+      {
+
+        if (!jobs[j].submitted && jobs[j].hasValidInput())
+        {
+          StartJob(jobs[j]);
+        }
+
+        if (jobs[j].submitted && !jobs[j].subjobComplete)
+        {
+          try
+          {
+            pollJob(jobs[j]);
+            if (!jobs[j].hasResponse())
+            {
+              throw (new Exception(
+                      "Timed out when communicating with server\nTry again later.\n"));
+            }
+            jalview.bin.Cache.log.debug("Job " + j + " Result state "
+                    + jobs[j].getState() + "(ServerError="
+                    + jobs[j].isServerError() + ")");
+          } catch (Exception ex)
+          {
+            if (Cache.log.isDebugEnabled())
+            {
+              Cache.log.debug(ex);
+            }
+            // Deal with Transaction exceptions
+            wsInfo.appendProgressText(jobs[j].jobnum, "\n" + WebServiceName
+                    + " Server exception!\n" + ex.getMessage());
+            Cache.log.warn(WebServiceName + " job(" + jobs[j].jobnum
+                    + ") Server exception: " + ex.getMessage());
+
+            if (jobs[j].allowedServerExceptions > 0)
+            {
+              jobs[j].allowedServerExceptions--;
+              Cache.log.debug("Sleeping after a server exception.");
+              try
+              {
+                Thread.sleep(5000);
+              } catch (InterruptedException ex1)
+              {
+              }
+            }
+            else
+            {
+              Cache.log.warn("Dropping job " + j + " " + jobs[j].jobId);
+              jobs[j].subjobComplete = true;
+              wsInfo.setStatus(jobs[j].jobnum,
+                      WebserviceInfo.STATE_STOPPED_SERVERERROR);
+            }
+          } catch (OutOfMemoryError er)
+          {
+            jobComplete = true;
+            jobs[j].subjobComplete = true;
+            jobs[j].clearResponse(); // may contain out of date result data
+            wsInfo.setStatus(jobs[j].jobnum,
+                    WebserviceInfo.STATE_STOPPED_ERROR);
+            Cache.log.error("Out of memory when retrieving Job " + j
+                    + " id:" + WsUrl + "/" + jobs[j].jobId, er);
+            new jalview.gui.OOMWarning("retrieving result for "
+                    + WebServiceName, er);
+            System.gc();
+          }
+        }
+        jstate.updateJobPanelState(wsInfo, OutputHeader, jobs[j]);
+      }
+      // Decide on overall state based on collected jobs[] states
+      if (jstate.running > 0)
+      {
+        wsInfo.setStatus(WebserviceInfo.STATE_RUNNING);
+      }
+      else if (jstate.queuing > 0)
+      {
+        wsInfo.setStatus(WebserviceInfo.STATE_QUEUING);
+      }
+      else
+      {
+        jobComplete = true;
+        if (jstate.finished > 0)
+        {
+          wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_OK);
+        }
+        else if (jstate.error > 0)
+        {
+          wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_ERROR);
+        }
+        else if (jstate.serror > 0)
+        {
+          wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_SERVERERROR);
+        }
+      }
+      if (!jobComplete)
+      {
+        try
+        {
+          Thread.sleep(5000);
+        } catch (InterruptedException e)
+        {
+          Cache.log
+                  .debug("Interrupted sleep waiting for next job poll.", e);
+        }
+        // System.out.println("I'm alive "+alTitle);
+      }
+    }
+    if (jobComplete && jobs != null)
+    {
+      parseResult(); // tidy up and make results available to user
+    }
+    else
+    {
+      Cache.log
+              .debug("WebServiceJob poll loop finished with no jobs created.");
+      wsInfo.setFinishedNoResults();
+    }
+  }
+
+
+  public AWSThread()
+  {
+    super();
+  }
+
+  public AWSThread(Runnable target)
+  {
+    super(target);
+  }
+
+  public AWSThread(String name)
+  {
+    super(name);
+  }
+
+  public AWSThread(ThreadGroup group, Runnable target)
+  {
+    super(group, target);
+  }
+
+  public AWSThread(ThreadGroup group, String name)
+  {
+    super(group, name);
+  }
+
+  public AWSThread(Runnable target, String name)
+  {
+    super(target, name);
+  }
+
+  public AWSThread(ThreadGroup group, Runnable target, String name)
+  {
+    super(group, target, name);
+  }
+
+  /**
+   * query web service for status of job. on return, job.result must not be null
+   * - if it is then it will be assumed that the job status query timed out and
+   * a server exception will be logged.
+   * 
+   * @param job
+   * @throws Exception
+   *           will be logged as a server exception for this job
+   */
+  public abstract void pollJob(AWsJob job) throws Exception;
+
+  /**
+   * submit job to web service
+   * 
+   * @param job
+   */
+  public abstract void StartJob(AWsJob job);
+
+  /**
+   * process the set of AWsJob objects into a set of results, and tidy up.
+   */
+  public abstract void parseResult();
+
+  /**
+   * helper function to conserve dataset references to sequence objects returned
+   * from web services 1. Propagates AlCodonFrame data from
+   * <code>codonframe</code> to <code>al</code>
+   * TODO: refactor to datamodel
+   * @param al
+   */
+  public void propagateDatasetMappings(Alignment al)
+  {
+    if (codonframe != null)
+    {
+      SequenceI[] alignment = al.getSequencesArray();
+      for (int sq = 0; sq < alignment.length; sq++)
+      {
+        for (int i = 0; i < codonframe.length; i++)
+        {
+          if (codonframe[i] != null
+                  && codonframe[i].involvesSequence(alignment[sq]))
+          {
+            al.addCodonFrame(codonframe[i]);
+            codonframe[i] = null;
+            break;
+          }
+        }
+      }
+    }
+  }
+
+  public AWSThread(ThreadGroup group, Runnable target, String name,
+          long stackSize)
+  {
+    super(group, target, name, stackSize);
+  }
+
+  /**
+   * 
+   * @return gap character to use for any alignment generation
+   */
+  public char getGapChar()
+  {
+    return defGapChar;
+  }
+
+  /**
+   * 
+   * @param alignFrame
+   *          reference for copying mappings across
+   * @param wsInfo
+   *          gui attachment point
+   * @param input
+   *          input data for the calculation
+   * @param webServiceName
+   *          name of service
+   * @param wsUrl
+   *          url of the service being invoked
+   */
+  public AWSThread(AlignFrame alignFrame, WebserviceInfo wsinfo,
+          AlignmentView input, String webServiceName, String wsUrl)
+  {
+    this(alignFrame, wsinfo, input, wsUrl);
+    WebServiceName = webServiceName;
+  }
+
+  /**
+   * 
+   * @param alframe
+   *          - reference for copying mappings and display styles across
+   * @param wsinfo2
+   *          - gui attachment point
+   * @param alview
+   *          - input data for the calculation
+   * @param wsurl2
+   *          - url of the service being invoked
+   */
+  public AWSThread(AlignFrame alframe, WebserviceInfo wsinfo2,
+          AlignmentView alview, String wsurl2)
+  {
+    super();
+    // this.alignFrame = alframe;
+    currentView = alframe.getCurrentView().getAlignment();
+    featureSettings = alframe.getFeatureRenderer().getSettings();
+    defGapChar = alframe.getViewport().getGapCharacter();
+    this.wsInfo = wsinfo2;
+    this.input = alview;
+    WsUrl = wsurl2;
+    if (alframe != null)
+    {
+      AlignedCodonFrame[] cf = alframe.getViewport().getAlignment()
+              .getCodonFrames();
+      if (cf != null)
+      {
+        codonframe = new AlignedCodonFrame[cf.length];
+        System.arraycopy(cf, 0, codonframe, 0, cf.length);
+      }
+    }
+  }
+}