From: Mateusz Warowny Date: Thu, 6 Jul 2023 13:26:25 +0000 (+0200) Subject: Implement getRootDatasetSequence for SequenceI X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=186a71ee78452e42f53560bb6ea25494799b05bd;p=jalview.git Implement getRootDatasetSequence for SequenceI --- diff --git a/src/jalview/datamodel/SequenceI.java b/src/jalview/datamodel/SequenceI.java index 8f1d160..d8a5462 100755 --- a/src/jalview/datamodel/SequenceI.java +++ b/src/jalview/datamodel/SequenceI.java @@ -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();