From 7850b5cdcf8f8b19fdf8c1e29498b35f609f754f Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Mon, 17 Nov 2014 14:38:16 +0000 Subject: [PATCH] JAL-1587 JAL-407 instrument setDataset to add dataset sequences to existing dataset if they aren't already present --- src/jalview/datamodel/Alignment.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index b2d4f0f..c1f3c2a 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -950,6 +950,27 @@ public class Alignment implements AlignmentI else if (dataset == null && data != null) { dataset = data; + for (int i = 0; i < getHeight(); i++) + { + SequenceI currentSeq = getSequenceAt(i); + SequenceI dsq = currentSeq.getDatasetSequence(); + if (dsq == null) + { + dsq = currentSeq.createDatasetSequence(); + dataset.addSequence(dsq); + } + else + { + while (dsq.getDatasetSequence() != null) + { + dsq = dsq.getDatasetSequence(); + } + if (dataset.findIndex(dsq) == -1) + { + dataset.addSequence(dsq); + } + } + } } dataset.addAlignmentRef(); } -- 1.7.10.2