From a0477223e2f54d4c8f011da77ffcb3c879960a43 Mon Sep 17 00:00:00 2001 From: Mateusz Warowny Date: Thu, 7 Oct 2021 15:31:07 +0200 Subject: [PATCH] JAL-3878 Add dataset and viewport arguments to ResultSupplier. --- src/jalview/ws2/ResultSupplier.java | 7 +++++- src/jalview/ws2/operations/AlignmentOperation.java | 5 +++- src/jalview/ws2/slivka/SlivkaWebService.java | 26 +++++++++++++++++--- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/jalview/ws2/ResultSupplier.java b/src/jalview/ws2/ResultSupplier.java index e691b80..3642d8e 100644 --- a/src/jalview/ws2/ResultSupplier.java +++ b/src/jalview/ws2/ResultSupplier.java @@ -1,9 +1,14 @@ package jalview.ws2; import java.io.IOException; +import java.util.List; + +import jalview.api.AlignViewportI; +import jalview.datamodel.AlignmentI; +import jalview.datamodel.SequenceI; @FunctionalInterface public interface ResultSupplier { - public T getResult(WSJob job) throws IOException; + public T getResult(WSJob job, List dataset, AlignViewportI viewport) throws IOException; } diff --git a/src/jalview/ws2/operations/AlignmentOperation.java b/src/jalview/ws2/operations/AlignmentOperation.java index f836c91..b70678a 100644 --- a/src/jalview/ws2/operations/AlignmentOperation.java +++ b/src/jalview/ws2/operations/AlignmentOperation.java @@ -302,6 +302,8 @@ public class AlignmentOperation implements Operation private final AlignmentI dataset; + private final AlignViewport viewport; + private final List codonFrame = new ArrayList<>(); private List args = Collections.emptyList(); @@ -337,6 +339,7 @@ public class AlignmentOperation implements Operation this.alnTitle = alnTitle; this.submitGaps = submitGaps; this.preserveOrder = preserveOrder; + this.viewport = viewport; this.gapCharacter = viewport.getGapCharacter(); String panelInfo = String.format("%s using service hosted at %s%n%s", @@ -528,7 +531,7 @@ public class AlignmentOperation implements Operation continue; try { - AlignmentI alignment = supplier.getResult(job); + AlignmentI alignment = supplier.getResult(job, dataset.getSequences(), viewport); if (alignment != null) { results.put(job.getUid(), alignment); diff --git a/src/jalview/ws2/slivka/SlivkaWebService.java b/src/jalview/ws2/slivka/SlivkaWebService.java index aee6b73..82a2ba9 100644 --- a/src/jalview/ws2/slivka/SlivkaWebService.java +++ b/src/jalview/ws2/slivka/SlivkaWebService.java @@ -12,7 +12,10 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import jalview.api.AlignViewportI; import jalview.bin.Cache; +import jalview.datamodel.Alignment; +import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.SequenceI; import jalview.io.AnnotationFile; @@ -234,7 +237,8 @@ public class SlivkaWebService implements WebServiceI return false; } - public AlignmentI getAlignment(WSJob job) throws IOException + public AlignmentI getAlignment(WSJob job, List dataset, + AlignViewportI viewport) throws IOException { Collection files; var slivkaJob = client.getJob(job.getJobId()); @@ -255,7 +259,8 @@ public class SlivkaWebService implements WebServiceI return null; } - public FeaturesFile getFeaturesFile(WSJob job) throws IOException + public FeaturesFile getFeaturesFile(WSJob job, + List dataset, AlignViewportI viewport) throws IOException { var slivkaJob = client.getJob(job.getJobId()); Collection files = slivkaJob.getResults(); @@ -269,7 +274,8 @@ public class SlivkaWebService implements WebServiceI return null; } - public AnnotationFile getAnnotationFile(WSJob job) throws IOException + public List getAnnotationFile(WSJob job, + List dataset, AlignViewportI viewport) throws IOException { var slivkaJob = client.getJob(job.getJobId()); Collection files = slivkaJob.getResults(); @@ -277,7 +283,19 @@ public class SlivkaWebService implements WebServiceI { if (f.getMediaType().equals("application/jalview-annotations")) { - // return new AnnorationFile(...); + Alignment aln = new Alignment(dataset.toArray(new SequenceI[0])); + AnnotationFile af = new AnnotationFile(); + boolean valid = af.readAnnotationFileWithCalcId(aln, service.getId(), + f.getContentUrl().toString(), DataSourceType.URL); + if (valid) + { + return Arrays.asList(aln.getAlignmentAnnotation()); + } + else + { + throw new IOException("Unable to read annotations from file " + + f.getContentUrl().toString()); + } } } return null; -- 1.7.10.2