From f80f1dd5762b7c035ca2502f35f059e9f5fe5a49 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Tue, 4 Oct 2016 11:58:56 +0100 Subject: [PATCH] JAL-2232 JAL-2154 update dbrefs to newly created dataset sequence --- src/jalview/datamodel/Alignment.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index 35ee8c4..2289ac6 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -24,6 +24,7 @@ import jalview.analysis.AlignmentUtils; import jalview.datamodel.AlignedCodonFrame.SequenceToSequenceMapping; import jalview.io.FastaFile; import jalview.util.Comparison; +import jalview.util.LinkedIdentityHashSet; import jalview.util.MessageManager; import java.util.ArrayList; @@ -1054,6 +1055,7 @@ public class Alignment implements AlignmentI private void resolveAndAddDatasetSeq(SequenceI currentSeq, Set seqs, boolean createDatasetSequence) { + SequenceI alignedSeq = currentSeq; if (currentSeq.getDatasetSequence() != null) { currentSeq = currentSeq.getDatasetSequence(); @@ -1088,12 +1090,19 @@ public class Alignment implements AlignmentI { if (dbr.getMap() != null && dbr.getMap().getTo() != null) { + if (dbr.getMap().getTo() == alignedSeq) + { + /* + * update mapping to be to the newly created dataset sequence + */ + dbr.getMap().setTo(currentSeq); + } if (dbr.getMap().getTo().getDatasetSequence() != null) { - throw new Error("Implementation error: Map.getTo() for dbref" - + dbr + " is not a dataset sequence."); - // TODO: if this happens, could also rewrite the reference to - // point to new dataset sequence + throw new Error( + "Implementation error: Map.getTo() for dbref " + dbr + + " from " + curDs.getName() + + " is not a dataset sequence."); } // we recurse to add all forward references to dataset sequences via // DBRefs/etc @@ -1115,7 +1124,7 @@ public class Alignment implements AlignmentI return; } // try to avoid using SequenceI.equals at this stage, it will be expensive - Set seqs = new jalview.util.LinkedIdentityHashSet(); + Set seqs = new LinkedIdentityHashSet(); for (int i = 0; i < getHeight(); i++) { -- 1.7.10.2