JAL-3070 JAL-3062 tidy up slivka ws menu builder and add in AACons style service UI
authorJim Procter <jprocter@issues.jalview.org>
Wed, 2 Oct 2019 14:19:41 +0000 (15:19 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Wed, 2 Oct 2019 14:19:41 +0000 (15:19 +0100)
src/jalview/ws/slivkaws/SlivkaAnnotationServiceInstance.java
src/jalview/ws/slivkaws/SlivkaWSDiscoverer.java

index 4aaae6a..80e44ec 100644 (file)
@@ -8,10 +8,12 @@ import jalview.datamodel.features.FeatureMatcherSetI;
 import jalview.io.AnnotationFile;
 import jalview.io.DataSourceType;
 import jalview.io.FeaturesFile;
+import jalview.util.MessageManager;
 import jalview.ws.api.JobId;
 import jalview.ws.api.SequenceAnnotationServiceI;
 import jalview.ws.params.ArgumentI;
 import jalview.ws.params.WsParamSetI;
+import jalview.ws.uimodel.AlignAnalysisUIText;
 
 import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
@@ -32,9 +34,21 @@ import uk.ac.dundee.compbio.slivkaclient.SlivkaService;
 
 public class SlivkaAnnotationServiceInstance extends SlivkaWSInstance implements SequenceAnnotationServiceI
 {
-  public SlivkaAnnotationServiceInstance(SlivkaClient client, SlivkaService service)
+  public SlivkaAnnotationServiceInstance(SlivkaClient client,
+          SlivkaService service, boolean conservation)
   {
-    super(client, service, "Annotations disorder");
+    super(client, service, !conservation ? "Annotations disorder"
+            : "Alignment Conservation");
+    if (conservation)
+    {
+      setAlignAnalysisUI(new AlignAnalysisUIText(getServiceType(),
+              SlivkaAnnotationServiceInstance.class,
+              "Slivka.AACons", false, true, true, true, true, 2,
+              MessageManager.getString("label.aacon_calculations"),
+              MessageManager.getString("tooltip.aacon_calculations"),
+              MessageManager.getString("label.aacon_settings"),
+              MessageManager.getString("tooltip.aacon_settings")));
+    }
   }
 
   @Override
index 56f7b9f..993d8ed 100644 (file)
@@ -40,6 +40,36 @@ public class SlivkaWSDiscoverer implements Runnable, WSMenuEntryProviderI
     return instance;
   }
 
+  private void addMsaServiceClient(JMenu alignmentMenu,
+          SlivkaService service, AlignFrame alignFrame)
+  {
+    SlivkaMsaServiceInstance instance = new SlivkaMsaServiceInstance(
+            slivkaClient, service);
+    MsaWSClient client = new MsaWSClient();
+    client.attachWSMenuEntry(alignmentMenu, instance, alignFrame);
+    alignmentMenu.addSeparator();
+  }
+
+  private void addDisorderServiceClient(JMenu disorderMenu,
+          SlivkaService service, AlignFrame alignFrame)
+  {
+    SlivkaAnnotationServiceInstance serviceInstance = new SlivkaAnnotationServiceInstance(
+            slivkaClient, service, false);
+    SequenceAnnotationWSClient client = new SequenceAnnotationWSClient();
+    client.attachWSMenuEntry(disorderMenu, serviceInstance, alignFrame);
+    disorderMenu.addSeparator();
+  }
+
+  private void addConservationServiceClient(JMenu conservationMenu,
+          SlivkaService service, AlignFrame alignFrame)
+  {
+    SlivkaAnnotationServiceInstance serviceInstance = new SlivkaAnnotationServiceInstance(
+            slivkaClient, service, true);
+    SequenceAnnotationWSClient client = new SequenceAnnotationWSClient();
+    client.attachWSMenuEntry(conservationMenu, serviceInstance, alignFrame);
+    conservationMenu.addSeparator();
+  }
+
   @Override
   public void attachWSMenuEntry(JMenu wsmenu, final AlignFrame alignFrame)
   {
@@ -48,53 +78,32 @@ public class SlivkaWSDiscoverer implements Runnable, WSMenuEntryProviderI
 
     JMenu alignmentMenu = new JMenu("Sequence Alignment");
     slivkaMenu.add(alignmentMenu);
-    try
-    {
-      for (SlivkaService service : slivkaClient.getServices())
-      {
-        msaClassifier:
-        {
-          for (String classifier : service.classifiers)
-          {
-            if (classifier.contains("Multiple sequence alignment"))
-            {
-              break msaClassifier;
-            }
-          }
-          continue;
-        }
-        SlivkaMsaServiceInstance instance = new SlivkaMsaServiceInstance(slivkaClient, service);
-        MsaWSClient client = new MsaWSClient();
-        client.attachWSMenuEntry(alignmentMenu, instance, alignFrame);
-        alignmentMenu.addSeparator();
-      }
-    } catch (IOException e)
-    {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
-    }
-
     JMenu disorderMenu = new JMenu("Protein sequence analysis");
     slivkaMenu.add(disorderMenu);
+    JMenu conservationMenu = new JMenu("Conservation");
+    slivkaMenu.add(conservationMenu);
     try
     {
       for (SlivkaService service : slivkaClient.getServices())
       {
-        msaClassifier:
+        for (String classifier : service.classifiers)
         {
-          for (String classifier : service.classifiers)
+          if (classifier.contains("Multiple sequence alignment"))
+          {
+            addMsaServiceClient(alignmentMenu, service, alignFrame);
+          }
+          else if (classifier.contains("Protein sequence analysis"))
           {
-            if (classifier.contains("Protein sequence analysis"))
-            {
-              break msaClassifier;
-            }
+            addDisorderServiceClient(disorderMenu, service, alignFrame);
           }
-          continue;
+          else if (classifier
+                  .contains("Sequence alignment analysis (conservation)"))
+          {
+            addConservationServiceClient(conservationMenu, service,
+                    alignFrame);
+          }
+
         }
-        SlivkaAnnotationServiceInstance serviceInstance = new SlivkaAnnotationServiceInstance(slivkaClient, service);
-        SequenceAnnotationWSClient client = new SequenceAnnotationWSClient();
-        client.attachWSMenuEntry(disorderMenu, serviceInstance, alignFrame);
-        disorderMenu.addSeparator();
       }
     } catch (IOException e)
     {