JAL-2046 simpler deriveSequence - promote to dataset and initSeqFrom or defer to...
authorJim Procter <jprocter@issues.jalview.org>
Tue, 5 Apr 2016 17:25:27 +0000 (18:25 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Tue, 5 Apr 2016 17:45:35 +0000 (18:45 +0100)
src/jalview/datamodel/Sequence.java

index fbe3670..d9b810d 100755 (executable)
@@ -1056,31 +1056,24 @@ public class Sequence extends ASequence implements SequenceI
   @Override
   public SequenceI deriveSequence()
   {
-    SequenceI seq = new Sequence(this);
-    if (datasetSequence != null)
-    {
-      // duplicate current sequence with same dataset
-      seq.setDatasetSequence(datasetSequence);
-    }
-    else
+    Sequence seq=null;
+    if (datasetSequence == null)
     {
       if (isValidDatasetSequence())
       {
         // Use this as dataset sequence
+        seq = new Sequence(getName(), "", 1, -1);
         seq.setDatasetSequence(this);
+        seq.initSeqFrom(this, getAnnotation());
+        return seq;
       }
       else
       {
         // Create a new, valid dataset sequence
-        SequenceI ds = seq;
-        ds.setSequence(AlignSeq.extractGaps(
-                jalview.util.Comparison.GapChars, new String(sequence)));
-        setDatasetSequence(ds);
-        ds.setSequenceFeatures(getSequenceFeatures());
-        seq = this; // and return this sequence as the derived sequence.
+       createDatasetSequence();
       }
     }
-    return seq;
+    return new Sequence(this);
   }
 
   /*