refactored and ensured alCodonMappings are propagated to new alignments
[jalview.git] / src / jalview / ws / WSThread.java
index 6b6c483..a23dfe1 100644 (file)
@@ -33,7 +33,9 @@ public abstract class WSThread
   AlignFrame alignFrame = null;
   WebserviceInfo wsInfo = null;
   AlignmentView input = null;
+  AlignedCodonFrame[] codonframe = null;
   boolean jobComplete = false;
+  
   abstract class WSJob
   {
     /**
@@ -281,4 +283,64 @@ public abstract class WSThread
   abstract void StartJob(WSJob job);
 
   abstract void parseResult();
+
+  protected 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;
+          }
+        }
+      }
+    }
+  }
+
+  /**
+   * 
+   * @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 WSThread(AlignFrame alignFrame, WebserviceInfo wsinfo,
+          AlignmentView input, String webServiceName,
+          String wsUrl)
+  {
+    this(alignFrame, wsinfo, input, wsUrl);
+    WebServiceName = webServiceName;
+  }
+
+  /**
+   * 
+   * @param alframe - reference for copying mappings across
+   * @param wsinfo2 - gui attachment point
+   * @param alview - input data for the calculation
+   * @param wsurl2 - url of the service being invoked
+   */
+  public WSThread(AlignFrame alframe, WebserviceInfo wsinfo2,
+          AlignmentView alview, String wsurl2)
+  {
+    super();
+    this.alignFrame = alframe;
+    this.wsInfo = wsinfo2;
+    this.input = alview;
+    WsUrl = wsurl2;
+    if (alignFrame!=null)
+    {
+      AlignedCodonFrame[] cf = alignFrame.getViewport().getAlignment().getCodonFrames();
+      codonframe = new AlignedCodonFrame[cf.length];
+      System.arraycopy(cf, 0, codonframe, 0, cf.length);
+    }
+  }
 }