From e45f54d4072df812ae41de43105a302dc106ab43 Mon Sep 17 00:00:00 2001 From: Mateusz Warowny Date: Fri, 28 Jul 2023 14:24:16 +0200 Subject: [PATCH] JAL-4241 Create sequence mapping before adjusting annotations --- .../ws/jws2/SeqAnnotationServiceCalcWorker.java | 24 +++++++------------- 1 file changed, 8 insertions(+), 16 deletions(-) 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(); -- 1.7.10.2