(JAL-976,JAL-975) disorder client menu items and check type of input sequence for...
authorjprocter <jprocter@compbio.dundee.ac.uk>
Mon, 7 Nov 2011 13:18:01 +0000 (13:18 +0000)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Mon, 7 Nov 2011 13:18:01 +0000 (13:18 +0000)
src/jalview/ws/jws2/SequenceAnnotationWSClient.java

index fea8f2a..e3f3674 100644 (file)
@@ -41,20 +41,21 @@ public class SequenceAnnotationWSClient extends Jws2Client
           AlignFrame alignFrame, WsParamSetI preset, boolean editParams)
   {
     super(alignFrame, preset, null);
-    if (sh.serviceType.toLowerCase().contains("aaconws"))
+    if (alignFrame.getViewport().getAlignment().isNucleotide())
     {
-      // 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;
+      JOptionPane
+              .showMessageDialog(
+                      Desktop.desktop,
+                      sh.serviceType+" can only be used\nfor amino acid alignments.",
+                      "Wrong type of sequences!",
+                      JOptionPane.WARNING_MESSAGE);
+      return;
+
+    }
+    if (sh.action.toLowerCase().contains("conservation"))
+    {
+      // Build an AACons style client - take alignment, return annotation for columns
 
-      }
       List<AlignCalcWorkerI> clnts = alignFrame.getViewport()
               .getCalcManager()
               .getRegisteredWorkersOfClass(AAConsClient.class);
@@ -88,7 +89,21 @@ public class SequenceAnnotationWSClient extends Jws2Client
 
       }
     }
-    
+    if (sh.action.toLowerCase().contains("disorder"))
+    {
+      // build IUPred style client. take sequences, returns annotation per sequence.
+      if (!processParams(sh, editParams))
+      {
+        return;
+      }
+
+      alignFrame
+              .getViewport()
+              .getCalcManager()
+              .startWorker(
+                      new AADisorderClient(sh, alignFrame, preset, paramset));
+    }
+
   }
 
   /*
@@ -100,62 +115,61 @@ public class SequenceAnnotationWSClient extends Jws2Client
   public void attachWSMenuEntry(JMenu wsmenu, final Jws2Instance service,
           final AlignFrame alignFrame)
   {
-    if (service.serviceType.toLowerCase().contains("aaconws"))
+    boolean hasparams = service.hasParameters();
+    // Assume name ends in WS
+    String calcName = service.serviceType.substring(0,service.serviceType.length()-2);
+
+    JMenuItem aacons = new JMenuItem(calcName + " Defaults");
+    aacons.addActionListener(new ActionListener()
     {
-      boolean hasparams = service.hasParameters();
-      String calcName = "AACons";
-      JMenuItem aacons = new JMenuItem("AACons Defaults");
-      aacons.addActionListener(new ActionListener()
+
+      @Override
+      public void actionPerformed(ActionEvent e)
       {
+        new SequenceAnnotationWSClient(service, alignFrame, null, false);
+      }
+    });
+    wsmenu.add(aacons);
+    if (hasparams)
+    {
+      // only add these menu options if the service has user-modifiable
+      // arguments
+      aacons = new JMenuItem("Edit settings and run ...");
+      aacons.setToolTipText("View and change parameters before running calculation");
 
-        @Override
+      aacons.addActionListener(new ActionListener()
+      {
         public void actionPerformed(ActionEvent e)
         {
-          new SequenceAnnotationWSClient(service, alignFrame, null, false);
+          new SequenceAnnotationWSClient(service, alignFrame, null, true);
         }
       });
       wsmenu.add(aacons);
-      if (hasparams)
+      List<WsParamSetI> presets = service.getParamStore().getPresets();
+      if (presets != null && presets.size() > 0)
       {
-        // only add these menu options if the service has user-modifiable
-        // arguments
-        aacons = new JMenuItem("Edit settings and run ...");
-        aacons.setToolTipText("View and change the parameters before alignment.");
+        JMenu presetlist = new JMenu("Run " + calcName + "with preset");
 
-        aacons.addActionListener(new ActionListener()
-        {
-          public void actionPerformed(ActionEvent e)
-          {
-            new SequenceAnnotationWSClient(service, alignFrame, null, true);
-          }
-        });
-        wsmenu.add(aacons);
-        List<WsParamSetI> presets = service.getParamStore().getPresets();
-        if (presets != null && presets.size() > 0)
+        for (final WsParamSetI preset : presets)
         {
-          JMenu presetlist = new JMenu("Run " + calcName + "with preset");
-
-          for (final WsParamSetI preset : presets)
+          final JMenuItem methodR = new JMenuItem(preset.getName());
+          methodR.setToolTipText("<html><p>"
+                  + JvSwingUtils.wrapTooltip("<strong>"
+                          + (preset.isModifiable() ? "User Preset"
+                                  : "Service Preset") + "</strong><br/>"
+                          + preset.getDescription() + "</p>") + "</html>");
+          methodR.addActionListener(new ActionListener()
           {
-            final JMenuItem methodR = new JMenuItem(preset.getName());
-            methodR.setToolTipText("<html><p>"
-                    + JvSwingUtils.wrapTooltip("<strong>"
-                            + (preset.isModifiable() ? "User Preset"
-                                    : "Service Preset") + "</strong><br/>"
-                            + preset.getDescription() + "</p>") + "</html>");
-            methodR.addActionListener(new ActionListener()
+            public void actionPerformed(ActionEvent e)
             {
-              public void actionPerformed(ActionEvent e)
-              {
-                new SequenceAnnotationWSClient(service, alignFrame, preset,
-                        false);
-              }
-
-            });
-            presetlist.add(methodR);
-          }
-          wsmenu.add(presetlist);
+              new SequenceAnnotationWSClient(service, alignFrame, preset,
+                      false);
+            }
+
+          });
+          presetlist.add(methodR);
         }
+        wsmenu.add(presetlist);
       }
 
     }