refactored and ensured alCodonMappings are propagated to new alignments
authorjprocter <Jim Procter>
Thu, 30 Aug 2007 15:59:33 +0000 (15:59 +0000)
committerjprocter <Jim Procter>
Thu, 30 Aug 2007 15:59:33 +0000 (15:59 +0000)
src/jalview/ws/JPredThread.java
src/jalview/ws/MsaWSThread.java
src/jalview/ws/WSThread.java

index 0cac709..c2305e6 100644 (file)
@@ -350,13 +350,9 @@ class JPredThread
   JPredThread(WebserviceInfo wsinfo, String altitle, ext.vamsas.Jpred server,\r
               String wsurl, AlignmentView alview, AlignFrame alframe)\r
   {\r
-    super();\r
+    super(alframe, wsinfo, alview, wsurl);\r
     this.altitle = altitle;\r
     this.server = server;\r
-    this.wsInfo = wsinfo;\r
-    this.input = alview;\r
-    this.alignFrame = alframe;\r
-    WsUrl = wsurl;\r
   }\r
 \r
   JPredThread(WebserviceInfo wsinfo, String altitle, ext.vamsas.Jpred server,\r
index c40c23b..0dedce2 100644 (file)
@@ -312,14 +312,10 @@ class MsaWSThread
               AlignmentView alview,
               String wsname, boolean subgaps, boolean presorder)
   {
+    super(alFrame, wsinfo, alview, wsname, wsUrl);
     this.server = server;
-    this.WsUrl = wsUrl;
-    this.wsInfo = wsinfo;
-    this.WebServiceName = wsname;
-    this.input = alview;
     this.submitGaps = subgaps;
     this.preserveOrder = presorder;
-    this.alignFrame = alFrame;
   }
 
   /**
@@ -636,11 +632,13 @@ class MsaWSThread
     SequenceI[] alignment = (SequenceI[]) newview[0];
     ColumnSelection columnselection = (ColumnSelection) newview[1];
     Alignment al = new Alignment(alignment);
+
     if (dataset != null)
     {
       al.setDataset(dataset);
     }
 
+    propagateDatasetMappings(al);
     // JBNote- TODO: warn user if a block is input rather than aligned data ?
 
     if (newFrame)
@@ -716,6 +714,7 @@ class MsaWSThread
     }
   }
 
+
   public boolean canMergeResults()
   {
     return false;
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);
+    }
+  }
 }