From cf8e8c6b06fc4272ef915b061ffb12ce555a9bb8 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Tue, 5 Apr 2016 18:12:59 +0100 Subject: [PATCH] JAL-2046 safer createDatasetSequence manipulates private fields and moves sequenceFeatures to dataset --- src/jalview/datamodel/Sequence.java | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/jalview/datamodel/Sequence.java b/src/jalview/datamodel/Sequence.java index 6c8cbc0..6f1b403 100755 --- a/src/jalview/datamodel/Sequence.java +++ b/src/jalview/datamodel/Sequence.java @@ -1074,20 +1074,27 @@ public class Sequence extends ASequence implements SequenceI { if (datasetSequence == null) { - datasetSequence = new Sequence(getName(), AlignSeq.extractGaps( + Sequence dsseq = new Sequence(getName(), AlignSeq.extractGaps( jalview.util.Comparison.GapChars, getSequenceAsString()), getStart(), getEnd()); - datasetSequence.setSequenceFeatures(getSequenceFeatures()); - datasetSequence.setDescription(getDescription()); - setSequenceFeatures(null); - // move database references onto dataset sequence - datasetSequence.setDBRefs(getDBRefs()); - setDBRefs(null); - datasetSequence.setPDBId(getAllPDBEntries()); - setPDBId(null); + + datasetSequence = dsseq; + + dsseq.setDescription(description); + // move features and database references onto dataset sequence + dsseq.sequenceFeatures = sequenceFeatures; + sequenceFeatures=null; + dsseq.dbrefs = dbrefs; + dbrefs=null; + // TODO: search and replace any references to this sequence with + // references to the dataset sequence in Mappings on dbref + dsseq.pdbIds = pdbIds; + pdbIds = null; datasetSequence.updatePDBIds(); if (annotation != null) { + // annotation is cloned rather than moved, to preserve what's currently + // on the alignment for (AlignmentAnnotation aa : annotation) { AlignmentAnnotation _aa = new AlignmentAnnotation(aa); -- 1.7.10.2