added SeqSearch service interface. Documented and refactored web service client ...
[jalview.git] / src / jalview / ws / MsaWSClient.java
index 03a801e..63e60d7 100755 (executable)
@@ -18,6 +18,9 @@
  */
 package jalview.ws;
 
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
 import javax.swing.*;
 
 import ext.vamsas.*;
@@ -83,6 +86,12 @@ public class MsaWSClient
 
   }
 
+  public MsaWSClient()
+  {
+    super();
+    // add a class reference to the list
+  }
+
   private void startMsaWSClient(String altitle, AlignmentView msa,
                                 boolean submitGaps, boolean preserveOrder,
                                 Alignment seqdataset)
@@ -167,4 +176,55 @@ public class MsaWSClient
   {
     return "Multiple Sequence Alignment";
   }
+  /**
+   * look at ourselves and work out if we are a service that can take a profile and align to it 
+   * @return true if we can send gapped sequences to the alignment service
+   */
+  private boolean canSubmitGaps()
+  {
+    // TODO: query service or extract service handle props to check if we can realign
+    return (WebServiceName.indexOf("lustal") > -1); // cheat!
+  }
+  public void attachWSMenuEntry(JMenu msawsmenu, final ServiceHandle serviceHandle, final AlignFrame alignFrame)
+  {
+    setWebService(serviceHandle, true); // headless
+    JMenuItem method = new JMenuItem(WebServiceName);
+    method.setToolTipText(WsURL);
+    method.addActionListener(new ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        AlignmentView msa = alignFrame.gatherSequencesForAlignment();
+        new jalview.ws.MsaWSClient(serviceHandle, alignFrame.getTitle(), msa,
+                                   false, true,
+                                   alignFrame.getViewport().getAlignment().getDataset(),
+                                   alignFrame);
+
+      }
+
+    });
+    msawsmenu.add(method);    
+    if (canSubmitGaps())
+    {
+      // We know that ClustalWS can accept partial alignments for refinement.
+      final JMenuItem methodR = new JMenuItem(serviceHandle.getName()+" Realign");
+      methodR.setToolTipText(WsURL);
+        methodR.addActionListener(new ActionListener()
+      {
+        public void actionPerformed(ActionEvent e)
+        {
+          AlignmentView msa = alignFrame.gatherSequencesForAlignment();
+          new jalview.ws.MsaWSClient(serviceHandle, alignFrame.getTitle(), msa,
+                                     true, true,
+                                     alignFrame.getViewport().getAlignment().getDataset(),
+                                     alignFrame);
+
+        }
+
+      });
+      msawsmenu.add(methodR);
+
+    }
+
+  }
 }