From: Jim Procter Date: Tue, 5 Apr 2016 17:12:59 +0000 (+0100) Subject: JAL-2046 safer createDatasetSequence manipulates private fields and moves sequenceFea... X-Git-Tag: Release_2_10_0~249^2~31^2~12 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=cf8e8c6b06fc4272ef915b061ffb12ce555a9bb8;p=jalview.git JAL-2046 safer createDatasetSequence manipulates private fields and moves sequenceFeatures to dataset --- 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);