JAL-1587 JAL-407 instrument setDataset to add dataset sequences to existing dataset...
authorJim Procter <jprocter@dundee.ac.uk>
Mon, 17 Nov 2014 14:38:16 +0000 (14:38 +0000)
committerJim Procter <jprocter@dundee.ac.uk>
Mon, 17 Nov 2014 14:38:16 +0000 (14:38 +0000)
src/jalview/datamodel/Alignment.java

index b2d4f0f..c1f3c2a 100755 (executable)
@@ -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();
   }