From: Mateusz Warowny Date: Fri, 27 Sep 2019 15:58:56 +0000 (+0100) Subject: JAL-3066 Automatically discoverable Protein sequence analysis services X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=6a7ffd7997c11b84a81acbdd83e462cac76f124b;p=jalview.git JAL-3066 Automatically discoverable Protein sequence analysis services --- diff --git a/j11lib/slivka-client.jar b/j11lib/slivka-client.jar index c990dd8..a8e499a 100644 Binary files a/j11lib/slivka-client.jar and b/j11lib/slivka-client.jar differ diff --git a/src/jalview/ws/slivkaws/SlivkaAnnotationServiceInstance.java b/src/jalview/ws/slivkaws/SlivkaAnnotationServiceInstance.java index 4fb35a0..184ca2d 100644 --- a/src/jalview/ws/slivkaws/SlivkaAnnotationServiceInstance.java +++ b/src/jalview/ws/slivkaws/SlivkaAnnotationServiceInstance.java @@ -1,16 +1,23 @@ package jalview.ws.slivkaws; import jalview.api.FeatureColourI; +import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.SequenceI; import jalview.datamodel.features.FeatureMatcherSetI; +import jalview.io.AnnotationFile; import jalview.ws.api.JobId; import jalview.ws.api.SequenceAnnotationServiceI; import jalview.ws.params.ArgumentI; import jalview.ws.params.WsParamSetI; +import java.io.BufferedReader; import java.io.ByteArrayInputStream; +import java.io.IOError; +import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -25,7 +32,7 @@ public class SlivkaAnnotationServiceInstance extends SlivkaWSInstance implements { public SlivkaAnnotationServiceInstance(SlivkaClient client, SlivkaService service) { - super(client, service, "Annotations"); + super(client, service, "Annotations disorder"); } @Override @@ -71,7 +78,30 @@ public class SlivkaAnnotationServiceInstance extends SlivkaWSInstance implements List seqs, Map featureColours, Map featureFilters) throws Throwable { - // TODO Auto-generated method stub - return null; + RemoteFile annotFile = null; + RemoteFile featFile = null; + try + { + List files = client.getJobResults(job.getJobId()); + for (RemoteFile f : files) + { + if (f.getMimeType().equals("application/jalview-annotations")) + { + annotFile = f; + } + else if (f.getMimeType().equals("application/jalview-features")) + { + featFile = f; + } + } + } catch (IOException e) + { + throw new IOError(e); + } + Alignment aln = new Alignment(seqs.toArray(new SequenceI[0])); + BufferedReader in = new BufferedReader(new InputStreamReader(annotFile.getContent())); + AnnotationFile f = new AnnotationFile(); + f.parseAnnotationFrom(aln, null, in); + return Arrays.asList(aln.getAlignmentAnnotation()); } } diff --git a/src/jalview/ws/slivkaws/SlivkaWSDiscoverer.java b/src/jalview/ws/slivkaws/SlivkaWSDiscoverer.java index e9d0d53..6b3856a 100644 --- a/src/jalview/ws/slivkaws/SlivkaWSDiscoverer.java +++ b/src/jalview/ws/slivkaws/SlivkaWSDiscoverer.java @@ -4,6 +4,7 @@ import jalview.datamodel.AlignmentView; import jalview.gui.AlignFrame; import jalview.ws.WSMenuEntryProviderI; import jalview.ws.jws2.MsaWSClient; +import jalview.ws.jws2.SequenceAnnotationWSClient; import java.awt.event.ActionEvent; import java.io.IOError; @@ -47,9 +48,9 @@ public class SlivkaWSDiscoverer implements Runnable, WSMenuEntryProviderI { JMenu slivkaMenu = new JMenu("Slivka"); wsmenu.add(slivkaMenu); - JMenu categoryMenu = new JMenu("Alignment"); - slivkaMenu.add(categoryMenu); + JMenu alignmentMenu = new JMenu("Sequence Alignment"); + slivkaMenu.add(alignmentMenu); try { for (SlivkaService service : client.getServices()) @@ -75,7 +76,7 @@ public class SlivkaWSDiscoverer implements Runnable, WSMenuEntryProviderI alignFrame.getViewport().getAlignment().getDataset(), alignFrame); } }); - categoryMenu.add(defaultEntry); + alignmentMenu.add(defaultEntry); JMenuItem customEntry = new JMenuItem(String.format("%s with custom parameters", service.label)); customEntry.addActionListener((ActionEvent evt) -> { @@ -93,15 +94,53 @@ public class SlivkaWSDiscoverer implements Runnable, WSMenuEntryProviderI } } }); - categoryMenu.add(customEntry); + alignmentMenu.add(customEntry); - categoryMenu.addSeparator(); + alignmentMenu.addSeparator(); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } + + JMenu disorderMenu = new JMenu("Protein sequence analysis"); + slivkaMenu.add(disorderMenu); + try + { + for (SlivkaService service : client.getServices()) + { + msaClassifier: + { + for (String classifier : service.classifiers) + { + if (classifier.contains("Protein sequence analysis")) + { + break msaClassifier; + } + } + continue; + } + JMenuItem menuEntry = new JMenuItem(String.format("%s with custom parameters", service.label)); + disorderMenu.add(menuEntry); + SlivkaAnnotationServiceInstance serviceInstance = new SlivkaAnnotationServiceInstance(client, service); + menuEntry.addActionListener((ActionEvent evt) -> { + try + { + SlivkaParamSet paramSet = new SlivkaParamSet(service); + SequenceAnnotationWSClient client = new SequenceAnnotationWSClient(); + client.initSequenceAnnotationWSClient(serviceInstance, alignFrame, paramSet, true); + } catch (IOException e) + { + throw new IOError(e); + } + + }); + } + } catch (IOException e) + { + throw new IOError(e); + } } @Override