From: Jim Procter Date: Mon, 17 Nov 2014 14:38:16 +0000 (+0000) Subject: JAL-1587 JAL-407 instrument setDataset to add dataset sequences to existing dataset... X-Git-Tag: Jalview_2_9~149^2~9 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=7850b5cdcf8f8b19fdf8c1e29498b35f609f754f;p=jalview.git JAL-1587 JAL-407 instrument setDataset to add dataset sequences to existing dataset if they aren't already present --- 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(); }