From: gmungoc Date: Mon, 13 Nov 2017 09:08:36 +0000 (+0000) Subject: JAL-2541 add new dataset sequence to alignment dataset X-Git-Tag: Release_2_11_1_0~98^2~15 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=72fafa02724acf81264142acb90d1c1428b21638;p=jalview.git JAL-2541 add new dataset sequence to alignment dataset --- diff --git a/src/jalview/commands/EditCommand.java b/src/jalview/commands/EditCommand.java index 334f30d..d603a0d 100644 --- a/src/jalview/commands/EditCommand.java +++ b/src/jalview/commands/EditCommand.java @@ -536,8 +536,21 @@ public class EditCommand implements CommandI boolean cutIsInternal = cutPositions != null && sequence.getStart() != cutPositions .getBegin() && sequence.getEnd() != cutPositions.getEnd(); + + /* + * perform the cut; if this results in a new dataset sequence, add + * that to the alignment dataset + */ + SequenceI ds = sequence.getDatasetSequence(); sequence.deleteChars(command.position, command.position + command.number); + SequenceI newDs = sequence.getDatasetSequence(); + if (newDs != ds && command.al != null + && command.al.getDataset() != null + && !command.al.getDataset().getSequences().contains(newDs)) + { + command.al.getDataset().addSequence(newDs); + } if (command.oldds != null && command.oldds[i] != null) { @@ -556,12 +569,13 @@ public class EditCommand implements CommandI { command.oldds = new SequenceI[command.seqs.length]; } - command.oldds[i] = oldds; + command.oldds[i] = oldds;// todo not if !cutIsInternal? // do we need to edit sequence features for new sequence ? if (oldds != sequence.getDatasetSequence() || (cutIsInternal && sequence.getFeatures().hasFeatures())) + // todo or just test cutIsInternal && cutPositions != null ? { if (cutPositions != null) { @@ -1529,7 +1543,7 @@ public class EditCommand implements CommandI *
  • features right of the cut are shifted left
  • *
  • features internal to the cut region are deleted
  • *
  • features that overlap or span the cut are shortened
  • - *
  • the originals of any deleted or shorted features are saved, to re-add + *
  • the originals of any deleted or shortened features are saved, to re-add * on Undo
  • *
  • any added (shortened) features are saved, to delete on Undo
  • * @@ -1543,8 +1557,9 @@ public class EditCommand implements CommandI protected static void cutFeatures(Edit command, SequenceI seq, int fromPosition, int toPosition, boolean cutIsInternal) { - /* if the cut is at start or end of sequence - * then we don't modify the seuqence feature store + /* + * if the cut is at start or end of sequence + * then we don't modify the sequence feature store */ if (!cutIsInternal) {