JAL-4199 Remove utility methods moved to other classes from AnnotationTask
authorMateusz Warowny <mmzwarowny@dundee.ac.uk>
Thu, 6 Jul 2023 13:54:34 +0000 (15:54 +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 238439a..ed67643 100644 (file)
@@ -150,13 +150,13 @@ public class AnnotationTask extends BaseTask<AnnotationJob, AnnotationResult>
      * visibility */
 
     udpateCalcId(returnedAnnot);
-    int graphGroup = getNextGraphGroup(viewport.getAlignment());
+    int graphGroup = viewport.getAlignment().getLastGraphGroup();
     shiftGraphGroup(returnedAnnot, graphGroup);
     List<AlignmentAnnotation> annotations = new ArrayList<>();
     for (AlignmentAnnotation ala : returnedAnnot)
     {
       SequenceI seq = job.seqNames.get(ala.sequenceRef.getName());
-      SequenceI aseq = getRootDatasetSequence(seq);
+      SequenceI aseq = seq.getRootDatasetSequence();
       Annotation[] gappedAnnots = createGappedAnnotations(ala.annotations, job.start, job.gapMap);
       ala.sequenceRef = aseq;
       ala.annotations = gappedAnnots;
@@ -180,7 +180,7 @@ public class AnnotationTask extends BaseTask<AnnotationJob, AnnotationResult>
         continue;
       hasFeatures = true;
       SequenceI seq = job.seqNames.get(sq.getName());
-      SequenceI datasetSeq = getRootDatasetSequence(seq);
+      SequenceI datasetSeq = seq.getRootDatasetSequence();
       List<ContiguousI> sourceRange = findContiguousRanges(datasetSeq, job.gapMap, job.start, job.end);
       int[] sourceStartEnd = ContiguousI.toStartEndArray(sourceRange);
       Mapping mp = new Mapping(new MapList(
@@ -208,16 +208,6 @@ public class AnnotationTask extends BaseTask<AnnotationJob, AnnotationResult>
     }
   }
 
-  private static int getNextGraphGroup(AlignmentI alignment)
-  {
-    if (alignment == null || alignment.getAlignmentAnnotation() == null)
-      return 1;
-    int graphGroup = 1;
-    for (AlignmentAnnotation ala : alignment.getAlignmentAnnotation())
-      graphGroup = Math.max(graphGroup, ala.graphGroup);
-    return graphGroup;
-  }
-
   private static void shiftGraphGroup(Iterable<AlignmentAnnotation> annotations, int shift)
   {
     for (AlignmentAnnotation ala : annotations)
@@ -229,15 +219,6 @@ public class AnnotationTask extends BaseTask<AnnotationJob, AnnotationResult>
     }
   }
 
-  private static SequenceI getRootDatasetSequence(SequenceI sequence)
-  {
-    while (sequence.getDatasetSequence() != null)
-    {
-      sequence = sequence.getDatasetSequence();
-    }
-    return sequence;
-  }
-
   private Annotation[] createGappedAnnotations(Annotation[] annotations, int start, boolean[] gapMap)
   {
     var size = Math.max(viewport.getAlignment().getWidth(), gapMap.length);