From 816f6d685d041b982810be8129129b02a440417c Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Mon, 12 Sep 2005 17:00:39 +0000 Subject: [PATCH] Remove gaps in regions, not char by char --- src/jalview/appletgui/AlignFrame.java | 44 ++++++++++++++++++++++++++------- src/jalview/gui/AlignFrame.java | 38 ++++++++++++++++++++++------ 2 files changed, 66 insertions(+), 16 deletions(-) diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index ccf2bd2..14a341d 100755 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -623,30 +623,56 @@ public class AlignFrame { seqs = viewport.getSelectionGroup().sequences; start = viewport.getSelectionGroup().getStartRes(); - end = viewport.getSelectionGroup().getEndRes(); + end = viewport.getSelectionGroup().getEndRes()+1; } else seqs = viewport.alignment.getSequences(); - for (int i = 0; i -1) + { + current.deleteChars(rangeStart, rangeEnd); + j-=rangeEnd-rangeStart; + jSize-=rangeEnd-rangeStart; + rangeStart = -1; + rangeEnd = -1; + } + else + j++; + } + } + while (j < end && j < jSize); + if(rangeStart>-1) + { + current.deleteChars(rangeStart, rangeEnd); } - while(j < end && j < jSize) ; } - viewport.setStartRes(seq.findIndex(startRes)-1); viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences()); } diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 8e3dfc8..e82356c 100755 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -744,7 +744,6 @@ public class AlignFrame */ protected void delete_actionPerformed(ActionEvent e) { - boolean seqsdeleted = false; if (viewport.getSelectionGroup() == null) { @@ -776,7 +775,6 @@ public class AlignFrame if (seq.getSequence().length() < 1) { - seqsdeleted = true; viewport.getAlignment().deleteSequence(seq); } else @@ -1005,7 +1003,7 @@ public class AlignFrame { seqs = viewport.getSelectionGroup().sequences; start = viewport.getSelectionGroup().getStartRes(); - end = viewport.getSelectionGroup().getEndRes(); + end = viewport.getSelectionGroup().getEndRes()+1; } else { @@ -1017,19 +1015,45 @@ public class AlignFrame current = (SequenceI) seqs.elementAt(i); jSize = current.getLength(); + // Removing a range is much quicker than removing gaps + // one by one for long sequences int j = start; + int rangeStart=-1, rangeEnd=-1; do { if (jalview.util.Comparison.isGap(current.getCharAt(j))) { - current.deleteCharAt(j); - j--; - jSize--; + if(rangeStart==-1) + { + rangeStart = j; + rangeEnd = j+1; + } + else + { + rangeEnd++; + } + j++; + } + else + { + if(rangeStart>-1) + { + current.deleteChars(rangeStart, rangeEnd); + j-=rangeEnd-rangeStart; + jSize-=rangeEnd-rangeStart; + rangeStart = -1; + rangeEnd = -1; + } + else + j++; } - j++; } while (j < end && j < jSize); + if(rangeStart>-1) + { + current.deleteChars(rangeStart, rangeEnd); + } } viewport.setStartRes(seq.findIndex(startRes)-1); -- 1.7.10.2