From 465ec4d5f251d139a207ab5c3280717234b74b7b Mon Sep 17 00:00:00 2001 From: Mateusz Warowny Date: Wed, 26 Jul 2023 14:03:14 +0200 Subject: [PATCH] JAL-4245 Return null from getRootDataset if no dataset --- src/jalview/datamodel/SequenceI.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/jalview/datamodel/SequenceI.java b/src/jalview/datamodel/SequenceI.java index d8a5462..11aa4e6 100755 --- a/src/jalview/datamodel/SequenceI.java +++ b/src/jalview/datamodel/SequenceI.java @@ -396,11 +396,16 @@ public interface SequenceI extends ASequenceI public SequenceI getDatasetSequence(); /** - * Returns the top grandparent in the dataset sequences hierarchy. + * Returns the top grandparent in the dataset sequences hierarchy + * or null if there is no dataset associated with this sequence. */ public default SequenceI getRootDatasetSequence() { - var sequence = this; + if (getDatasetSequence() == null) + { + return null; + } + var sequence = getDatasetSequence(); while (sequence.getDatasetSequence() != null) { sequence = sequence.getDatasetSequence(); -- 1.7.10.2