git://source.jalview.org
/
jalview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
983d1a8
)
JAL-2541 save/Undo only 'diffs' for features with Cut command
author
gmungoc
<g.m.carstairs@dundee.ac.uk>
Wed, 21 Jun 2017 12:46:50 +0000
(13:46 +0100)
committer
gmungoc
<g.m.carstairs@dundee.ac.uk>
Wed, 21 Jun 2017 12:58:42 +0000
(13:58 +0100)
src/jalview/commands/EditCommand.java
patch
|
blob
|
history
src/jalview/datamodel/features/SequenceFeatures.java
patch
|
blob
|
history
src/jalview/datamodel/features/SequenceFeaturesI.java
patch
|
blob
|
history
diff --git
a/src/jalview/commands/EditCommand.java
b/src/jalview/commands/EditCommand.java
index
a92dca7
..
1c6726e
100644
(file)
--- a/
src/jalview/commands/EditCommand.java
+++ b/
src/jalview/commands/EditCommand.java
@@
-552,6
+552,10
@@
public class EditCommand implements CommandI
command.oldds = new SequenceI[command.seqs.length];
}
command.oldds[i] = oldds;
command.oldds = new SequenceI[command.seqs.length];
}
command.oldds[i] = oldds;
+ if (oldds != sequence.getDatasetSequence())
+ {
+ oldds.getFeatures().deleteAll();
+ }
if (cutPositions != null)
{
if (cutPositions != null)
{
@@
-581,22
+585,21
@@
public class EditCommand implements CommandI
*/
static void paste(Edit command, AlignmentI[] views)
{
*/
static void paste(Edit command, AlignmentI[] views)
{
- StringBuffer tmp;
- boolean newDSNeeded;
- boolean newDSWasNeeded;
- int newstart, newend;
boolean seqWasDeleted = false;
boolean seqWasDeleted = false;
- int start = 0, end = 0;
for (int i = 0; i < command.seqs.length; i++)
{
for (int i = 0; i < command.seqs.length; i++)
{
- newDSNeeded = false;
- newDSWasNeeded = command.oldds != null && command.oldds[i] != null;
+ int start = 0;
+ int end = 0;
+ boolean newDSNeeded = false;
+ boolean newDSWasNeeded = command.oldds != null
+ && command.oldds[i] != null;
SequenceI sequence = command.seqs[i];
if (sequence.getLength() < 1)
{
SequenceI sequence = command.seqs[i];
if (sequence.getLength() < 1)
{
- // ie this sequence was deleted, we need to
- // readd it to the alignment
+ /*
+ * sequence was deleted; re-add it to the alignment
+ */
if (command.alIndex[i] < command.al.getHeight())
{
List<SequenceI> sequences;
if (command.alIndex[i] < command.al.getHeight())
{
List<SequenceI> sequences;
@@
-614,10
+617,10
@@
public class EditCommand implements CommandI
}
seqWasDeleted = true;
}
}
seqWasDeleted = true;
}
- newstart = sequence.getStart();
- newend = sequence.getEnd();
+ int newStart = sequence.getStart();
+ int newEnd = sequence.getEnd();
- tmp = new StringBuffer();
+ StringBuilder tmp = new StringBuilder();
tmp.append(sequence.getSequence());
// Undo of a delete does not replace original dataset sequence on to
// alignment sequence.
tmp.append(sequence.getSequence());
// Undo of a delete does not replace original dataset sequence on to
// alignment sequence.
@@
-649,11
+652,11
@@
public class EditCommand implements CommandI
}
if (sequence.getStart() == start)
{
}
if (sequence.getStart() == start)
{
- newstart--;
+ newStart--;
}
else
{
}
else
{
- newend++;
+ newEnd++;
}
}
}
}
}
}
@@
-661,8
+664,14
@@
public class EditCommand implements CommandI
}
sequence.setSequence(tmp.toString());
}
sequence.setSequence(tmp.toString());
- sequence.setStart(newstart);
- sequence.setEnd(newend);
+ sequence.setStart(newStart);
+ sequence.setEnd(newEnd);
+
+ /*
+ * command and Undo share the same dataset sequence if cut was
+ * at start or end of sequence
+ */
+ boolean sameDatasetSequence = false;
if (newDSNeeded)
{
if (sequence.getDatasetSequence() != null)
if (newDSNeeded)
{
if (sequence.getDatasetSequence() != null)
@@
-687,9
+696,11
@@
public class EditCommand implements CommandI
command.oldds = new SequenceI[command.seqs.length];
}
command.oldds[i] = sequence.getDatasetSequence();
command.oldds = new SequenceI[command.seqs.length];
}
command.oldds[i] = sequence.getDatasetSequence();
+ sameDatasetSequence = ds == sequence.getDatasetSequence();
+ ds.setSequenceFeatures(sequence.getSequenceFeatures());
sequence.setDatasetSequence(ds);
}
sequence.setDatasetSequence(ds);
}
- undoCutFeatures(command, i, start, end);
+ undoCutFeatures(command, i, start, end, sameDatasetSequence);
}
}
adjustAnnotations(command, true, seqWasDeleted, views);
}
}
adjustAnnotations(command, true, seqWasDeleted, views);
@@
-1101,7
+1112,7
@@
public class EditCommand implements CommandI
}
final static void undoCutFeatures(Edit command, int index, final int i,
}
final static void undoCutFeatures(Edit command, int index, final int i,
- final int j)
+ final int j, boolean sameDatasetSequence)
{
SequenceI seq = command.seqs[index];
SequenceI sequence = seq.getDatasetSequence();
{
SequenceI seq = command.seqs[index];
SequenceI sequence = seq.getDatasetSequence();
@@
-1111,10
+1122,13
@@
public class EditCommand implements CommandI
}
/*
}
/*
- * TODO: shift right features that lie to the right of the restored cut
- * Currently not needed as all features restored with saved dataset sequence
- * nor if no saved dataset sequence (as coordinates left unchanged by Cut)
+ * shift right features that lie to the right of the restored cut
+ * (but not if dataset sequence unchanged - coordinates left unchanged by Cut)
*/
*/
+ if (!sameDatasetSequence)
+ {
+ seq.getFeatures().shiftFeatures(i + 1, j - i);
+ }
/*
* restore any features that were deleted or truncated
/*
* restore any features that were deleted or truncated
@@
-1469,7
+1483,6
@@
public class EditCommand implements CommandI
* truncate left, adjust end of feature
*/
newBegin = cutIsInternal ? cutStartPos : cutEndPos + 1;
* truncate left, adjust end of feature
*/
newBegin = cutIsInternal ? cutStartPos : cutEndPos + 1;
- // newEnd = newBegin + (sfEnd - sfBegin) - overlapsBy;
newEnd = newBegin + sfEnd - cutEndPos - 1;
if (sf.isContactFeature())
{
newEnd = newBegin + sfEnd - cutEndPos - 1;
if (sf.isContactFeature())
{
diff --git
a/src/jalview/datamodel/features/SequenceFeatures.java
b/src/jalview/datamodel/features/SequenceFeatures.java
index
3a927e4
..
d1bae50
100644
(file)
--- a/
src/jalview/datamodel/features/SequenceFeatures.java
+++ b/
src/jalview/datamodel/features/SequenceFeatures.java
@@
-491,4
+491,13
@@
public class SequenceFeatures implements SequenceFeaturesI
}
return modified;
}
}
return modified;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void deleteAll()
+ {
+ featureStore.clear();
+ }
}
\ No newline at end of file
}
\ No newline at end of file
diff --git
a/src/jalview/datamodel/features/SequenceFeaturesI.java
b/src/jalview/datamodel/features/SequenceFeaturesI.java
index
803ef0c
..
f3d8a16
100644
(file)
--- a/
src/jalview/datamodel/features/SequenceFeaturesI.java
+++ b/
src/jalview/datamodel/features/SequenceFeaturesI.java
@@
-205,4
+205,9
@@
public interface SequenceFeaturesI
* @param shiftBy
*/
boolean shiftFeatures(int fromPosition, int shiftBy);
* @param shiftBy
*/
boolean shiftFeatures(int fromPosition, int shiftBy);
+
+ /**
+ * Deletes all positional and non-positional features
+ */
+ void deleteAll();
}
\ No newline at end of file
}
\ No newline at end of file