X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws2%2Factions%2Fannotation%2FAnnotationTask.java;h=866f862e1ad10957c0e9a52f4d9a21e5cd7f788f;hb=4e47d166b44617b1cb3cabc3ea3ed72f1a0ad545;hp=0aaff23a01847026ce517d3146c223d6d0a080f4;hpb=84208814e3b7f5c386105252bd489637fab82e37;p=jalview.git diff --git a/src/jalview/ws2/actions/annotation/AnnotationTask.java b/src/jalview/ws2/actions/annotation/AnnotationTask.java index 0aaff23..866f862 100644 --- a/src/jalview/ws2/actions/annotation/AnnotationTask.java +++ b/src/jalview/ws2/actions/annotation/AnnotationTask.java @@ -31,7 +31,9 @@ public class AnnotationTask extends BaseTask private final AnnotationAction action; - private final AlignViewportI viewport; + private final AlignmentI alignment; + + private final AnnotatedCollectionI selectionGroup; public AnnotationTask(AnnotationWebServiceClientI client, AnnotationAction action, List args, Credentials credentials, @@ -40,7 +42,8 @@ public class AnnotationTask extends BaseTask super(client, args, credentials); this.client = client; this.action = action; - this.viewport = viewport; + this.alignment = viewport.getAlignment(); + this.selectionGroup = viewport.getSelectionGroup(); } /** @@ -55,7 +58,6 @@ public class AnnotationTask extends BaseTask @Override public List prepareJobs() throws ServiceInputInvalidException { - AlignmentI alignment = viewport.getAlignment(); if (alignment == null || alignment.getWidth() <= 0 || alignment.getSequences() == null) throw new ServiceInputInvalidException("Alignment does not contain sequences"); @@ -66,7 +68,7 @@ public class AnnotationTask extends BaseTask throw new ServiceInputInvalidException( action.getFullName() + " does not allow protein sequences"); boolean bySequence = !action.isAlignmentAnalysis(); - AnnotatedCollectionI inputSeqs = bySequence ? viewport.getSelectionGroup() : null; + AnnotatedCollectionI inputSeqs = bySequence ? selectionGroup : null; if (inputSeqs == null || inputSeqs.getWidth() <= 0 || inputSeqs.getSequences() == null || inputSeqs.getSequences().size() < 1) inputSeqs = alignment; @@ -100,30 +102,17 @@ public class AnnotationTask extends BaseTask * visibility */ udpateCalcId(returnedAnnot); - int graphGroup = viewport.getAlignment().getLastGraphGroup(); - shiftGraphGroup(returnedAnnot, graphGroup); - List annotations = new ArrayList<>(); for (AlignmentAnnotation ala : returnedAnnot) { SequenceI aseq = null; - if (ala.sequenceRef != null) { + if (ala.sequenceRef != null) + { SequenceI seq = job.seqNames.get(ala.sequenceRef.getName()); aseq = seq.getRootDatasetSequence(); } ala.sequenceRef = aseq; Annotation[] gappedAnnots = createGappedAnnotations(ala.annotations, job.start, job.gapMap); ala.annotations = gappedAnnots; - - AlignmentAnnotation newAnnot = viewport.getAlignment() - .updateFromOrCopyAnnotation(ala); - if (aseq != null) - { - aseq.addAlignmentAnnotation(newAnnot); - newAnnot.adjustForAlignment(); - AlignmentAnnotationUtils.replaceAnnotationOnAlignmentWith( - newAnnot, newAnnot.label, newAnnot.getCalcId()); - } - annotations.add(newAnnot); } boolean hasFeatures = false; @@ -142,7 +131,7 @@ public class AnnotationTask extends BaseTask datasetSeq.transferAnnotation(sq, mp); } - return new AnnotationResult(annotations, hasFeatures, featureColours, featureFilters); + return new AnnotationResult(returnedAnnot, hasFeatures, featureColours, featureFilters); } /** @@ -161,20 +150,9 @@ public class AnnotationTask extends BaseTask } } - private static void shiftGraphGroup(Iterable annotations, int shift) - { - for (AlignmentAnnotation ala : annotations) - { - if (ala.graphGroup > 0) - { - ala.graphGroup += shift; - } - } - } - private Annotation[] createGappedAnnotations(Annotation[] annotations, int start, boolean[] gapMap) { - var size = Math.max(viewport.getAlignment().getWidth(), gapMap.length); + var size = Math.max(alignment.getWidth(), gapMap.length); Annotation[] gappedAnnotations = new Annotation[size]; for (int p = 0, ap = start; ap < size; ap++) {