From 186a71ee78452e42f53560bb6ea25494799b05bd Mon Sep 17 00:00:00 2001 From: Mateusz Warowny Date: Thu, 6 Jul 2023 15:26:25 +0200 Subject: [PATCH] Implement getRootDatasetSequence for SequenceI --- src/jalview/datamodel/SequenceI.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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(); -- 1.7.10.2