{\r
seqs = viewport.getSelectionGroup().sequences;\r
start = viewport.getSelectionGroup().getStartRes();\r
- end = viewport.getSelectionGroup().getEndRes();\r
+ end = viewport.getSelectionGroup().getEndRes()+1;\r
}\r
else\r
seqs = viewport.alignment.getSequences();\r
\r
- for (int i = 0; i <seqs.size(); i++)\r
+ for (int i = 0; i < seqs.size(); i++)\r
{\r
- current = (SequenceI)seqs.elementAt(i);\r
+ current = (SequenceI) seqs.elementAt(i);\r
jSize = current.getLength();\r
\r
+ // Removing a range is much quicker than removing gaps\r
+ // one by one for long sequences\r
int j = start;\r
+ int rangeStart=-1, rangeEnd=-1;\r
+\r
do\r
{\r
if (jalview.util.Comparison.isGap(current.getCharAt(j)))\r
{\r
- current.deleteCharAt(j);\r
- j--;\r
- jSize--;\r
+ if(rangeStart==-1)\r
+ {\r
+ rangeStart = j;\r
+ rangeEnd = j+1;\r
+ }\r
+ else\r
+ {\r
+ rangeEnd++;\r
+ }\r
+ j++;\r
}\r
- j++;\r
+ else\r
+ {\r
+ if(rangeStart>-1)\r
+ {\r
+ current.deleteChars(rangeStart, rangeEnd);\r
+ j-=rangeEnd-rangeStart;\r
+ jSize-=rangeEnd-rangeStart;\r
+ rangeStart = -1;\r
+ rangeEnd = -1;\r
+ }\r
+ else\r
+ j++;\r
+ }\r
+ }\r
+ while (j < end && j < jSize);\r
+ if(rangeStart>-1)\r
+ {\r
+ current.deleteChars(rangeStart, rangeEnd);\r
}\r
- while(j < end && j < jSize) ;\r
}\r
-\r
viewport.setStartRes(seq.findIndex(startRes)-1);\r
viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());\r
}\r
*/\r
protected void delete_actionPerformed(ActionEvent e)\r
{\r
- boolean seqsdeleted = false;\r
\r
if (viewport.getSelectionGroup() == null)\r
{\r
\r
if (seq.getSequence().length() < 1)\r
{\r
- seqsdeleted = true;\r
viewport.getAlignment().deleteSequence(seq);\r
}\r
else\r
{\r
seqs = viewport.getSelectionGroup().sequences;\r
start = viewport.getSelectionGroup().getStartRes();\r
- end = viewport.getSelectionGroup().getEndRes();\r
+ end = viewport.getSelectionGroup().getEndRes()+1;\r
}\r
else\r
{\r
current = (SequenceI) seqs.elementAt(i);\r
jSize = current.getLength();\r
\r
+ // Removing a range is much quicker than removing gaps\r
+ // one by one for long sequences\r
int j = start;\r
+ int rangeStart=-1, rangeEnd=-1;\r
\r
do\r
{\r
if (jalview.util.Comparison.isGap(current.getCharAt(j)))\r
{\r
- current.deleteCharAt(j);\r
- j--;\r
- jSize--;\r
+ if(rangeStart==-1)\r
+ {\r
+ rangeStart = j;\r
+ rangeEnd = j+1;\r
+ }\r
+ else\r
+ {\r
+ rangeEnd++;\r
+ }\r
+ j++;\r
+ }\r
+ else\r
+ {\r
+ if(rangeStart>-1)\r
+ {\r
+ current.deleteChars(rangeStart, rangeEnd);\r
+ j-=rangeEnd-rangeStart;\r
+ jSize-=rangeEnd-rangeStart;\r
+ rangeStart = -1;\r
+ rangeEnd = -1;\r
+ }\r
+ else\r
+ j++;\r
}\r
- j++;\r
}\r
while (j < end && j < jSize);\r
+ if(rangeStart>-1)\r
+ {\r
+ current.deleteChars(rangeStart, rangeEnd);\r
+ }\r
}\r
\r
viewport.setStartRes(seq.findIndex(startRes)-1);\r