incremental refinement of results parsing
authorjprocter <Jim Procter>
Wed, 15 Dec 2010 14:54:18 +0000 (14:54 +0000)
committerjprocter <Jim Procter>
Wed, 15 Dec 2010 14:54:18 +0000 (14:54 +0000)
src/jalview/ws/rest/RestJobThread.java

index 67ccd3a..c100a72 100644 (file)
@@ -7,6 +7,7 @@ import jalview.gui.AlignFrame;
 import jalview.gui.WebserviceInfo;
 import jalview.io.packed.DataProvider;
 import jalview.io.packed.JalviewDataset;
+import jalview.io.packed.JalviewDataset.AlignmentSet;
 import jalview.io.packed.ParsePackedSet;
 import jalview.io.packed.SimpleDataProvider;
 import jalview.io.packed.DataProvider.JvDataType;
@@ -47,7 +48,8 @@ public class RestJobThread extends AWSThread
 
   public RestJobThread(RestClient restClient)
   {
-    super();
+    super(restClient.af, null, restClient._input,
+            restClient.service.postUrl);
     this.restClient = restClient; // may not be needed
     // Test Code
     // minimal job - submit given input and parse result onto alignment as
@@ -497,34 +499,17 @@ public class RestJobThread extends AWSThread
      * annotation/features.
      */
     /**
-     * alignments. New alignments are added to dataset, and subsequently
-     * annotated/visualised accordingly. 1. New alignment frame created for new
-     * alignment. Decide if any vis settings should be inherited from old
-     * alignment frame (e.g. sequence ordering ?). 2. Subsequent data added to
-     * alignment as below:
+     * alignment panels derived from each alignment set returned by service. 
      */
+    ArrayList<jalview.gui.AlignmentPanel> destPanels = new ArrayList<jalview.gui.AlignmentPanel>();
     /**
-     * annotation update to original/newly created context alignment: 1.
-     * identify alignment where annotation is to be loaded onto. 2. Add
-     * annotation, excluding any duplicates. 3. Ensure annotation is visible on
-     * alignment - honouring ordering given by file.
+     * current pane being worked with
      */
+    jalview.gui.AlignmentPanel destPanel;
     /**
-     * features updated to original or newly created context alignment: 1.
-     * Features are(or were already) added to dataset. 2. Feature settings
-     * modified to ensure all features are displayed - honouring any ordering
-     * given by result file. Consider merging action with the code used by the
-     * DAS fetcher to update alignment views with new info.
+     * when false, zeroth pane is panel derived from input deta.
      */
-    /**
-     * Seq associated data files (PDB files). 1. locate seq association in
-     * current dataset/alignment context and add file as normal - keep handle of
-     * any created ref objects. 2. decide if new data should be displayed : PDB
-     * display: if alignment has PDB display already, should new pdb files be
-     * aligned to it ?
-     * 
-     */
-    jalview.gui.AlignmentPanel destPanel = null;
+    boolean newAlignment = false;
     if (merge)
     {
       if (!restClient.isAlignmentModified())
@@ -534,11 +519,14 @@ public class RestJobThread extends AWSThread
         {
           destPanel = destPanel.alignFrame.newView(false);
         }
+        // add the destination panel to frame zero of result panel set
+        destPanels.add(destPanel);
       }
     }
-    if (destPanel == null)
+    if (destPanels.size()==0)
     {
-      Object[] idat = input.getAlignmentAndColumnSelection(restClient.av.getGapCharacter());
+      Object[] idat = input.getAlignmentAndColumnSelection(restClient.av
+              .getGapCharacter());
       AlignFrame af = new AlignFrame((AlignmentI) idat[0],
               (ColumnSelection) idat[1], AlignFrame.DEFAULT_WIDTH,
               AlignFrame.DEFAULT_HEIGHT);
@@ -549,20 +537,92 @@ public class RestJobThread extends AWSThread
               AlignFrame.DEFAULT_HEIGHT);
       destPanel = af.alignPanel;
       // create totally new alignment from stashed data/results
+      newAlignment = true;
     }
-    else
+    // Now process results, adding/creating new views as necessary.
     {
+      boolean hsepjobs = restClient.service.isHseparable();
+      boolean vsepjobs = restClient.service.isVseparable();
+      // total number of distinct alignment sets generated by job set.
+      int totalSets = 0, numAlSets = 0;
       for (int j = 0; j < jobs.length; j++)
       {
         RestJob rj = (RestJob) jobs[j];
-        if (rj.jvresultobj!=null && rj.jvresultobj.length>0) {
-          // transfer results onto panel
-          
+        if (rj.hasResults())
+        {
+          JalviewDataset rset = rj.context;
+          numAlSets = rset.hasAlignments() ? 0 : rset.getAl().size();
+          if (numAlSets > 0)
+          {
+            for (int als = 0; als < numAlSets; als++)
+            {
+              // gather data from context
+              if (vsepjobs)
+              {
+                // todo: merge data from each group/sequence onto whole
+                // alignment
+              }
+              else
+              {
+                if (hsepjobs)
+                {
+                  // map single result back on to all visible region of original alignment
+                  if (als==0 && rj.isInputContextModified())
+                  {
+                    // transfer features, annotation, groups, etc, from input context to align panel derived from input data
+                    new jalview.datamodel.Alignment(new jalview.datamodel.SequenceI[] {null}).getAlignmentAnnotation();
+                  }
+                  
+                }
+                else
+                {
+                  // map result onto visible contigs.
+                  AlignmentSet alset = rset.getAl().get(als);
+                  if (als>0 )
+                  if (als == 0)
+                  {
+                    
+                    // alignment is added straight to 
+                  }
+                }
+              }
+            }
+          }
         }
+        // transfer results onto panel
+
       }
+      /**
+       * alignments. New alignments are added to dataset, and subsequently
+       * annotated/visualised accordingly. 1. New alignment frame created for
+       * new alignment. Decide if any vis settings should be inherited from old
+       * alignment frame (e.g. sequence ordering ?). 2. Subsequent data added to
+       * alignment as below:
+       */
+      /**
+       * annotation update to original/newly created context alignment: 1.
+       * identify alignment where annotation is to be loaded onto. 2. Add
+       * annotation, excluding any duplicates. 3. Ensure annotation is visible
+       * on alignment - honouring ordering given by file.
+       */
+      /**
+       * features updated to original or newly created context alignment: 1.
+       * Features are(or were already) added to dataset. 2. Feature settings
+       * modified to ensure all features are displayed - honouring any ordering
+       * given by result file. Consider merging action with the code used by the
+       * DAS fetcher to update alignment views with new info.
+       */
+      /**
+       * Seq associated data files (PDB files). 1. locate seq association in
+       * current dataset/alignment context and add file as normal - keep handle
+       * of any created ref objects. 2. decide if new data should be displayed :
+       * PDB display: if alignment has PDB display already, should new pdb files
+       * be aligned to it ?
+       * 
+       */
+
     }
-    destPanel.adjustAnnotationHeight();
-    
+    // destPanel.adjustAnnotationHeight();
 
   }