Implement getRootDatasetSequence for SequenceI
authorMateusz Warowny <mmzwarowny@dundee.ac.uk>
Thu, 6 Jul 2023 13:26:25 +0000 (15:26 +0200)
committerMateusz Warowny <mmzwarowny@dundee.ac.uk>
Wed, 12 Jul 2023 14:25:05 +0000 (16:25 +0200)
src/jalview/datamodel/SequenceI.java

index 8f1d160..d8a5462 100755 (executable)
@@ -396,6 +396,19 @@ public interface SequenceI extends ASequenceI
   public SequenceI getDatasetSequence();
 
   /**
+   * Returns the top grandparent in the dataset sequences hierarchy.
+   */
+  public default SequenceI getRootDatasetSequence()
+  {
+    var sequence = this;
+    while (sequence.getDatasetSequence() != null)
+    {
+      sequence = sequence.getDatasetSequence();
+    }
+    return sequence;
+  }
+
+  /**
    * Returns a new array containing this sequence's annotations, or null.
    */
   public AlignmentAnnotation[] getAnnotation();