From: Mateusz Warowny Date: Fri, 28 Jul 2023 12:24:16 +0000 (+0200) Subject: JAL-4241 Create sequence mapping before adjusting annotations X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=e45f54d4072df812ae41de43105a302dc106ab43;p=jalview.git JAL-4241 Create sequence mapping before adjusting annotations --- diff --git a/src/jalview/ws/jws2/SeqAnnotationServiceCalcWorker.java b/src/jalview/ws/jws2/SeqAnnotationServiceCalcWorker.java index 3253f43..e004bf5 100644 --- a/src/jalview/ws/jws2/SeqAnnotationServiceCalcWorker.java +++ b/src/jalview/ws/jws2/SeqAnnotationServiceCalcWorker.java @@ -702,26 +702,18 @@ public class SeqAnnotationServiceCalcWorker extends AlignCalcWorker { ala.graphGroup += graphGroup; } - SequenceI aseq = null; - - /** + SequenceI aseq = (ala.sequenceRef == null) ? null + : running.getSeqNames().get(ala.sequenceRef.getName()); + /* * transfer sequence refs and adjust gapmap + * Prepare an array for annotations and copy returned annotations to it + * according to gapMap if present. */ - if (ala.sequenceRef != null) - { - SequenceI seq = running.getSeqNames() - .get(ala.sequenceRef.getName()); - aseq = seq; - while (seq.getDatasetSequence() != null) - { - seq = seq.getDatasetSequence(); - } - } Annotation[] resAnnot = ala.annotations, gappedAnnot = new Annotation[Math.max( alignViewport.getAlignment().getWidth(), gapMap.length)]; - for (int p = 0, ap = start; ap < gappedAnnot.length; ap++) + for (int p = 0, ap = 0; ap < gappedAnnot.length; ap++) { if (gapMap != null && gapMap.length > ap && !gapMap[ap]) { @@ -733,12 +725,12 @@ public class SeqAnnotationServiceCalcWorker extends AlignCalcWorker } } ala.sequenceRef = aseq; - ala.annotations = gappedAnnot; AlignmentAnnotation newAnnot = getAlignViewport().getAlignment() .updateFromOrCopyAnnotation(ala); + newAnnot.annotations = gappedAnnot; if (aseq != null) { - + newAnnot.createSequenceMapping(aseq, aseq.findPosition(start), false); aseq.addAlignmentAnnotation(newAnnot); newAnnot.adjustForAlignment();