From: Mateusz Warowny Date: Thu, 19 Sep 2019 13:35:46 +0000 (+0100) Subject: JAL-3066 Auto discover multiple sequence alignment services X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=1cca7d8fe617a8a1587bc325bdce2d922f818445;p=jalview.git JAL-3066 Auto discover multiple sequence alignment services --- diff --git a/j11lib/slivka-client.jar b/j11lib/slivka-client.jar index 9efae32..12cc028 100644 Binary files a/j11lib/slivka-client.jar and b/j11lib/slivka-client.jar differ diff --git a/src/jalview/ws/slivkaws/SlivkaWSDiscoverer.java b/src/jalview/ws/slivkaws/SlivkaWSDiscoverer.java index fc90a69..009e388 100644 --- a/src/jalview/ws/slivkaws/SlivkaWSDiscoverer.java +++ b/src/jalview/ws/slivkaws/SlivkaWSDiscoverer.java @@ -14,6 +14,7 @@ import javax.swing.JMenu; import javax.swing.JMenuItem; import uk.ac.dundee.compbio.slivkaclient.SlivkaClient; +import uk.ac.dundee.compbio.slivkaclient.SlivkaService; public class SlivkaWSDiscoverer implements Runnable, WSMenuEntryProviderI @@ -42,61 +43,61 @@ public class SlivkaWSDiscoverer @Override public void attachWSMenuEntry(JMenu wsmenu, final AlignFrame alignFrame) { - JMenu submenu = new JMenu("Slivka"); + JMenu slivkaMenu = new JMenu("Slivka"); + wsmenu.add(slivkaMenu); + JMenu categoryMenu = new JMenu("Alignment"); + slivkaMenu.add(categoryMenu); - String[] services = { "clustalo", "clustalw", "probcons", "muscle", "mafft", "tcoffee" }; - String[] names = { "ClustalO", "ClustalW2", "Probcons", "Muscle", "Mafft", "TCoffe" }; - - for (int i = 0; i < services.length; i++) + try { - try - { - SlivkaWSInstance instance = new SlivkaWSInstance(client, - client.getService(services[i])); - - JMenuItem defaultMenuItem = new JMenuItem( - String.format("%s with defaults", names[i])); - defaultMenuItem.addActionListener((ActionEvent e) -> { + for (SlivkaService service: client.getServices()) { + msaClassifier: { + for (String classifier: service.classifiers) { + if (classifier.contains("Multiple sequence alignment")) { + break msaClassifier; + } + } + continue; + } + SlivkaWSInstance instance = new SlivkaWSInstance(client, service); + JMenuItem defaultEntry = new JMenuItem(String.format("%s with defaults", service.label)); + defaultEntry.addActionListener((ActionEvent evt) -> { AlignmentView msa = alignFrame.gatherSequencesForAlignment(); - if (msa != null) - { - new MsaWSClient(instance, alignFrame.getTitle(), msa, false, true, + if (msa != null) { + new MsaWSClient( + instance, alignFrame.getTitle(), msa, false, true, alignFrame.getViewport().getAlignment().getDataset(), - alignFrame); + alignFrame + ); } }); - submenu.add(defaultMenuItem); - - JMenuItem customMenuItem = new JMenuItem( - String.format("%s with custom parameters", names[i])); - customMenuItem.addActionListener((ActionEvent e) -> { + categoryMenu.add(defaultEntry); + + JMenuItem customEntry = new JMenuItem(String.format("%s with custom parameters", service.label)); + customEntry.addActionListener((ActionEvent evt) -> { AlignmentView msa = alignFrame.gatherSequencesForAlignment(); - if (msa != null) - { + if (msa != null) { try { - SlivkaParamSet paramSet = new SlivkaParamSet( - instance.getService()); - new MsaWSClient(instance, paramSet, null, true, - alignFrame.getTitle(), msa, false, true, - alignFrame.getViewport().getAlignment().getDataset(), - alignFrame); - } catch (IOException e1) + SlivkaParamSet paramSet = new SlivkaParamSet(service); + new MsaWSClient( + instance, paramSet, null, true, alignFrame.getTitle(), msa, false, true, + alignFrame.getViewport().getAlignment().getDataset(), alignFrame); + } catch (IOException exc) { - throw new IOError(e1); + throw new IOError(exc); } - } }); - submenu.add(customMenuItem); - } catch (IOException e) - { - // TODO Auto-generated catch block - e.printStackTrace(); + categoryMenu.add(customEntry); + + categoryMenu.addSeparator(); } + } catch (IOException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); } - - wsmenu.add(submenu); } @Override