JAL-4199 Perform null check for annotation sequenceRef
authorMateusz Warowny <mmzwarowny@dundee.ac.uk>
Fri, 7 Jul 2023 08:53:02 +0000 (10:53 +0200)
committerMateusz Warowny <mmzwarowny@dundee.ac.uk>
Wed, 12 Jul 2023 14:25:05 +0000 (16:25 +0200)
src/jalview/ws2/actions/annotation/AnnotationTask.java

index ed67643..a448b3c 100644 (file)
@@ -155,15 +155,18 @@ public class AnnotationTask extends BaseTask<AnnotationJob, AnnotationResult>
     List<AlignmentAnnotation> annotations = new ArrayList<>();
     for (AlignmentAnnotation ala : returnedAnnot)
     {
-      SequenceI seq = job.seqNames.get(ala.sequenceRef.getName());
-      SequenceI aseq = seq.getRootDatasetSequence();
-      Annotation[] gappedAnnots = createGappedAnnotations(ala.annotations, job.start, job.gapMap);
+      SequenceI aseq = 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) // I suspect it's always true
+      if (aseq != null)
       {
         aseq.addAlignmentAnnotation(newAnnot);
         newAnnot.adjustForAlignment();