JAL-4199 Perform null check for annotation sequenceRef
[jalview.git] / 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();