From: Jim Procter Date: Thu, 16 Nov 2017 18:40:50 +0000 (+0000) Subject: JAL-2822 rejig new dataset after edit computation so it works for test cases X-Git-Tag: Release_2_11_1_0~98^2~7 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=e39c567c1a0c8deeb68797abc14111967d9ddb91;p=jalview.git JAL-2822 rejig new dataset after edit computation so it works for test cases --- diff --git a/src/jalview/commands/EditCommand.java b/src/jalview/commands/EditCommand.java index 894dc75..874948f 100644 --- a/src/jalview/commands/EditCommand.java +++ b/src/jalview/commands/EditCommand.java @@ -762,7 +762,7 @@ public class EditCommand implements CommandI Range beforeEditedPositions = command.seqs[i].findPositions(1, start); Range afterEditedPositions = command.seqs[i] - .findPositions(start + end + 1, command.seqs[i].getLength()); + .findPositions(end + 1, command.seqs[i].getLength()); oldstring = command.seqs[i].getSequenceAsString(); tmp = new StringBuffer(oldstring.substring(0, start)); @@ -770,8 +770,6 @@ public class EditCommand implements CommandI String nogaprep = jalview.analysis.AlignSeq.extractGaps( jalview.util.Comparison.GapChars, new String(command.string[i])); - int ipos = command.seqs[i].findPosition(start) - - command.seqs[i].getStart(); if (end < oldstring.length()) { tmp.append(oldstring.substring(end)); @@ -813,9 +811,22 @@ public class EditCommand implements CommandI // first edit the original dataset sequence string SequenceI oldds = command.seqs[i].getDatasetSequence(); String osp = oldds.getSequenceAsString(); - - String fullseq = osp.substring(0, ipos) + nogaprep - + osp.substring(ipos + nogaprep.length()); + int beforeStartOfEdit = -oldds.getStart() + 1 + + (beforeEditedPositions == null + ? ((afterEditedPositions != null) + ? afterEditedPositions.getBegin() - 1 + : oldstartend.getBegin() + + nogapold.length()) + : beforeEditedPositions.getEnd() + ); + int afterEndOfEdit = -oldds.getStart() + 1 + + ((afterEditedPositions == null) + ? oldstartend.getEnd() + : afterEditedPositions.getBegin() - 1); + String fullseq = osp.substring(0, + beforeStartOfEdit) + + nogaprep + + osp.substring(afterEndOfEdit); // and check if new sequence data is different.. if (!fullseq.equalsIgnoreCase(osp)) @@ -830,6 +841,14 @@ public class EditCommand implements CommandI command.oldds = new SequenceI[command.seqs.length]; } command.oldds[i] = command.seqs[i].getDatasetSequence(); + + // And preserve start/end for good-measure + + if (command.oldStartEnd == null) + { + command.oldStartEnd = new Range[command.seqs.length]; + } + command.oldStartEnd[i] = oldstartend; // TODO: JAL-1131 ensure newly created dataset sequence is added to // the set of // dataset sequences associated with the alignment.