(JAL-975) ensure AACons is only run on protein sequences. (note - should really fix...
authorjprocter <jprocter@compbio.dundee.ac.uk>
Fri, 4 Nov 2011 16:58:24 +0000 (16:58 +0000)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Fri, 4 Nov 2011 16:58:24 +0000 (16:58 +0000)
src/jalview/ws/jws2/AAConsClient.java
src/jalview/ws/jws2/SequenceAnnotationWSClient.java

index 7aaa2fe..054c9ab 100644 (file)
@@ -135,7 +135,7 @@ public class AAConsClient extends AlignCalcWorker
 
       int aWidth = -1;
 
-      if (alignment == null || (aWidth = alignment.getWidth()) < 0)
+      if (alignment == null || (aWidth = alignment.getWidth()) < 0 || alignment.isNucleotide())
       {
         calcMan.workerComplete(this);
         return;
index 3e4cbe1..fea8f2a 100644 (file)
@@ -9,12 +9,15 @@ import java.util.List;
 
 import javax.swing.JMenu;
 import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
 
 import compbio.metadata.Argument;
 
 import jalview.api.AlignCalcWorkerI;
 import jalview.datamodel.AlignmentView;
 import jalview.gui.AlignFrame;
+import jalview.gui.Desktop;
+import jalview.gui.JalviewDialog;
 import jalview.gui.JvSwingUtils;
 import jalview.ws.jws2.jabaws2.Jws2Instance;
 import jalview.ws.params.WsParamSetI;
@@ -38,37 +41,54 @@ public class SequenceAnnotationWSClient extends Jws2Client
           AlignFrame alignFrame, WsParamSetI preset, boolean editParams)
   {
     super(alignFrame, preset, null);
-    List<AlignCalcWorkerI> clnts = alignFrame.getViewport()
-            .getCalcManager()
-            .getRegisteredWorkersOfClass(AAConsClient.class);
-    if (clnts == null || clnts.size() == 0)
+    if (sh.serviceType.toLowerCase().contains("aaconws"))
     {
-      if (!processParams(sh, editParams))
+      // Build an AACons client
+      if (alignFrame.getViewport().getAlignment().isNucleotide())
       {
+        JOptionPane
+                .showMessageDialog(
+                        Desktop.desktop,
+                        "AACons can only be used\nfor amino acid alignments.\nSorry about that!",
+                        "Wrong type of sequences!",
+                        JOptionPane.WARNING_MESSAGE);
         return;
+
       }
-      alignFrame
-              .getViewport()
+      List<AlignCalcWorkerI> clnts = alignFrame.getViewport()
               .getCalcManager()
-              .registerWorker(
-                      new AAConsClient(sh, alignFrame, preset, paramset));
-    }
-    else
-    {
-      AAConsClient worker = (AAConsClient) clnts.get(0);
-      if (editParams)
+              .getRegisteredWorkersOfClass(AAConsClient.class);
+      if (clnts == null || clnts.size() == 0)
       {
-        paramset = worker.getArguments();
-        preset = worker.getPreset();
+        if (!processParams(sh, editParams))
+        {
+          return;
+        }
+        alignFrame
+                .getViewport()
+                .getCalcManager()
+                .registerWorker(
+                        new AAConsClient(sh, alignFrame, preset, paramset));
       }
+      else
+      {
+        AAConsClient worker = (AAConsClient) clnts.get(0);
+        if (editParams)
+        {
+          paramset = worker.getArguments();
+          preset = worker.getPreset();
+        }
 
-      if (!processParams(sh, editParams, true))
-        return;
-      // reinstate worker if it was blacklisted (might have happened due to invalid parameters)
-      alignFrame.getViewport().getCalcManager().workerMayRun(worker);
-      worker.updateParameters(preset, paramset);
+        if (!processParams(sh, editParams, true))
+          return;
+        // reinstate worker if it was blacklisted (might have happened due to
+        // invalid parameters)
+        alignFrame.getViewport().getCalcManager().workerMayRun(worker);
+        worker.updateParameters(preset, paramset);
 
+      }
     }
+    
   }
 
   /*
@@ -84,7 +104,6 @@ public class SequenceAnnotationWSClient extends Jws2Client
     {
       boolean hasparams = service.hasParameters();
       String calcName = "AACons";
-      System.out.println("Making an aacons client!");
       JMenuItem aacons = new JMenuItem("AACons Defaults");
       aacons.addActionListener(new ActionListener()
       {