\r
public boolean padGaps() {\r
boolean modified=false;\r
- int Width = getWidth();\r
+\r
+ //Remove excess gaps from the end of alignment\r
+ int maxLength = -1;\r
+\r
SequenceI current;\r
+ for (int i = 0; i < sequences.size(); i++)\r
+ {\r
+ current = getSequenceAt(i);\r
+ for (int j = current.getLength(); j > maxLength; j--)\r
+ {\r
+ if (j > maxLength && !jalview.util.Comparison.isGap(\r
+ current.getCharAt(j)))\r
+ {\r
+ maxLength = j;\r
+ break;\r
+ }\r
+ }\r
+ }\r
+\r
+ maxLength++;\r
+\r
for (int i = 0; i < sequences.size();\r
i++)\r
{\r
current = getSequenceAt(i);\r
\r
- if (current.getLength() < Width)\r
+ if (current.getLength() < maxLength)\r
{\r
- current.insertCharAt(Width - 1, gapCharacter);\r
+ current.insertCharAt(maxLength - 1, gapCharacter);\r
modified=true;\r
}\r
+ else if(current.getLength() > maxLength)\r
+ {\r
+ current.deleteChars(maxLength, current.getLength());\r
+ }\r
}\r
return modified;\r
}\r